📄 sor.c
字号:
zzCONSUME;
{
zzBLOCK(zztasp4);
zzMake0;
{
if ( (LA(1)==84) ) {
zzmatch(84);
local_no_copy = 1;
zzCONSUME;
}
else {
if ( (setwd6[LA(1)]&0x80) ) {
}
else {zzFAIL(1,zzerr36,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp4);
}
}
zzastArg(1)->no_copy = no_copy || local_no_copy;
}
else {zzFAIL(1,zzerr37,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp3);
}
}
t->is_root = 1;
}
else {zzFAIL(2,zzerr38,zzerr39,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
zzMake0;
{
for (;;) {
if ( !((setwd7[LA(1)]&0x1)
)) break;
if ( (setwd7[LA(1)]&0x2) && (LA(2)==LABEL) ) {
labeled_element(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
}
else {
if ( (setwd7[LA(1)]&0x4) && (setwd7[LA(2)]&0x8) ) {
element(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
}
else {
if ( (LA(1)==BT) ) {
tree(zzSTR, no_copy ); zzlink(_root, &_sibling, &_tail);
}
else break; /* MR6 code for exiting loop "for sure" */
}
}
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
zzmatch(90); zzCONSUME;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
found_error=1;
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd7, 0x10);
}
}
void
#ifdef __USE_PROTOS
enum_file(AST**_root)
#else
enum_file(_root)
AST **_root;
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
SymEntry *p=NULL;
if ( (setwd7[LA(1)]&0x20) ) {
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==103)
) {
zzmatch(103); zzastDPush; zzCONSUME;
zzmatch(ID); zzastDPush; zzCONSUME;
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==106) ) {
zzmatch(106); zzastDPush; zzCONSUME;
zzmatch(ID); zzastDPush; zzCONSUME;
}
else {
if ( (LA(1)==110) ) {
}
else {zzFAIL(1,zzerr40,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp3);
}
}
}
else {
if ( (LA(1)==110) ) {
}
else {zzFAIL(1,zzerr41,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp2);
}
}
{
zzBLOCK(zztasp2);
int zzcnt=1;
zzMake0;
{
do {
_ast = NULL; enum_def(&_ast);
zzLOOP(zztasp2);
} while ( (LA(1)==110) );
zzEXIT(zztasp2);
}
}
}
else {
if ( (LA(1)==106)
) {
_ast = NULL; defines(&_ast);
}
else {
if ( (LA(1)==Eof) ) {
}
else {zzFAIL(1,zzerr42,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd7, 0x40);
}
}
void
#ifdef __USE_PROTOS
defines(AST**_root)
#else
defines(_root)
AST **_root;
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
int maxt= -1; /**** char *t; **** MR10 ****/ SymEntry *p; int ignore=0;
{
zzBLOCK(zztasp2);
int zzcnt=1;
zzMake0;
{
do {
zzmatch(106); zzastDPush; zzCONSUME;
zzmatch(ID); zzastDPush;
p = (SymEntry *) hash_get(symbols, zzaArg(zztasp2,2 ).text);
if ( p==NULL ) {
p = (SymEntry *) hash_add(symbols, zzaArg(zztasp2,2 ).text,
(Entry *) newSymEntry(zzaArg(zztasp2,2 ).text));
require(p!=NULL, "can't add to sym tab");
p->token = Token;
list_add(&token_list, (void *)p);
set_orel(p->token_type, &referenced_tokens);
}
else
{
err(eMsg1("redefinition of token %s; ignored",zzaArg(zztasp2,2 ).text));
ignore = 1;
}
zzCONSUME;
zzmatch(INT); zzastDPush;
if ( !ignore ) {
p->token_type = atoi(zzaArg(zztasp2,3 ).text);
token_association(p->token_type, p->str);
/* fprintf(stderr, "#token %s=%d\n", p->str, p->token_type);*/
if ( p->token_type>maxt ) maxt=p->token_type;
ignore = 0;
}
zzCONSUME;
zzLOOP(zztasp2);
} while ( (LA(1)==106) );
zzEXIT(zztasp2);
}
}
token_type = maxt + 1;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd7, 0x80);
}
}
void
#ifdef __USE_PROTOS
enum_def(AST**_root)
#else
enum_def(_root)
AST **_root;
#endif
{
zzRULE;
zzBLOCK(zztasp1);
zzMake0;
{
int maxt = -1, v= -1; /**** char *t; **** MR10 ****/ SymEntry *p; int ignore=0;
zzmatch(110); zzastDPush; zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==ID) ) {
zzmatch(ID); zzastDPush; zzCONSUME;
}
else {
if ( (LA(1)==111) ) {
}
else {zzFAIL(1,zzerr43,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp2);
}
}
zzmatch(111); zzastDPush; zzCONSUME;
zzmatch(ID); zzastDPush;
p = (SymEntry *) hash_get(symbols, zzaArg(zztasp1,4 ).text);
if ( p==NULL ) {
p = (SymEntry *) hash_add(symbols, zzaArg(zztasp1,4 ).text,
(Entry *) newSymEntry(zzaArg(zztasp1,4 ).text));
require(p!=NULL, "can't add to sym tab");
p->token = Token;
list_add(&token_list, (void *)p);
set_orel(p->token_type, &referenced_tokens);
}
else
{
err(eMsg1("redefinition of token %s; ignored",zzaArg(zztasp1,4 ).text));
ignore = 1;
}
zzCONSUME;
{
zzBLOCK(zztasp2);
zzMake0;
{
if ( (LA(1)==112)
) {
zzmatch(112); zzastDPush; zzCONSUME;
zzmatch(INT); zzastDPush;
v=atoi(zzaArg(zztasp2,2 ).text);
zzCONSUME;
}
else {
if ( (setwd8[LA(1)]&0x1) ) {
v++;
}
else {zzFAIL(1,zzerr44,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp2);
}
}
if ( !ignore ) {
/* fprintf(stderr, "#token %s=%d\n", p->str, v);*/
if ( v>maxt ) maxt=v;
p->token_type = v;
token_association(p->token_type, p->str);
ignore = 0;
}
{
zzBLOCK(zztasp2);
zzMake0;
{
while ( (LA(1)==113) ) {
zzmatch(113); zzastDPush; zzCONSUME;
{
zzBLOCK(zztasp3);
zzMake0;
{
if ( (LA(1)==114) ) {
zzmatch(114); zzastDPush; zzCONSUME;
{
zzBLOCK(zztasp4);
zzMake0;
{
if ( (LA(1)==112) ) {
zzmatch(112); zzastDPush; zzCONSUME;
zzmatch(INT); zzastDPush; zzCONSUME;
}
else {
if ( (setwd8[LA(1)]&0x2)
) {
}
else {zzFAIL(1,zzerr45,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp4);
}
}
}
else {
if ( (LA(1)==115) ) {
zzmatch(115); zzastDPush; zzCONSUME;
{
zzBLOCK(zztasp4);
zzMake0;
{
if ( (LA(1)==112) ) {
zzmatch(112); zzastDPush; zzCONSUME;
zzmatch(INT); zzastDPush; zzCONSUME;
}
else {
if ( (setwd8[LA(1)]&0x4) ) {
}
else {zzFAIL(1,zzerr46,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp4);
}
}
}
else {
if ( (LA(1)==ID) ) {
zzmatch(ID); zzastDPush;
p = (SymEntry *) hash_get(symbols, zzaArg(zztasp3,1 ).text);
if ( p==NULL ) {
p = (SymEntry *) hash_add(symbols, zzaArg(zztasp3,1 ).text,
(Entry *) newSymEntry(zzaArg(zztasp3,1 ).text));
require(p!=NULL, "can't add to sym tab");
p->token = Token;
list_add(&token_list, (void *)p);
set_orel(p->token_type, &referenced_tokens);
}
else
{
err(eMsg1("redefinition of token %s; ignored",zzaArg(zztasp3,1 ).text));
ignore = 1;
}
zzCONSUME;
{
zzBLOCK(zztasp4);
zzMake0;
{
if ( (LA(1)==112)
) {
zzmatch(112); zzastDPush; zzCONSUME;
zzmatch(INT); zzastDPush;
v=atoi(zzaArg(zztasp4,2 ).text);
zzCONSUME;
}
else {
if ( (setwd8[LA(1)]&0x8) ) {
v++;
}
else {zzFAIL(1,zzerr47,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
zzEXIT(zztasp4);
}
}
if ( !ignore ) {
/* fprintf(stderr, "#token %s=%d\n", p->str, v);*/
if ( v>maxt ) maxt=v;
p->token_type = v;
token_association(p->token_type, p->str);
ignore = 0;
}
}
else {
if ( (setwd8[LA(1)]&0x10) ) {
}
else {zzFAIL(1,zzerr48,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText,&zzErrk); goto fail;}
}
}
}
zzEXIT(zztasp3);
}
}
zzLOOP(zztasp2);
}
zzEXIT(zztasp2);
}
}
zzmatch(116); zzastDPush; zzCONSUME;
zzmatch(117); zzastDPush;
token_type = maxt + 1;
zzCONSUME;
zzEXIT(zztasp1);
return;
fail:
zzEXIT(zztasp1);
zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
zzresynch(setwd8, 0x20);
}
}
/* SORCERER-specific syntax error message generator
* (define USER_ZZSYN when compiling so don't get 2 definitions)
*/
void
#ifdef __USE_PROTOS
zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
#else
zzsyn(text, tok, egroup, eset, etok, k, bad_text)
char *text, *egroup, *bad_text;
int tok;
int etok;
int k;
SetWordType *eset;
#endif
{
fprintf(stderr, ErrHdr, FileStr[CurFile]!=NULL?FileStr[CurFile]:"stdin", zzline);
fprintf(stderr, " syntax error at \"%s\"", (tok==zzEOF_TOKEN)?"EOF":text);
if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
if ( k==1 ) fprintf(stderr, " missing");
else
{
fprintf(stderr, "; \"%s\" not", bad_text);
if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
}
if ( zzset_deg(eset)>0 ) zzedecode(eset);
else fprintf(stderr, " %s", zztokens[etok]);
if ( strlen(egroup) > (size_t)0 ) fprintf(stderr, " in %s", egroup);
fprintf(stderr, "\n");
}
SymEntry *
#ifdef __USE_PROTOS
define_token(char *text)
#else
define_token(text)
char *text;
#endif
{
SymEntry *p;
p = (SymEntry *) hash_get(symbols, text);
if ( p==NULL ) {
if ( UserDefdTokens ) {
err(eMsg1("implicit token definition of '%s' not allowed with #tokdefs",text));
}
p = (SymEntry *) hash_add(symbols, text, (Entry *) newSymEntry(text));
p->token = Token;
p->token_type = token_type++;
token_association(p->token_type, p->str);
list_add(&token_list, (void *)p);
set_orel(p->token_type, &referenced_tokens);
}
else {
if ( p->token!=Token )
err(eMsg2("token definition clashes with %s definition: '%s'", zztokens[p->token], text));
}
return p;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -