📄 main.c
字号:
/* S i m p l e I n t S t a c k */void#ifdef __STDC__pushint( int i )#elsepushint( i )int i;#endif{ require(isp>0, "pushint: stack overflow"); istack[--isp] = i;}int#ifdef __STDC__popint( void )#elsepopint( )#endif{ require(isp<MAX_INT_STACK, "popint: stack underflow"); return istack[isp++];}int#ifdef __STDC__istacksize( void )#elseistacksize( )#endif{ return MAX_INT_STACK-isp;}void#ifdef __STDC__istackreset( void )#elseistackreset( )#endif{ isp = MAX_INT_STACK;}int#ifdef __STDC__istackempty( void )#elseistackempty( )#endif{ return isp==MAX_INT_STACK;}int#ifdef __STDC__topint( void )#elsetopint( )#endif{ require(isp<MAX_INT_STACK, "topint: stack underflow"); return istack[isp];}void#ifdef __STDC__ProcessArgs( int argc, char **argv, Opt *options )#elseProcessArgs( argc, argv, options )int argc;char **argv;Opt *options;#endif{ Opt *p; require(argv!=NULL, "ProcessArgs: command line NULL"); while ( argc-- > 0 ) { p = options; while ( p->option != NULL ) { if ( strcmp(p->option, "*") == 0 || ci_strequ(p->option, *argv) == 1 ) { if ( p->arg ) {/* MR9 26-Sep-97 Check for argv valid */ if (argc-- > 0) { (*p->process)( *argv, *(argv+1) ); argv++; } else {fprintf(stderr,"error: required argument for option %s omitted\n",*argv);exit(PCCTS_EXIT_FAILURE); }; } else (*p->process)( *argv ); break; } p++; } argv++; }}static void CompleteContextGuards(){ ListNode * p; Predicate * pred; if (ContextGuardPredicateList == NULL) return; for (p=ContextGuardPredicateList->next; p != NULL; p=p->next) { pred=(Predicate *)p->elem; recomputeContextGuard(pred); }}/* Go back into the syntax diagram and compute all meta tokens; i.e. * turn all '.', ranges, token class refs etc... into actual token sets */static voidCompleteTokenSetRefs(){ ListNode *p; if ( MetaTokenNodes==NULL ) return; for (p = MetaTokenNodes->next; p!=NULL; p=p->next) { set a,b; TokNode *q = (TokNode *)p->elem; if ( q->wild_card ) { q->tset = all_tokens; } else if ( q->tclass!=NULL ) { if ( q->complement ) q->tset = set_dif(all_tokens, q->tclass->tset); else q->tset = q->tclass->tset; } else if ( q->upper_range!=0 ) { /* we have a range on our hands: make a set from q->token .. q->upper_range */ int i; a = empty; for (i=q->token; i<=q->upper_range; i++) { set_orel(i, &a); } /* MR13 *//* MR13 */ if (q->complement) {/* MR13 */ q->tset = set_dif(all_tokens, a);/* MR13 */ set_free(a);/* MR13 */ } else {/* MR13 */ q->tset = a;/* MR13 */ } } /* at this point, it can only be a complemented single token */ else if ( q->complement ) { a = set_of(q->token); b = set_dif(all_tokens, a); set_free(a); q->tset=b; } else fatal("invalid meta token"); }}/* MR10: Jeff Vincent MR10: Changed to remove directory information from n only if MR10: if OutputDirectory was changed by user (-o option)*/char *#ifdef __USE_PROTOSOutMetaName(char *n)#elseOutMetaName(n)char *n;#endif{ static char *dir_sym = DirectorySymbol; static char newname[MaxFileName+1]; char *p; /* If OutputDirectory is same as TopDirectory (platform default) then leave n alone. */ if (strcmp(OutputDirectory, TopDirectory) == 0) return n; /* p will point to filename without path information */ if ((p = strrchr(n, *dir_sym)) != NULL) p++; else p = n; /* Copy new output directory into newname[] */ strcpy(newname, OutputDirectory); /* if new output directory does not have trailing dir_sym, add it! */ if (newname[strlen(newname)-1] != *dir_sym) strcat(newname, dir_sym); /* contatenate FILE NAME ONLY to new output directory */ strcat(newname, p); return newname;}char *#ifdef __STDC__baseName(char *n)#elsebaseName(n)char *n;#endif{ static char newname[MaxFileName+1]; static char* dir_sym = DirectorySymbol; int count = 0; char *p; p = n; while ( *p != '\0' ) {p++;} /* go to end of string */ while ( (*p != *dir_sym) && (p != n) ) {--p;} /* Find last DirectorySymbol */ while ( *p == *dir_sym) p++; /* step forward if we're on a dir symbol */ while ( *p != '\0' && *p != '.') { newname[count++] = *p; p++; } /* create a new name */ newname[count] = '\0'; return newname;}static void#ifdef __STDC__ensure_no_C_file_collisions(char *class_c_file)#elseensure_no_C_file_collisions(class_c_file)char *class_c_file;#endif{ int i; for (i=0; i<NumFiles; i++) {#ifdef PC /* assume that file names are case insensitive */ if ( stricmp(outname(FileStr[i]), class_c_file)==0 )#else if ( strcmp(outname(FileStr[i]), class_c_file)==0 )#endif { fatal(eMsg1("class def output file conflicts with parser output file: %s", outname(FileStr[i]))); } }}void#ifdef __STDC__warnNoFL(char *err)#elsewarnNoFL(err)char *err;#endif{ fprintf(stderr, "warning: %s\n", err);}void#ifdef __STDC__warnFL(char *err,char *f,int l)#elsewarnFL(err,f,l)char *f;int l;char *err;#endif{ fprintf(stderr, ErrHdr, f, l); fprintf(stderr, " warning: %s\n", err);}void#ifdef __STDC__warn(char *err) #elsewarn(err) char *err;#endif{ /* back up the file number if we hit an error at the end of the last file */ if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--; fprintf(stderr, ErrHdr, FileStr[CurFile], zzline); fprintf(stderr, " warning: %s\n", err);}void#ifdef __STDC__warnNoCR( char *err )#elsewarnNoCR( err ) char *err;#endif{ /* back up the file number if we hit an error at the end of the last file */ if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--; fprintf(stderr, ErrHdr, FileStr[CurFile], zzline); fprintf(stderr, " warning: %s", err);}void#ifdef __STDC__errNoFL(char *err)#elseerrNoFL(err)char *err;#endif{ fprintf(stderr, "error: %s\n", err);}void#ifdef __STDC__errFL(char *err,char *f,int l)#elseerrFL(err,f,l)char *err;char *f;int l;#endif{ fprintf(stderr, ErrHdr, f, l); fprintf(stderr, " error: %s\n", err);}void#ifdef __STDC__err(char *err) #elseerr(err) char *err;#endif{ /* back up the file number if we hit an error at the end of the last file */ if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--; fprintf(stderr, ErrHdr, FileStr[CurFile], zzline); fprintf(stderr, " error: %s\n", err);}void#ifdef __STDC__errNoCR( char *err ) #elseerrNoCR( err ) char *err;#endif{ /* back up the file number if we hit an error at the end of the last file */ if ( CurFile >= NumFiles && CurFile >= 1 ) CurFile--; fprintf(stderr, ErrHdr, FileStr[CurFile], zzline); fprintf(stderr, " error: %s", err);}UserAction *#ifdef __STDC__newUserAction(char *s)#elsenewUserAction(s)char *s;#endif{ UserAction *ua = (UserAction *) calloc(1, sizeof(UserAction)); require(ua!=NULL, "cannot allocate UserAction"); ua->action = (char *) calloc(strlen(LATEXT(1))+1, sizeof(char)); strcpy(ua->action, s); return ua;}/* Added by TJP September 1994 *//* Take in file.h and return file_h; names w/o '.'s are left alone */char *#ifdef __USE_PROTOSgate_symbol(char *name)#elsegate_symbol(name)char *name;#endif{ static char buf[100]; char *p; sprintf(buf, "%s", name); for (p=buf; *p!='\0'; p++) { if ( *p=='.' ) *p = '_'; } return buf;}char *#ifdef __USE_PROTOSmakeAltID(int blockid, int altnum)#elsemakeAltID(blockid, altnum)int blockid;int altnum;#endif{ static char buf[100]; char *p; sprintf(buf, "_blk%d_alt%d", blockid, altnum); p = (char *)malloc(strlen(buf)+1); strcpy(p, buf); return p;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -