yylex(){ int nstr; extern int yyprevious; while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: {BEGIN VER;} break; case 2: {} break; case 3: {} break; case 4: {process_branch(yytext);} break; case 5: {} break; case 6: {BEGIN 0;} break; case 7: {printf("<%c>", yytext[0]);} break; case -1: break; default: fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
/* YYLEX -- Return the next token from the input stream. Two separate lexical * analyzers are provided, the "command mode" lexical analyzer for interactive * command entry, and the "compute mode" analyzer for more sophisticated * applications. The nesting level of parentheses and braces is used to switch * between the two modes. When the paren level is nonzero compute mode is in * effect. Mode switching may be defeated by setting the external variable * _lexmodes to zero. A single parser accepts input from both lexical * analyzers. */ int yylex (void) { register int token; if (_lexmodes && parenlevel == 0 && bracelevel < PBRACE) { while (!(token = lexicon())) if (yywrap()) break; } else token = lex_yylex(); if (!lexdebug) return (token); #if LEXDEBUG switch (token) { case Y_CONSTANT: eprintf ("CONSTANT "); fprop (stderr, reference (operand, yylval)); eprintf ("\n"); break; case Y_IDENT: eprintf ("IDENT "); fprop (stderr, reference (operand, yylval)); eprintf ("\n"); break; case Y_OSESC: eprintf ("Y_OSESC "); fprop (stderr, reference (operand, yylval)); eprintf ("\n"); break; case Y_APPEND: eprintf ("Y_APPEND\n"); break; case Y_ALLAPPEND: eprintf ("Y_ALLAPPEND\n"); break; case Y_ALLREDIR: eprintf ("Y_ALLREDIR\n"); break; case Y_GSREDIR: eprintf ("Y_GSREDIR\n"); break; case Y_ALLPIPE: eprintf ("Y_ALLPIPE\n"); break; case Y_NEWLINE: eprintf ("NEWLINE\n"); break; default: eprintf ("`%c'\n", token); break; } #endif return (token); }
static int input() { int c; unsigned char *yy_cp = yy_c_buf_p; *yy_cp = yy_hold_char; if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* need more input */ yytext = yy_c_buf_p; ++yy_c_buf_p; switch ( yy_get_next_buffer() ) { /* this code, unfortunately, is somewhat redundant with * that above */ case EOB_ACT_END_OF_FILE: { if ( yywrap() ) { yy_c_buf_p = yytext; return ( EOF ); } yy_ch_buf[0] = '\n'; yy_n_chars = 1; yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; yy_eof_has_been_seen = 0; yytext = yy_c_buf_p = &yy_ch_buf[1]; yy_hold_char = *yy_c_buf_p; return ( input() ); } break; case EOB_ACT_RESTART_SCAN: yy_c_buf_p = yytext; break; case EOB_ACT_LAST_MATCH: YY_FATAL_ERROR( "unexpected last match in input()" ); } } c = *yy_c_buf_p; yy_hold_char = *++yy_c_buf_p; return ( c ); }
static int input(void) { int c; YY_DO_BEFORE_SCAN if (yy_c_buf_p == yy_e_buf_p) { int yy_n_chars; if (yy_saw_eof) { if (yywrap()) return (EOF); YY_INIT; } yy_b_buf_p = 0; YY_INPUT(yy_ch_buf, yy_n_chars, YY_MAX_LINE); if (yy_n_chars == YY_NULL) { yy_saw_eof = 1; if (yywrap()) return (EOF); YY_INIT; return (input()); } yy_c_buf_p = -1; yy_e_buf_p = yy_n_chars - 1; } c = yy_ch_buf[++yy_c_buf_p]; YY_DO_BEFORE_ACTION; return (c); }
int main(int argc, char *argv[]) { int t; if(argc >= 2) { yyin = fopen(argv[1],"r"); if (yyin == NULL) { printf("can't open/read '%s'\n", argv[1]); exit(-1); } } yywrap(); //not for use until hw 2 while ((t=yylex()) != -1) { printf("token %d code %d line %d text %s\n", yyntokens, t, yytokens[yyntokens-1].linenumber, yytokens[yyntokens-1].text); } return 0; }
void yyinit( void ) { char *name, *value, *map_path; /* zero the line counter */ yylineno = 0; if( rulemap_path == NULL ) { NMloc( FILES, FILENAME, ERx( "default.rfm" ), &loc ); LOcopy( &loc, file_name, &loc ); LOtos( &loc, &map_path ); } else { STcopy( rulemap_path, file_name ); LOfroms( FILENAME, file_name, &loc ); map_path = rulemap_path; } (void) PMmInit( &rulemap ); if( PMmLoad( rulemap, &loc, PMerror ) != OK ) PCexit( FAIL ); /* initiate scan of rule map */ if( PMmScan( rulemap, ERx( ".*" ), &rfm_scan, NULL, &name, &value ) != OK ) { F_ERROR( "Rule file map %s is empty.", map_path ); } /* set up LOCATION of first rule file */ STcopy( value, file_name ); NMloc( FILES, FILENAME, file_name, &loc ); LOcopy( &loc, file_name, &loc ); /* initialize input pointer */ yyp = &dummy; /* open rule file */ if( SIfopen( &loc, ERx( "r" ), SI_TXT, SI_MAX_TXT_REC, &yyin ) != OK && yywrap() ) { ERROR( "No configuration rule files were found." ); } }
yylex() { int nstr; extern int yyprevious; #ifdef YYDEBUG fprintf(yyout,"yylex()\n"); #endif while((nstr = yylook()) >= 0) { #ifdef YYDEBUG fprintf(yyout,"yylex: nstr=%d\n",nstr); #endif yyfussy: switch(nstr) { case 0: if(yywrap()) return(0); break; case 1: return ID; break; case 2: return CON; break; case 3: ; break; case 4: return yytext[0]; break; case -1: break; default: fprintf(yyout,"yylex: bad switch yylook %d\n",nstr); } } #ifdef YYDEBUG fprintf(yyout,"yylex: return 0\n"); #endif return(0); }
void init(int argc,char** argv) { time_t ti; time(&ti); srand(ti); fnit(); rules= alloc_options(argc,argv,"-r"); variables= alloc_options(argc,argv,"-v"); frames= alloc_options(argc,argv,"-f"); yywrap(); varwrap(); varparse(); qTranslationIinitiateVariables(0); qNexus_createNameNexuses(); registerDefaultRules(); qContentFilter_init(); yyparse(); netStruct_init(); }
int d() { b(); c(); #ifdef WITH_PTHREAD pthread_t self = pthread_self(); return static_cast<int>(self); #elif defined(WITH_LEX_YACC) yywrap(); yyerror("no error"); return 0; #elif defined(WITH_SETUPAPI) CABINET_INFO ci; ci.SetId = 0; return ci.SetId; #else return 0; #endif }
yylex(){ int nstr; extern int yyprevious; #ifdef __cplusplus /* to avoid CC and lint complaining yyfussy not being used ...*/ static int __lex_hack = 0; if (__lex_hack) goto yyfussy; #endif while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: # line 10 "scan.l" { printf("I found a stego!\n"); return("stego"); } break; case 2: # line 11 "scan.l" { printf("this is gay!\n"); return(0); } break; case 3: # line 12 "scan.l" { printf("this is asinine\n"); return("asinine"); } break; case 4: # line 13 "scan.l" { return(yytext);} break; case 5: # line 14 "scan.l" { /* ignore bad characters */ } break; case -1: break; default: (void)fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
yylex(){ int nstr; extern int yyprevious; while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: return ID; break; case 2: return CON; break; case 3: ; break; case 4: return yytext[0]; break; case -1: break; default: fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
void init(int argc,char** argv) { printf("Init...\n"); time_t ti; time(&ti); srand(ti); fnit(); rules= alloc_options(argc,argv,"-r"); variables= alloc_options(argc,argv,"-v"); frames= alloc_options(argc,argv,"-f"); yywrap(); varwrap(); varparse(); printf("create %d variables \n",varsParsed); qTranslationIinitiateVariables(); qNexus_createNameNexuses(); registerDefaultRules(); qContentFilter_init(); printf("created nexi\n"); yyparse(); printf("parsed %d rules \n",rulesParsed); netStruct_init(); }
yylex(){ int nstr; extern int yyprevious; seek(); while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: { /* Integer */ yylval.numtok.value = atol (yytext); // sscanf (yytext, "%d", &yylval.numtok.value); yylval.numtok.numline = yylineno; return (NUMBER); } break; case 2: case 3: case 4: { /* Real Number */ yylval.realtok.value = atof (yytext); // sscanf (yytext, "%f", &yylval.realtok.value); yylval.realtok.numline = yylineno; return (REAL_NUMBER); } break; case 5: case 6: { /* String */ register unsigned char scope_char = *yytext; register char *cptr; strncpy (yylval.strtok.str, yytext+1, MAXSTRING); if ((cptr = strchr (yylval.strtok.str, scope_char)) != NULL) *cptr = '\0'; yylval.strtok.strline = yylineno; return (STRING); } break; case 7: { /* Identifier, Keyword etc. */ register int i; strncpy (yylval.strtok.str, yytext, NAMELEN); /* ist ID ein reserviertes Wort ? */ for (i = 0; keywords[i].lx ; i++) { if (!strcmp (keywords[i].id, yylval.strtok.str)) break; } if (keywords[i].lx) { /* ID ist Schluesselwort */ yylval.strtok.strline = yylineno; return (keywords[i].lx); } /* ist ID eine Systemvariable ? */ for (i = 0; system_var[i].var_name; ++i) { if (!strcmp (system_var[i].var_name, yylval.strtok.str)) break; } if (system_var[i].var_name) { /* ID ist Systemvar */ yylval.numtok.value = system_var[i].var_wert; yylval.numtok.index = i; yylval.numtok.numline = yylineno; return (SYSTEM_VAR); } /* ist ID Systemkonstante ? */ for (i = 0; system_const[i].const_name; ++i) { if (!strcmp (system_const[i].const_name, yylval.strtok.str)) break; } if (system_const[i].const_name) { /* ID ist Sys.const */ yylval.numtok.value = (*system_const[i].const_wert)(); yylval.numtok.index = i; yylval.numtok.numline = yylineno; return (SYSTEM_CONST); } else { /* Ansonsten ist ID nutzerdefinierter Name */ yylval.strtok.strline = yylineno; return (IDENT); } } break; case 8: { /* Neue Zeilennummer (Zeile ignorieren) */ register int n = 0; register int ch; while ((ch = input ()) == ' ') ; if (isdigit(ch)) { n = 0; while (isdigit(ch)) { n= 10*n + ch - '0'; ch = input (); } yylineno = n - 1; } while ((ch = input ()) != '\n') ; } break; case 9: return (OROR); break; case 10: return (ANDAND); break; case 11: return (NE); break; case 12: return (LE); break; case 13: return (GE); break; case 14: return (EQ); break; case 15: return (LT); break; case 16: return (GT); break; case 17: return (UNOT); break; case 18: return (EQU); break; case 19: comment ("*/"); break; case 20: comment ("\n"); break; case 21: ; break; case 22: return (*yytext); break; case -1: break; default: r_abort("bad switch yylook"); } return(0); }
int yylex(){ int nstr; extern int yyprevious; #ifdef __cplusplus /* to avoid CC and lint complaining yyfussy not being used ...*/ static int __lex_hack = 0; if (__lex_hack) goto yyfussy; #endif while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: # line 102 "lexer.l" { /* ignore comment */; } break; case 2: # line 104 "lexer.l" { /* ignore whitespace*/; } break; case 3: # line 106 "lexer.l" { lineno++; return T_newline; } break; case 4: # line 108 "lexer.l" { announce("<T_from>\n"); return T_from; } break; case 5: # line 110 "lexer.l" { announce("<T_into>\n"); return T_into; } break; case 6: # line 112 "lexer.l" { announce("<T_pipe>\n"); return T_pipe; } break; case 7: # line 114 "lexer.l" { int token,ok; ok=matchquotes(yytext); yylval.v.string=cleancpystring(yytext); if ( ok ) { announce1("<T_string(%s)>\n",yylval.v.string); token=T_string; } else { announce1("<T_badstring(%s)>\n",yylval.v.string); fprintf(stderr,"Unterminated string, line %d.\n", lineno); token=T_badstring; } lineno += countlines(yylval.v.string); return token; } break; case -1: break; default: (void)fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
ULONG yylex(void) { ULONG hash, maxlen; char *s; struct sLexString *pLongestFixed = NULL; ULONG nFloatMask, nOldFloatMask, nFloatLen; ULONG linestart = AtLineStart; switch (lexerstate) { case LEX_STATE_NORMAL: AtLineStart = 0; scanagain: while (*pLexBuffer == ' ' || *pLexBuffer == '\t') { linestart = 0; pLexBuffer += 1; } if (*pLexBuffer == 0) { if (yywrap() == 0) { linestart = AtLineStart; AtLineStart = 0; goto scanagain; } } s = pLexBuffer; nOldFloatMask = nFloatLen = 0; nFloatMask = tFloatingFirstChar[(int) *s++]; while (nFloatMask && nFloatLen < nLexBufferLeng) { nFloatLen += 1; nOldFloatMask = nFloatMask; if (nFloatLen == 1) nFloatMask &= tFloatingSecondChar[(int) *s++]; else nFloatMask &= tFloatingChars[(int) *s++]; } maxlen = nLexBufferLeng; if (nLexMaxLeng < maxlen) maxlen = nLexMaxLeng; yyleng = 0; hash = 0; s = pLexBuffer; while (yyleng < nLexMaxLeng) { yyleng += 1; hash = ((hash << 1) + (toupper(*s))) % LEXHASHSIZE; s += 1; if (tLexHash[hash]) { struct sLexString *lex; lex = tLexHash[hash]; while (lex) { if (lex->nNameLength == yyleng) { if (strnicmp (pLexBuffer, lex->tzName, yyleng) == 0) { pLongestFixed = lex; } } lex = lex->pNext; } } } if (nFloatLen == 0 && pLongestFixed == NULL) { if (*pLexBuffer == '"') { ULONG index = 0; pLexBuffer += 1; while ((*pLexBuffer != '"') && (*pLexBuffer != '\n')) { char ch, *marg; if ((ch = *pLexBuffer++) == '\\') { switch (ch = (*pLexBuffer++)) { case 'n': ch = '\n'; break; case 't': ch = '\t'; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if ((marg = sym_FindMacroArg(ch - '0')) != NULL) { while (*marg) yylval. tzString [index++] = *marg++; ch = 0; } break; case '@': if ((marg = sym_FindMacroArg (-1)) != NULL) { while (*marg) yylval. tzString [index++] = *marg++; ch = 0; } break; } } else if (ch == '{') { char sym[MAXSYMLEN]; int i = 0; while ((*pLexBuffer != '}') && (*pLexBuffer != '"') && (*pLexBuffer != '\n')) { if ((ch = *pLexBuffer++) == '\\') { switch (ch = (*pLexBuffer++)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if ((marg = sym_FindMacroArg(ch - '0')) != NULL) { while (*marg) sym[i++] = *marg++; ch = 0; } break; case '@': if ((marg = sym_FindMacroArg(-1)) != NULL) { while (*marg) sym[i++] = *marg++; ch = 0; } break; } } else sym[i++] = ch; } sym[i] = 0; index += symvaluetostring(&yylval. tzString [index], sym); if (*pLexBuffer == '}') pLexBuffer += 1; else yyerror("Missing }"); ch = 0; } if (ch) yylval.tzString[index++] = ch; } yylval.tzString[index++] = 0; if (*pLexBuffer == '\n') yyerror("Unterminated string"); else pLexBuffer += 1; return (T_STRING); } else if (*pLexBuffer == '{') { char sym[MAXSYMLEN], ch, *marg; int i = 0; pLexBuffer += 1; while ((*pLexBuffer != '}') && (*pLexBuffer != '\n')) { if ((ch = *pLexBuffer++) == '\\') { switch (ch = (*pLexBuffer++)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if ((marg = sym_FindMacroArg(ch - '0')) != NULL) { while (*marg) sym[i++] = *marg++; ch = 0; } break; case '@': if ((marg = sym_FindMacroArg (-1)) != NULL) { while (*marg) sym[i++] = *marg++; ch = 0; } break; } } else sym[i++] = ch; } sym[i] = 0; symvaluetostring(yylval.tzString, sym); if (*pLexBuffer == '}') pLexBuffer += 1; else yyerror("Missing }"); return (T_STRING); } else { if (*pLexBuffer == '\n') AtLineStart = 1; yyleng = 1; return (*pLexBuffer++); } } if (nFloatLen == 0) { yyleng = pLongestFixed->nNameLength; pLexBuffer += yyleng; return (pLongestFixed->nToken); } if (pLongestFixed == NULL) { struct sLexFloat *tok; tok = lexgetfloat(nOldFloatMask); yyleng = nFloatLen; if (tok->Callback) { if (tok->Callback(pLexBuffer, yyleng) == 0) goto scanagain; } if (tok->nToken == T_ID && linestart) { pLexBuffer += yyleng; return (T_LABEL); } else { pLexBuffer += yyleng; return (tok->nToken); } } if (nFloatLen > pLongestFixed->nNameLength) { struct sLexFloat *tok; tok = lexgetfloat(nOldFloatMask); yyleng = nFloatLen; if (tok->Callback) { if (tok->Callback(pLexBuffer, yyleng) == 0) goto scanagain; } if (tok->nToken == T_ID && linestart) { pLexBuffer += yyleng; return (T_LABEL); } else { pLexBuffer += yyleng; return (tok->nToken); } } else { yyleng = pLongestFixed->nNameLength; pLexBuffer += yyleng; return (pLongestFixed->nToken); } break; case LEX_STATE_MACROARGS: { ULONG index = 0; while (*pLexBuffer == ' ' || *pLexBuffer == '\t') { linestart = 0; pLexBuffer += 1; } while ((*pLexBuffer != ',') && (*pLexBuffer != '\n')) { char ch, *marg; if ((ch = *pLexBuffer++) == '\\') { switch (ch = (*pLexBuffer++)) { case 'n': ch = '\n'; break; case 't': ch = '\t'; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if ((marg = sym_FindMacroArg(ch - '0')) != NULL) { while (*marg) yylval. tzString [index++] = *marg++; ch = 0; } break; case '@': if ((marg = sym_FindMacroArg(-1)) != NULL) { while (*marg) yylval. tzString [index++] = *marg++; ch = 0; } break; } } else if (ch == '{') { char sym[MAXSYMLEN]; int i = 0; while ((*pLexBuffer != '}') && (*pLexBuffer != '"') && (*pLexBuffer != '\n')) { if ((ch = *pLexBuffer++) == '\\') { switch (ch = (*pLexBuffer++)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if ((marg = sym_FindMacroArg (ch - '0')) != NULL) { while (*marg) sym[i++] = *marg++; ch = 0; } break; case '@': if ((marg = sym_FindMacroArg (-1)) != NULL) { while (*marg) sym[i++] = *marg++; ch = 0; } break; } } else sym[i++] = ch; } sym[i] = 0; index += symvaluetostring(&yylval. tzString[index], sym); if (*pLexBuffer == '}') pLexBuffer += 1; else yyerror("Missing }"); ch = 0; } if (ch) yylval.tzString[index++] = ch; } if (index) { yyleng = index; yylval.tzString[index] = 0; if (*pLexBuffer == '\n') { while (yylval.tzString[--index] == ' ') { yylval.tzString[index] = 0; yyleng -= 1; } } return (T_STRING); } else if (*pLexBuffer == '\n') { pLexBuffer += 1; AtLineStart = 1; yyleng = 1; return ('\n'); } else if (*pLexBuffer == ',') { pLexBuffer += 1; yyleng = 1; return (','); } else { yyerror("INTERNAL ERROR IN YYLEX"); return (0); } } break; } yyerror("INTERNAL ERROR IN YYLEX"); return (0); }
yylex(){ int nstr; extern int yyprevious; #ifdef __cplusplus /* to avoid CC and lint complaining yyfussy not being used ...*/ static int __lex_hack = 0; if (__lex_hack) goto yyfussy; #endif while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: # line 35 "stab.l" MYECHO; break; case 2: # line 36 "stab.l" MYECHO; break; case 3: # line 37 "stab.l" { MYECHO; YYDUMP(); strcpy(yylval.string, yytext); if (strlen(yytext) == 1) return(*yytext); else return(NAME); } break; case 4: # line 46 "stab.l" GETTOKEN(STRING); break; case 5: # line 47 "stab.l" GETTOKEN(REAL); break; case 6: # line 48 "stab.l" GETTOKEN(INTEGER); break; case 7: # line 49 "stab.l" GETTOKEN(HEXADECIMAL); break; case 8: # line 50 "stab.l" { MYECHO; YYDUMP(); strcpy(yylval.string, yytext); return(*yytext); } break; case -1: break; default: (void)fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
yylex(){ int nstr; extern int yyprevious; while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: {eot(); return(PLUS);} break; case 2: {eot(); return(MINUS);} break; case 3: {eot(); return(ASTERISK);} break; case 4: {eot(); return(SLASH);} break; case 5: {eot(); return(ASSIGN);} break; case 6: {eot(); return(AMPERSAND);} break; case 7: {eot(); return(DOT);} break; case 8: {eot(); return(COMMA);} break; case 9: {eot(); return(SEMICOLON);} break; case 10: {eot(); return(LPAREN);} break; case 11: {eot(); return(LBRACKET);} break; case 12: {eot(); return(LBRACE);} break; case 13: {eot(); return(UPARROW);} break; case 14: {eot(); return(EQUAL);} break; case 15: {eot(); return(RARROW);} break; case 16: {eot(); return(SHARP);} break; case 17: {eot(); return(LESS);} break; case 18: {eot(); return(GREATER);} break; case 19: {eot(); return(LSEQUAL);} break; case 20: {eot(); return(SUBTYPE);} break; case 21: {eot(); return(GREQUAL);} break; case 22: {eot(); return(DOTDOT);} break; case 23: {eot(); return(COLON);} break; case 24: {eot(); return(RPAREN);} break; case 25: {eot(); return(RBRACKET);} break; case 26: {eot(); return(RBRACE);} break; case 27: {eot(); return(BAR);} break; case 28: {PTRKEYWORDENTRY tempp; eot(); if ((tempp=lookup(yytext))!=NULL){ return(tempp->lexval);} else { strcpy(lastident, yytext); return(IDENT); } } break; case 29: {eot(); return(CARD_CONST);} break; case 30: {eot(); return(REAL_CONST);} break; case 31: { eot(); return(STR_CONST);} break; case 32: { eot(); return(STR_CONST);} break; case 33: {eot(); eol();} break; case 34: {eot(); } break; case 35: /* other spaces */ /* putchar(' ')*/ eot(); break; case 36: {eot(); BEGIN Com; comdepth=1; } break; case 37: {eot(); comdepth++; } break; case 38: {eot(); comdepth--; if (comdepth==0) BEGIN Prog; } break; case 39: {eot(); BEGIN Prag; pragdepth=1; } break; case 40: {eot(); pragdepth++; } break; case 41: {eot(); pragdepth--; if (pragdepth==0) BEGIN Prog; } break; case 42: {eot(); eol();} break; case 43: {eot(); eol();} break; case 44: {eot();} break; case 45: {eot();} break; case 46: {yyless(0); BEGIN Prog;} break; case -1: break; default: fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
yylex(){ int nstr; extern int yyprevious; #ifdef __cplusplus /* to avoid CC and lint complaining yyfussy not being used ...*/ static int __lex_hack = 0; if (__lex_hack) goto yyfussy; #endif while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: # line 46 "otyscan.l" ; break; case 2: # line 47 "otyscan.l" GETTOKEN(NEWLINE); break; case 3: # line 48 "otyscan.l" GETTOKEN(MSGID); break; case 4: # line 49 "otyscan.l" GETTOKEN(TIME); break; case 5: # line 50 "otyscan.l" GETTOKEN(CLASS); break; case 6: # line 51 "otyscan.l" GETTOKEN(ACTION); break; case 7: # line 52 "otyscan.l" GETTOKEN(OUTPRIOR); break; case 8: # line 53 "otyscan.l" GETTOKEN(FREQ); break; case 9: # line 54 "otyscan.l" GETTOKEN(PROTOTYPE); break; case 10: # line 55 "otyscan.l" GETTOKEN(FIELD); break; case 11: # line 56 "otyscan.l" GETTOKEN(FIELDUP); break; case 12: # line 57 "otyscan.l" GETTOKEN(NPVAL); break; case 13: # line 58 "otyscan.l" GETTOKEN(WIDTH); break; case 14: # line 59 "otyscan.l" GETTOKEN(ENUM); break; case 15: # line 60 "otyscan.l" GETTOKEN(OUTPUT); break; case 16: # line 61 "otyscan.l" { YYDUMP(); VERBOSE(stdout, "otyscan: %s", yytext+strlen("otypp: ")); } break; case 17: # line 65 "otyscan.l" GETTOKEN(LEFTBRACE); break; case 18: # line 66 "otyscan.l" GETTOKEN(RIGHTBRACE); break; case -1: break; default: (void)fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
static int input (void) #endif { int c; *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ *(yy_c_buf_p) = '\0'; else { /* need more input */ int offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart(yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) return EOF; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); return c; }
yylex(){ int nstr; extern int yyprevious; while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: { } break; case 2: { yylval.typed.ru.charptr = reader_get_symbol_with_quotes(yytext); return SYMBOL; } break; case 3: { yylval.typed.ru.integer = 0; return OPEN_PAREN; } break; case 4: { yylval.typed.ru.integer = 0; return CLOSE_PAREN; } break; case 5: { yylval.typed.ru.integer = 0; return OPEN_SQUARE; } break; case 6: { yylval.typed.ru.integer = 0; return CLOSE_SQUARE; } break; case 7: { yylval.typed.ru.integer = 0; return OPEN_BRACE; } break; case 8: { yylval.typed.ru.integer = 0; return CLOSE_BRACE; } break; case 9: { yylval.typed.ru.real = atof(yytext); return FLOAT; } break; case 10: { sscanf(yytext+2,"%x",&(yylval.typed.ru.integer)); return INTEGER; } break; case 11: { sscanf(yytext+2,"%o",&(yylval.typed.ru.integer)); return INTEGER; } break; case 12: { sscanf(yytext,"%d",&(yylval.typed.ru.integer)); return INTEGER; } break; case 13: { yylval.typed.ru.integer = yytext[0]; return MULOP; } break; case 14: { yylval.typed.ru.integer = yytext[0]; return ADDOP; } break; case 15: { yylval.typed.ru.integer = yytext[0]; return SHIFTOP; } break; case 16: { yylval.typed.ru.integer = (yytext[0] == '='); return EQOP; } break; case 17: { yylval.typed.ru.integer = (yytext[1] == '='); return LTOP; } break; case 18: { yylval.typed.ru.integer = (yytext[1] == '='); return GTOP; } break; case 19: { yylval.typed.ru.integer = yytext[0]; return BITAOP; } break; case 20: { yylval.typed.ru.integer = yytext[0]; return BITXOP; } break; case 21: { yylval.typed.ru.integer = yytext[0]; return BITIOP; } break; case 22: { yylval.typed.ru.integer = yytext[0]; return ANDOP; } break; case 23: { yylval.typed.ru.integer = yytext[0]; return OROP; } break; case 24: { yylval.typed.ru.integer = yytext[0]; return NOTOP; } break; case 25: { yylval.typed.ru.integer = yytext[0]; return QUESTOP; } break; case 26: { yylval.typed.ru.integer = yytext[0]; return COLONOP; } break; case 27: { yylval.typed.ru.integer = 1; return INTEGER; } break; case 28: { yylval.typed.ru.integer = 0; return INTEGER; } break; case 29: { yylval.typed.ru.charptr = reader_get_symbol(yytext); if (reader_get_symbol_value(yylval.typed.ru.charptr)) return MACRO_SYMBOL; else return SYMBOL; } break; case 30: ; break; case 31: { reader_lex_line_count++; } break; case 32: { if (!reader_dot_warning_given) { yyerror("Warning: . encountered (ignored)"); reader_dot_warning_given = 1; } } break; case 33: { printf("Lex error on line %d. ??? %s ???\n", reader_lex_line_count, yytext); exit(1); } break; case -1: break; default: fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
yylex(){ int nstr; extern int yyprevious; #ifdef __cplusplus /* to avoid CC and lint complaining yyfussy not being used ...*/ static int __lex_hack = 0; if (__lex_hack) goto yyfussy; #endif while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: # line 10 "parse.lex" return (INCLUDE); break; case 2: # line 11 "parse.lex" return (INPUT); break; case 3: # line 12 "parse.lex" return (CLEAR); break; case 4: # line 13 "parse.lex" return (LAYOUT); break; case 5: # line 14 "parse.lex" return (MENU); break; case 6: # line 15 "parse.lex" return (KEYBOARD); break; case 7: # line 16 "parse.lex" return (TRANSLATION); break; case 8: # line 17 "parse.lex" return (FUNCTION); break; case 9: # line 18 "parse.lex" return (VARIABLE); break; case 10: # line 19 "parse.lex" return (IF); break; case 11: # line 20 "parse.lex" return (ELSEIF); break; case 12: # line 21 "parse.lex" return (ELSE); break; case 13: # line 22 "parse.lex" return (FI); break; case 14: # line 23 "parse.lex" return (DO); break; case 15: # line 24 "parse.lex" return (ELSEDO); break; case 16: # line 25 "parse.lex" return (OD); break; case 17: # line 26 "parse.lex" return (OPTIONS); break; case 18: # line 27 "parse.lex" return (PIN); break; case 19: # line 28 "parse.lex" return (LEFTRIGHT); break; case 20: # line 29 "parse.lex" return (RIGHTLEFT); break; case 21: # line 30 "parse.lex" return (SEPARATOR); break; case 22: # line 31 "parse.lex" return (TITLE); break; case 23: # line 32 "parse.lex" return (DEFAULT); break; case 24: # line 33 "parse.lex" return (BUTTON); break; case 25: # line 34 "parse.lex" return (IMAGE); break; case 26: # line 35 "parse.lex" return (SCROLLBAR); break; case 27: # line 36 "parse.lex" return (LEFT); break; case 28: # line 37 "parse.lex" return (RIGHT); break; case 29: # line 38 "parse.lex" return (BOTTOM); break; case 30: # line 39 "parse.lex" return (TOP); break; case 31: # line 40 "parse.lex" return (GEOMETRY); break; case 32: # line 41 "parse.lex" return (TYPE); break; case 33: # line 42 "parse.lex" return (EDIT); break; case 34: # line 43 "parse.lex" return (COMMENT); break; case 35: # line 44 "parse.lex" return (PROGRAM); break; case 36: # line 45 "parse.lex" return (CONSOLE); break; case 37: # line 46 "parse.lex" return (BUFFER); break; case 38: # line 47 "parse.lex" return (SYMBOL); break; case 39: # line 48 "parse.lex" return (STENCIL); break; case 40: # line 49 "parse.lex" return (DEFINE); break; case 41: # line 50 "parse.lex" return (FINDREPLACE); break; case 42: # line 51 "parse.lex" return (ALL); break; case 43: # line 52 "parse.lex" return (SHELL); break; case 44: # line 53 "parse.lex" return (FILESELECT); break; case 45: # line 54 "parse.lex" return (REMARK); break; case 46: # line 55 "parse.lex" return (NOTEQUAL); break; case 47: # line 56 "parse.lex" return (LESSEQUAL); break; case 48: # line 57 "parse.lex" return (GREATEREQUAL); break; case 49: # line 58 "parse.lex" return (LOGICAND); break; case 50: # line 59 "parse.lex" return (LOGICOR); break; case 51: # line 60 "parse.lex" return (LOGICXOR); break; case 52: # line 61 "parse.lex" return (ASSIGN); break; case 53: # line 62 "parse.lex" return (RANGE); break; case 54: # line 63 "parse.lex" return (MINUS); break; case 55: # line 64 "parse.lex" return (ADD); break; case 56: # line 65 "parse.lex" return (MULTIPLY); break; case 57: # line 66 "parse.lex" return (DIVIDE); break; case 58: # line 67 "parse.lex" return (REMAINDER); break; case 59: # line 68 "parse.lex" return (LOGICNOT); break; case 60: # line 69 "parse.lex" return (BITNOT); break; case 61: # line 70 "parse.lex" return (LAZYREF); break; case 62: # line 71 "parse.lex" return (EQUAL); break; case 63: # line 72 "parse.lex" return (LESS); break; case 64: # line 73 "parse.lex" return (GREATER); break; case 65: # line 74 "parse.lex" return (BITOR); break; case 66: # line 75 "parse.lex" return (BITAND); break; case 67: # line 76 "parse.lex" return (BITXOR); break; case 68: # line 77 "parse.lex" { yylval.ival=strtol(yytext,NULL,8); return (INTEGER); } break; case 69: # line 78 "parse.lex" { yylval.ival=strtol(yytext,NULL,16); return (INTEGER); } break; case 70: # line 79 "parse.lex" { yylval.ival=strtol(yytext,NULL,10); return (INTEGER); } break; case 71: # line 80 "parse.lex" case 72: # line 81 "parse.lex" case 73: # line 82 "parse.lex" case 74: # line 83 "parse.lex" case 75: # line 84 "parse.lex" { sscanf(yytext, "%lf", &yylval.rval); return (REAL); } break; case 76: # line 85 "parse.lex" { int i; for (i=yyleng-1; i>=0 && yytext[i]=='\\'; i--); if ((yyleng-i)%2) { char *conv; int i; Uchar *ucon,*slashconv; input(); conv=(char*) malloc((yyleng+1)*sizeof(char)); for (i=0; i<yyleng-1;i++) { conv[i]=yytext[i+1]; } conv[i]=0; ucon=LocaletoUstr(conv); free(conv); slashconv = (Uchar*)malloc((yyleng+1)*sizeof(Uchar)); convertslash(slashconv, ucon); yylval.utval=slashconv; return (STRING); } else { yymore(); } } break; case 77: # line 101 "parse.lex" { int i; for (i=yyleng-1; i>=0 && yytext[i]=='\\'; i--); if ((yyleng-i)%2) { input(); convertslashascii(yytext, yytext+1, yyleng-1); parse_key(yytext, &yylval.keyval.key, &yylval.keyval.mode); return (KEY); } else { yymore(); } } break; case 78: # line 113 "parse.lex" case 79: # line 114 "parse.lex" case 80: # line 115 "parse.lex" { Uchar b[40]; char bc[40]; int i; for (i=0; i<yyleng-2 && i<39;i++) { bc[i]=yytext[i+1]; } bc[i]=0; convertslash(b,LocaletoUstr(bc)); yylval.ival= b[0]; return (INTEGER); } break; case 81: # line 120 "parse.lex" { Type t; t = lookup_type(yytext); if (t) { yylval.ival=t; return (TYPEVAL); } yylval.tval=ident_buffer[current_id++]; if (current_id==MAXIDENTIFIER) current_id=0; strncpy(yylval.tval,yytext, IDENTLENGTH-1); return (IDENTIFIER); } break; case 82: # line 130 "parse.lex" { int i; if (yytext[yyleng-1]=='*') { input(); } else { yymore(); } } break; case 83: # line 137 "parse.lex" ; break; case 84: # line 138 "parse.lex" return yytext[0]; break; case -1: break; default: (void)fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
yylex(){ int nstr; extern int yyprevious; #ifdef LINUX if ( ! yyin) yyin = stdin; if ( ! yyout) yyout = stdout; #endif #ifdef __cplusplus /* to avoid CC and lint complaining yyfussy not being used ...*/ static int __lex_hack = 0; if (__lex_hack) goto yyfussy; #endif while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: # line 92 "magic.lex.l" { LPRINT0("lex: exhausted, suspending!\n"); return(-1); } break; case 2: # line 95 "magic.lex.l" { LPRINT0("lex: got \"^D\", ENDFILE\n"); returnToken(ENDFILE); } break; case 3: # line 98 "magic.lex.l" { LPRINT0("lex: got \"{\", LC\n"); returnToken(DOLLAR); } break; case 4: # line 101 "magic.lex.l" { LPRINT0("lex: got \"{\", LC\n"); returnToken(LC); } break; case 5: # line 104 "magic.lex.l" { LPRINT0("lex: got \"}\", RC\n"); returnToken(RC); } break; case 6: # line 107 "magic.lex.l" { LPRINT1("lex: got \"%s\", CL\n",yytext); returnToken(CL); } break; case 7: # line 110 "magic.lex.l" { LPRINT1("lex: got \"%s\", CM\n",yytext); returnToken(CM); } break; case 8: # line 113 "magic.lex.l" { LPRINT1("lex: got \"%s\", EQ\n",yytext); returnToken(EQ); } break; case 9: # line 116 "magic.lex.l" { LPRINT1("lex: got \"%s\", NE\n",yytext); returnToken(NE); } break; case 10: # line 119 "magic.lex.l" { LPRINT1("lex: got \"%s\", LT\n",yytext); returnToken(LT); } break; case 11: # line 122 "magic.lex.l" { LPRINT1("lex: got \"%s\", LE\n",yytext); returnToken(LE); } break; case 12: # line 125 "magic.lex.l" { LPRINT1("lex: got \"%s\", GT\n",yytext); returnToken(GT); } break; case 13: # line 128 "magic.lex.l" { LPRINT1("lex: got \"%s\", GE\n",yytext); returnToken(GE); } break; case 14: # line 131 "magic.lex.l" { LPRINT1("lex: got \"%s\", PLUS\n",yytext); returnToken(PLUS); } break; case 15: # line 134 "magic.lex.l" { LPRINT1("lex: got \"%s\", MINUS\n",yytext); returnToken(MINUS); } break; case 16: # line 137 "magic.lex.l" { LPRINT1("lex: got \"%s\", MULT\n",yytext); returnToken(MULT); } break; case 17: # line 140 "magic.lex.l" { LPRINT1("lex: got \"%s\", DIV\n",yytext); returnToken(DIV); } break; case 18: # line 143 "magic.lex.l" { LPRINT1("lex: got \"%s\", LP\n",yytext); returnToken(LP); } break; case 19: # line 146 "magic.lex.l" { LPRINT1("lex: got \"%s\", LB\n",yytext); returnToken(LB); } break; case 20: # line 149 "magic.lex.l" { LPRINT1("lex: got \"%s\", RB\n",yytext); returnToken(RB); } break; case 21: # line 152 "magic.lex.l" { LPRINT1("lex: got \"%s\", RP\n",yytext); returnToken(RP); } break; case 22: # line 155 "magic.lex.l" { LPRINT1("lex: got \"%s\", ABORT\n",yytext); returnToken(BOMB); } break; case 23: # line 158 "magic.lex.l" { LPRINT1("lex: got \"%s\",ABORTOFF\n",yytext); returnToken(IGNORE); } break; case 24: # line 161 "magic.lex.l" { LPRINT1("lex: got \"%s\", ABORTON\n",yytext); returnToken(DONT); } break; case 25: # line 164 "magic.lex.l" { LPRINT1("lex: got \"%s\", AND\n",yytext); returnToken(AND); } break; case 26: # line 167 "magic.lex.l" { LPRINT1("lex: got \"%s\", BREAK\n",yytext); returnToken(BREAK); } break; case 27: # line 170 "magic.lex.l" { LPRINT1("lex: got \"%s\", DO\n",yytext); returnToken(DO); } break; case 28: # line 173 "magic.lex.l" { LPRINT1("lex: got \"%s\", ELSE\n",yytext); returnToken(ELSE); } break; case 29: # line 176 "magic.lex.l" { LPRINT1("lex: got \"%s\", ELSEIF\n",yytext); returnToken(ELSEIF); } break; case 30: # line 179 "magic.lex.l" { LPRINT1("lex: got \"%s\", FI\n",yytext); returnToken(FI); } break; case 31: # line 182 "magic.lex.l" { LPRINT1("lex: got \"%s\", OD\n",yytext); returnToken(OD); } break; case 32: # line 185 "magic.lex.l" { LPRINT1("lex: got \"%s\", RETURN\n",yytext); returnToken(EXIT); } break; case 33: # line 188 "magic.lex.l" { LPRINT1("lex: got \"%s\", IF\n",yytext); returnToken(IF); } break; case 34: # line 191 "magic.lex.l" { LPRINT1("lex: got \"%s\", MOD\n",yytext); returnToken(MOD); } break; case 35: # line 194 "magic.lex.l" { LPRINT1("lex: got \"%s\", NOT\n",yytext); returnToken(NOT); } break; case 36: # line 197 "magic.lex.l" { LPRINT1("lex: got \"%s\", OR\n",yytext); returnToken(OR); } break; case 37: # line 200 "magic.lex.l" { LPRINT1("lex: got \"%s\", REPEAT\n",yytext); returnToken(REPEAT); } break; case 38: # line 203 "magic.lex.l" { LPRINT1("lex: got \"%s\", SHOW\n",yytext); returnToken(SHOW); } break; case 39: # line 206 "magic.lex.l" { LPRINT1("lex: got \"%s\", SIZE\n",yytext); returnToken(SIZE); } break; case 40: # line 209 "magic.lex.l" { LPRINT1("lex: got \"%s\", SQRT\n",yytext); returnToken(SQRT); } break; case 41: # line 212 "magic.lex.l" { LPRINT1("lex: got \"%s\", TRUNC\n",yytext); returnToken(TRUNC); } break; case 42: # line 215 "magic.lex.l" { LPRINT1("lex: got \"%s\", TYPEOF\n",yytext); returnToken(TYPEOF); } break; case 43: # line 218 "magic.lex.l" { LPRINT1("lex: got \"%s\", THEN\n",yytext); returnToken(THEN); } break; case 44: # line 221 "magic.lex.l" { LPRINT1("lex: got \"%s\", UNTIL\n",yytext); returnToken(UNTIL); } break; case 45: # line 224 "magic.lex.l" { LPRINT1("lex: got \"%s\", WHILE\n",yytext); returnToken(WHILE); } break; case 46: # line 227 "magic.lex.l" { LPRINT1("lex: got \"%s\", ID\n",yytext); returnToken(ID); } break; case 47: # line 231 "magic.lex.l" { LPRINT1("lex: got \"%s\", REAL\n",yytext); returnToken(REAL); } break; case 48: # line 235 "magic.lex.l" { LPRINT1("lex: got \"%s\", UNIT\n",yytext); returnToken(UNIT); } break; case 49: # line 239 "magic.lex.l" { int c,notDone,slashed; slashed = 0; notDone = 1; while (notDone) { c = input(); if ((c < ' ') && (c != '\t') && (c != '\n') && (c != '\r')) { yyleng = 1; yytext[0] = '\n'; yytext[1] = '\0'; LPRINT0("lex: unclosed string!\n"); returnToken(EOL); } if (slashed) { slashed = 0; switch (c) { case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case '\n': c = ' '; break; default: break; } if (yyleng < YYLMAX - 1) { yytext[yyleng++] = c; yytext[yyleng] = '\0'; } else { yyleng = 2; yytext[0] = '\n'; yytext[1] = '\n'; yytext[2] = '\0'; LPRINT0("lex: unclosed string!\n"); returnToken(EOL); } } else { if (c == '\\') slashed = 1; else { if (yyleng < YYLMAX-1) { yytext[yyleng++] = c; yytext[yyleng] = '\0'; } else { yyleng = 2; yytext[0] = '\n'; yytext[1] = '\n'; yytext[2] = '\0'; LPRINT0("lex: unclosed string!\n"); returnToken(EOL); } if (c == '\'') notDone = 0; } } } LPRINT1("lex: got \"%s\", STRING\n",yytext); returnToken(STRING); } break; case 50: # line 311 "magic.lex.l" { int c,notDone,slashed; slashed = 0; notDone = 1; while (notDone) { c = input(); if ((c < ' ') && (c != '\t') && (c != '\n') && (c != '\r')) { yyleng = 1; yytext[0] = '\n'; yytext[1] = '\0'; LPRINT0("lex: unclosed string!\n"); returnToken(EOL); } if (slashed) { slashed = 0; switch (c) { case 'b': c = '\b'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case '\n': c = ' '; break; default: break; } if (yyleng < YYLMAX - 1) { yytext[yyleng++] = c; yytext[yyleng] = '\0'; } else { yyleng = 2; yytext[0] = '\n'; yytext[1] = '\n'; yytext[2] = '\0'; LPRINT0("lex: unclosed string!\n"); returnToken(EOL); } } else { if (c == '\\') slashed = 1; else { if (yyleng < YYLMAX-1) { yytext[yyleng++] = c; yytext[yyleng] = '\0'; } else { yyleng = 2; yytext[0] = '\n'; yytext[1] = '\n'; yytext[2] = '\0'; LPRINT0("lex: unclosed string!\n"); returnToken(EOL); } if (c == '`') notDone = 0; } } } LPRINT1("lex: got \"%s\", STRING\n",yytext); returnToken(STRING); } break; case 51: # line 383 "magic.lex.l" { int c; while ((c=input()) != '"') if (c == '\n') { if (!ignoreEOL) { returnToken(EOL); } else { break; } } else if (c < ' ' && c != '\t') { yyleng = 1; yytext[0] = '\n'; yytext[1] = '\0'; returnToken(EOL); } LPRINT0("lex: got comment!\n"); } break; case 52: # line 394 "magic.lex.l" { int c; while ((c=input()) != '\n') ; LPRINT0("lex: got comment!\n"); if (!ignoreEOL) returnToken(EOL); } break; case 53: # line 401 "magic.lex.l" { int c; int done = 0; if (fromFile) { while (!done) { while ((c=input()) != '*') if (c == '\004') { yyleng = 2; yytext[0] = '\n'; yytext[1] = '\004'; yytext[2] = '\0'; returnToken(BAD); } while ((c=input()) == '*') ; if (c == '/') done = 1; } } else { while (!done) { while ( ((c=input()) != '*') && (c != '\n') ) ; if (c == '\n') { done = 1; returnToken(EOL); } else { while ((c=input()) == '*') ; if (c == '/') done = 1; else if (c == '\n') { done = 1; returnToken(EOL); } } } } LPRINT0("lex: got comment!\n"); } break; case 54: # line 449 "magic.lex.l" ; break; case 55: # line 450 "magic.lex.l" { if (ignoreEOL) { LPRINT0("lex: ignored \"\\n\", EOL\n"); } else { LPRINT0("lex: got \"\\n\", EOL\n"); returnToken(EOL); } } break; case 56: # line 458 "magic.lex.l" ; break; case 57: # line 459 "magic.lex.l" returnToken(BAD); break; case -1: break; default: (void)fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
int yylex () { int nstr; while ((nstr = yylook ()) >= 0) switch (nstr) { case 0: if (yywrap ()) return (0); break; case 1: yymark (); break; case 2: yymark (); break; case 3: return (OR); break; case 4: return (AND); break; case 5: return (LE); break; case 6: return (GE); break; case 7: return (EQ); break; case 8: return (DOTS); break; case 9: return screen (); break; case 10: { s_lookup ((ICON)); return (ICON); } break; case 11: { s_lookup ((RCON)); return (RCON); } break; case 12: { s_lookup ((ESTRING)); return (ESTRING); } break; case 13: { s_lookup ((ESTRING)); return (ESTRING); } break; case 14: ; break; case 15: return ((yytext[0])); break; case -1: break; default: fprintf (yyout, "bad switch yylook %d", nstr); } return (0); }
/* * Argument cracking... */ static void fsi_get_args(int c, char *v[]) { int ch; int usage = 0; char *iptr = idvbuf; /* * Determine program name */ if (v[0]) { progname = strrchr(v[0], '/'); if (progname && progname[1]) progname++; else progname = v[0]; } if (!progname) progname = "fsinfo"; while ((ch = getopt(c, v, "a:b:d:e:f:h:m:D:U:I:qv")) != -1) switch (ch) { case 'a': autodir = optarg; break; case 'b': if (bootparams_pref) fatal("-b option specified twice"); bootparams_pref = optarg; break; case 'd': if (dumpset_pref) fatal("-d option specified twice"); dumpset_pref = optarg; break; case 'h': xstrlcpy(hostname, optarg, sizeof(hostname)); break; case 'e': if (exportfs_pref) fatal("-e option specified twice"); exportfs_pref = optarg; break; case 'f': if (fstab_pref) fatal("-f option specified twice"); fstab_pref = optarg; break; case 'm': if (mount_pref) fatal("-m option specified twice"); mount_pref = optarg; break; case 'q': verbose = -1; break; case 'v': verbose = 1; break; case 'I': case 'D': case 'U': /* sizeof(iptr) is actually that of idvbuf. See declaration above */ xsnprintf(iptr, sizeof(idvbuf), "-%c%s ", ch, optarg); iptr += strlen(iptr); break; default: usage++; break; } if (c != optind) { g_argv = v + optind - 1; #ifdef yywrap if (yywrap()) #endif /* yywrap */ fatal("Cannot read any input files"); } else { usage++; } if (usage) { fprintf(stderr, "\ Usage: %s [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]\n\ \t[-e exports] [-f fstabs] [-m automounts]\n\ \t[-I dir] [-D|-U string[=string]] config ...\n", progname); exit(1); } if (g_argv[0]) fsi_log("g_argv[0] = %s", g_argv[0]); else fsi_log("g_argv[0] = (nil)"); }
yylex(){ int nstr; extern int yyprevious; while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: {} break; case 2: {Cid = enter(0,yytext,yyleng); if (LexDebug) { printf("%s : %s (%d)\n", yytext, ((Cid->tokentype) ? "RESERVED" : "IDENTIFIER"), Cid->count); } if (Cid->tokentype) { return(Cid->tokentype); } else { yyint = Cid->value; return(R_ID); } } break; case 3: {if (LexDebug) { printf("%s : %s\n", yytext, "REAL"); } return(R_REAL); } break; case 4: {if (LexDebug) { printf("%s : %s\n", yytext, "INTEGER"); } yyint = atoi(yytext); return(R_INTEGER);} break; case 5: {if (LexDebug) { printf("%s : %s\n", yytext, "(HEX)INTEGER"); } yyint = strtol(yytext+2,NULL,16); return(R_INTEGER);} break; case 6: {if (LexDebug) { printf("%s : %s\n", yytext, "(HEX)INTEGER"); } yyint = strtol(yytext,NULL,16); return(R_INTEGER);} break; case 7: {if (LexDebug) { printf("%s : %s\n", yytext, "(OCT)INTEGER"); } yyint = strtol(yytext+2,NULL,8); return(R_INTEGER);} break; case 8: {if (LexDebug) { printf("%s : %s\n", yytext, "(OCT)INTEGER"); } yyint = strtol(yytext,NULL,8); return(R_INTEGER);} break; case 9: {if (LexDebug) { printf("%s : %s\n", yytext, "(CHAR)INTEGER"); } if (yyleng>4) { yyint = strtol(yytext+2,NULL,8); } else { if (*(yytext+1)=='\\') { switch(*(yytext+2)) { case '0': yyint=0; break; case 'b': yyint = 0x8; break; case 'i': yyint = 0x9; break; case 'n': yyint = 0xa; break; case 'v': yyint = 0xb; break; case 'f': yyint = 0xc; break; case 'r': yyint = 0xd; break; default: yyint=(*yytext+2); break; } } else { yyint = *(yytext+1); } } return(R_INTEGER);} break; case 10: {if (LexDebug) { printf("%s : %s\n", yytext, "LBRACKET"); } return(R_LBRACKET);} break; case 11: {if (LexDebug) { printf("%s : %s\n", yytext, "RBRACKET"); } return(R_RBRACKET);} break; case 12: {if (LexDebug) { printf("%s : %s\n", yytext, "STRING"); } return(R_STRING);} break; case 13: {CommentDepth++; BEGIN COMMENT;} break; case 14: {CommentDepth--;if(!CommentDepth) BEGIN NORMAL;} break; case 15: { /* None of the above rules applicable, so it's a bad symbol. */ printf("Bad input char '%c' on line %d\n", yytext[0], yylineno); } break; case 16: {} break; case -1: break; default: fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
yylex(){ int nstr; extern int yyprevious; while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: {;} break; case 2: {;} break; case 3: {return TYPE;} break; case 4: {return ENDT;} break; case 5: {return BODY;} break; case 6: {return ENDB;} break; case 7: {return INT ;} break; case 8: {return BOOL;} break; case 9: {return TRUE;} break; case 10: {return FALSE;} break; case 11: {return XOR;} break; case 12: {return OR;} break; case 13: {return AND;} break; case 14: {return NOT;} break; case 15: {return FM; } break; case 16: {return FD; } break; case 17: {return IS;} break; case 18: {return NS;} break; case 19: {return MS;} break; case 20: {return BMS;} break; case 21: {return EMS;} break; case 22: {return ES;} break; case 23: {return TR;} break; case 24: {return FR;} break; case 25: {return TO;} break; case 26: {return ET;} break; case 27: {return RE;} break; case 28: {return ER;} break; case 29: {return AC;} break; case 30: {return EA;} break; case 31: {return INF_E;} break; case 32: {return SUP_E;} break; case 33: {return NO_EQ;} break; case 34: {return INF_S;} break; case 35: {return SUP_S;} break; case 36: {return EQUAL;} break; case 37: {return AFFECT;} break; case 38: {return ADD;} break; case 39: {return SUB;} break; case 40: {return DIV;} break; case 41: {return EXP;} break; case 42: {return MUL;} break; case 43: {return MOD;} break; case 44: {strcpy (yylval.str,yytext);return RELET; } break; case 45: {strcpy (yylval.str,yytext);return IDENTIFIER;} break; case 46: {sscanf (yytext,"%d",&yylval.val);return INTEGER;} break; case 47: {strcpy (yylval.str,yytext);return REAL;} break; case 48: {return yytext [0];} break; case -1: break; default: fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
int main(int argc, char **argv) { for (;;) { int c = getopt(argc, argv, "y"); if (c == -1) break; switch (c) { case 'y': option_easy = 1; option_prompt = "> "; break; default: fprintf(stderr, "unrecognized option: %c\n", c); break; } } field_init_z(Z); field_init_multiz(M); symtab_init(tab); builtin(fun_rnd); builtin(fun_random); builtin(fun_ord); builtin(fun_order); builtin(fun_nextprime); builtin(fun_sqrt); builtin(fun_inv); builtin(fun_type); builtin(fun_pairing); builtin(fun_zmod); builtin(fun_poly); builtin(fun_polymod); builtin(fun_extend); builtin(fun_exit); builtin(fun_CHECK); builtin(fun_init_pairing_a); builtin(fun_init_pairing_d); builtin(fun_init_pairing_e); builtin(fun_init_pairing_f); builtin(fun_init_pairing_g); builtin(fun_init_pairing_i); run_init_pairing_a(NULL); symtab_put(reserved, val_new_field(M), "M"); symtab_put(reserved, val_new_field(Z), "Z"); if (argc > optind) { FILE *fp = fopen(argv[optind], "r"); if (!fp) pbc_die("fopen failed on %s", argv[optind]); YY_BUFFER_STATE st = yy_create_buffer(fp, YY_BUF_SIZE); yy_switch_to_buffer(st); yywrapfun = yywrap_return1; yyparse(); yy_delete_buffer(st); } else { yywrapfun = yywrap_readline; yywrap(); while (!end_of_input) { if (2 == yyparse()) pbc_die("parser out of memory"); } putchar('\n'); } symtab_clear(tab); field_clear(M); return 0; }
int yylex(){ int nstr; extern int yyprevious; #ifdef __cplusplus /* to avoid CC and lint complaining yyfussy not being used ...*/ static int __lex_hack = 0; if (__lex_hack) goto yyfussy; #endif while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: # line 45 "shell.l" { return NEWLINE; } break; case 2: # line 47 "shell.l" { /* Discard spaces and tabs */ } break; case 3: # line 49 "shell.l" { return AMPERSAND; } break; case 4: # line 51 "shell.l" { return GREAT; } break; case 5: # line 53 "shell.l" { return GREATAMPERSAND; } break; case 6: # line 55 "shell.l" { return GREATGREAT; } break; case 7: # line 57 "shell.l" { return GREATGREATAMPERSAND; } break; case 8: # line 59 "shell.l" { return LESS; } break; case 9: # line 61 "shell.l" { return PIPE; } break; case 10: # line 63 "shell.l" { yylval.string_val = strdup(yytext+1); yylval.string_val[strlen(yylval.string_val) - 1] = '\0'; return WORD; } break; case 11: # line 69 "shell.l" { yylval.string_val = strdup(yytext+1); yylval.string_val[strlen(yylval.string_val) - 1] = '\0'; return WORD; } break; case 12: # line 75 "shell.l" { char *buff = strdup(yytext); char *word = (char*)malloc(strlen(yytext) + 1); int j; j = 0; int i; i = 0; while (i < strlen(buff) + 1) { if (buff[i] == '\\') { word[j] = buff[i+1]; i = i + 2; } else { word[j] = buff[i]; i++; } j++; } yylval.string_val = strdup(word); return WORD; } break; case 13: # line 104 "shell.l" { return NOTOKEN; } break; case -1: break; default: (void)fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
yylex(){ int nstr; extern int yyprevious; #ifdef __cplusplus /* to avoid CC and lint complaining yyfussy not being used ...*/ static int __lex_hack = 0; if (__lex_hack) goto yyfussy; #endif while((nstr = yylook()) >= 0) yyfussy: switch(nstr){ case 0: if(yywrap()) return(0); break; case 1: # line 36 "prop.l" ECHO; break; case 2: # line 37 "prop.l" ECHO; break; case 3: # line 38 "prop.l" GETTOKEN(NEWLINE); break; case 4: # line 39 "prop.l" GETTOKEN(THEREFORE); break; case 5: # line 40 "prop.l" GETTOKEN(BICONDITIONAL); break; case 6: # line 41 "prop.l" GETTOKEN(IMPLICATION); break; case 7: # line 42 "prop.l" GETTOKEN(OR); break; case 8: # line 43 "prop.l" GETTOKEN(AND); break; case 9: # line 44 "prop.l" GETTOKEN(NEGATION); break; case 10: # line 45 "prop.l" GETTOKEN(LPAREN); break; case 11: # line 46 "prop.l" GETTOKEN(RPAREN); break; case 12: # line 47 "prop.l" GETTOKEN(COMMA); break; case 13: # line 48 "prop.l" GETTOKEN(SEMICOLON); break; case 14: # line 49 "prop.l" GETTOKEN(QUIT); break; case 15: # line 50 "prop.l" GETTOKEN(TRUE); break; case 16: # line 51 "prop.l" GETTOKEN(FALSE); break; case 17: # line 52 "prop.l" GETTOKEN(IDENTIFIER); break; case 18: # line 53 "prop.l" { ECHO; YYDUMP(); strcpy(yylval.string, yytext); return(*yytext); } break; case -1: break; default: (void)fprintf(yyout,"bad switch yylook %d",nstr); } return(0); }
int yyclexer::yylex() { while (1) { int state = 1 + yystart; if (yyeol) { state++; } // yymore if (yymoreflg) { yymoreflg = 0; // clear flag } else { yyleng = 0; yyoldeol = yyeol; } int oldleng = yyleng; // look for a string do { // get input character (lookahead character) int ch = yyinput(); yyassert(ch >= 0 && ch <= UCHAR_MAX || ch == EOF); if (ch == EOF) { break; } // check for possible overflow if (yyleng == yytext_size) { do { if (yytextgrow) { if (yytext_size != 0) { int size = yytext_size * 2; if (size / 2 == yytext_size) { // overflow check if (yysettextsize(size)) { break; } } } else { if (yysettextsize(100)) { break; } } } yytextoverflow(); exit(EXIT_FAILURE); } while (0); } // look for a transition int index = yystate[state].base; while (1) { if (yyctransition[index].next == 0) { state = yystate[state].def; if (state <= 0) { if (state < 0) { if (ch >= 0 && ch <= 0xff) { state = -state; } else { state = 0; } } break; } } if (ch >= yyctransition[index].first && ch <= yyctransition[index].last) { state = yyctransition[index].next; break; } index++; } int leng = yyleng; // slightly more efficient code yytext[leng] = (char)ch; yystatebuf[leng] = state; leng++; yyleng = leng; } while (state != 0 && (yystate[state].def != 0 || yystate[state].base != 0)); // now find a match if (yyleng > oldleng) { int rejectmatch = 0; while (1) { int match = yystate[yystatebuf[yyleng - 1]].match; if (rejectmatch != 0) { if (match < 0) { int index = -match; do { match = yymatch[index++]; } while (match > 0 && match <= rejectmatch); } else { if (match == rejectmatch) { match = 0; } } rejectmatch = 0; } else { if (match < 0) { match = yymatch[-match]; } } if (match > 0) { // check for backup if (yybackup[match]) { while (yyleng > oldleng) { int index = yystate[yystatebuf[yyleng - 1]].match; if (index < 0) { if (yyback(&yymatch[-index], -match)) { break; // found an expression } } yyleng--; yyunput((unsigned char)yytext[yyleng]); } } yytext[yyleng] = '\0'; #ifdef YYDEBUG yydmatch(match); #endif yyrejectflg = 0; // clear flag int rejectleng = yyleng; if (yyleng > 0) { yyeol = (unsigned char)(yytext[yyleng - 1] == '\n'); } else { yyeol = yyoldeol; } // perform user action int token = yyaction(match); if (yyreturnflg) { return token; } if (!yyrejectflg) { break; } if (rejectleng == yyleng) { rejectmatch = match; } } else if (yyleng > oldleng + 1) { yyleng--; yyunput((unsigned char)yytext[yyleng]); } else { yyeol = (unsigned char)(yytext[0] == '\n'); yyoutput(yytext[0]); // non-matched character break; } } } else { yyassert(yyleng == oldleng); // handles <<EOF>> rules int index = 0; int match = yystate[state].match; if (match < 0) { index = -match; match = yymatch[index++]; } while (match > 0) { yytext[yyleng] = '\0'; #ifdef YYDEBUG yydmatch(match); #endif yyrejectflg = 0; // clear flag // perform user action int token = yyaction(match); if (yyreturnflg) { return token; } if (!yyrejectflg) { break; } if (index == 0) { break; } match = yymatch[index++]; } if (yywrap()) { yyoldeol = 1; yyeol = 1; yystart = 0; return 0; // eof reached } } } }