This is NSStringPropList.m in view mode; [Download] [Up]
/* * A n t l r T r a n s l a t i o n H e a d e r * * Terence Parr, Will Cohen, and Hank Dietz: 1989-1994 * Purdue University Electrical Engineering * With AHPCRC, University of Minnesota * ANTLR Version 1.33 */ #include <stdio.h> #define ANTLR_VERSION 133 #define zzparser NSStringPropertyListParser #include "remap.h" #include <objc/objc.h> #ifndef __Attrib_def__ #define __Attrib_def__ typedef id Attrib; #endif #define USER_ZZSYN #define zzcr_attr NSStringPropertyListParser_zzcr_attr void zzcr_attr(Attrib* attr, int token, char* text); #define zzSET_SIZE 8 #include "antlr.h" #include "tokens.h" #include "dlgdef.h" #include "mode.h" #ifndef PURIFY #define PURIFY(r,s) #endif ANTLR_INFO static zzchar_t *zzlextext; /* text of most recently matched token */ static zzchar_t *zzbegexpr; /* beginning of last reg expr recogn. */ static zzchar_t *zzendexpr; /* beginning of last reg expr recogn. */ static int zzbufsize; /* number of characters in zzlextext */ #include "err.m" #include "NSStringScanner.m" #include <ctype.h> #include <Foundation/NSString.h> #include <Foundation/NSData.h> #include <Foundation/NSArray.h> #include <Foundation/NSDictionary.h> #include <Foundation/NSAutoreleasePool.h> #include <Foundation/NSUtilities.h> #include <Foundation/NSException.h> #include <Foundation/exceptions/GeneralExceptions.h> static NSMutableString* NSStringPropertyListParser_errors; id readPropertyListFrom(NSString* string) { id plist = nil; id pool = [NSAutoreleasePool new]; NSStringPropertyListParser_errors = [[NSMutableString new] autorelease]; ANTLRs(plist = propertyList(), (char*)[string cString]); if(*[NSStringPropertyListParser_errors cString]) THROW([[SyntaxErrorException new] setReason:NSStringPropertyListParser_errors]); [plist retain]; [pool release]; return [[[plist autorelease] copy] autorelease]; } id readDictionary(NSString *string) { id plist = nil; id pool = [NSAutoreleasePool new]; NSStringPropertyListParser_errors = [[NSMutableString new] autorelease]; ANTLRs(plist = strings(), (char*)[string cString]); if(*[NSStringPropertyListParser_errors cString]) THROW([[SyntaxErrorException new] setReason:NSStringPropertyListParser_errors]); plist = [plist copy]; [pool release]; return [plist autorelease]; } static char make_hexa(char a, char b); void zzcr_attr(Attrib* attr, int token, char* text) { switch(token) { case DATA: { int i, pos, len = strlen(text); for(i = pos = 0; i < len; i += 2, pos++) text[pos] = make_hexa(text[i], text[i + 1] ? text[i + 1] : '0'); *attr = [NSData dataWithBytes:text length:pos]; break; } case STRING: *attr = [NSString stringWithCString:text]; break; } } void zzsyn(char* text, int tok, char* egroup, SetWordType* eset, int etok, int k, char*bad_text) { [NSStringPropertyListParser_errors appendFormat: @"line %d: syntax error at \"%s\"", zzline, (tok == zzEOF_TOKEN) ? "EOF" : bad_text]; if(!etok && !eset) { [NSStringPropertyListParser_errors appendString:@"\n"]; return; } if (k==1) [NSStringPropertyListParser_errors appendString:@" missing"]; else { [NSStringPropertyListParser_errors appendFormat:@"; \"%s\" not", bad_text]; if(zzset_deg(eset) > 1) [NSStringPropertyListParser_errors appendString:@" in"]; } if(zzset_deg(eset) > 0) zzedecode(eset); else [NSStringPropertyListParser_errors appendFormat:@" %s", zztokens[etok]]; if(strlen(egroup) > 0) [NSStringPropertyListParser_errors appendFormat:@" in %s", egroup]; [NSStringPropertyListParser_errors appendString:@"\n"]; } static char make_hexa(char a, char b) { char c = 0; if(isdigit(a)) c = (a - '0') << 4; else if(isalpha(a)) c = (tolower(a) - 'a' + 10) << 4; if(isdigit(b)) c += b - '0'; else if(isalpha(b)) c += tolower(b) - 'a' + 10; return c; } id #ifdef __STDC__ propertyList(void) #else propertyList() #endif { id _retv; PURIFY(_retv,sizeof( id )) zzRULE; zzBLOCK(zztasp1); zzMake0; { _retv=nil; pobj(); zzmatch(Eof); _retv=zzaArg(zztasp1,1); zzCONSUME; zzEXIT(zztasp1); return _retv; fail: zzEXIT(zztasp1); zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText); zzresynch(setwd1, 0x1); return _retv; } } void #ifdef __STDC__ pobj(void) #else pobj() #endif { zzRULE; zzBLOCK(zztasp1); zzMake0; { if ( (LA(1)==29) ) { plist(); zzaRet=zzaArg(zztasp1,1); } else { if ( (LA(1)==32) ) { dict(); zzaRet=zzaArg(zztasp1,1); } else { if ( (LA(1)==STRING) ) { zzmatch(STRING); zzaRet=zzaArg(zztasp1,1); zzCONSUME; } else { if ( (LA(1)==DATA) ) { zzmatch(DATA); zzaRet=zzaArg(zztasp1,1); zzCONSUME; } else {zzFAIL(1,zzerr1,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;} } } } zzEXIT(zztasp1); return; fail: zzEXIT(zztasp1); zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText); zzresynch(setwd1, 0x2); } } void #ifdef __STDC__ plist(void) #else plist() #endif { zzRULE; zzBLOCK(zztasp1); zzMake0; { zzaRet=[NSMutableArray array]; zzmatch(29); zzCONSUME; { zzBLOCK(zztasp2); zzMake0; { if ( (setwd1[LA(1)]&0x4) ) { pobj(); [zzaRet addObject:zzaArg(zztasp2,2)]; { zzBLOCK(zztasp3); zzMake0; { while ( (setwd1[LA(1)]&0x8) ) { { zzBLOCK(zztasp4); zzMake0; { if ( (LA(1)==30) ) { zzmatch(30); zzCONSUME; } zzEXIT(zztasp4); } } pobj(); [zzaRet addObject:zzaArg(zztasp3,2)]; zzLOOP(zztasp3); } zzEXIT(zztasp3); } } } zzEXIT(zztasp2); } } zzmatch(31); zzCONSUME; zzEXIT(zztasp1); return; fail: zzEXIT(zztasp1); zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText); zzresynch(setwd1, 0x10); } } void #ifdef __STDC__ dict(void) #else dict() #endif { zzRULE; zzBLOCK(zztasp1); zzMake0; { zzaRet=[NSMutableDictionary dictionary]; zzmatch(32); zzCONSUME; { zzBLOCK(zztasp2); zzMake0; { while ( (setwd1[LA(1)]&0x20) ) { pobj(); zzmatch(33); zzCONSUME; pobj(); { zzBLOCK(zztasp3); zzMake0; { if ( (LA(1)==34) ) { zzmatch(34); zzCONSUME; } zzEXIT(zztasp3); } } [zzaRet setObject:zzaArg(zztasp2,3) forKey:zzaArg(zztasp2,1)]; zzLOOP(zztasp2); } zzEXIT(zztasp2); } } zzmatch(35); zzCONSUME; zzEXIT(zztasp1); return; fail: zzEXIT(zztasp1); zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText); zzresynch(setwd1, 0x40); } } id #ifdef __STDC__ strings(void) #else strings() #endif { id _retv; PURIFY(_retv,sizeof( id )) zzRULE; zzBLOCK(zztasp1); zzMake0; { _retv=[NSMutableDictionary dictionary]; { zzBLOCK(zztasp2); zzMake0; { while ( (LA(1)==STRING) ) { zzmatch(STRING); zzCONSUME; zzmatch(33); zzCONSUME; zzmatch(STRING); zzCONSUME; { zzBLOCK(zztasp3); zzMake0; { if ( (LA(1)==34) ) { zzmatch(34); zzCONSUME; } zzEXIT(zztasp3); } } [_retv setObject:zzaArg(zztasp2,3) forKey:zzaArg(zztasp2,1)]; zzLOOP(zztasp2); } zzEXIT(zztasp2); } } zzEXIT(zztasp1); return _retv; fail: zzEXIT(zztasp1); zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText); zzresynch(setwd1, 0x80); return _retv; } }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.