📄 scan.c
字号:
77, 131, 77, 80, 79, 129, 79, 126, 80, 125, 80, 144, 144, 123, 122, 120, 119, 117, 116, 113, 112, 111, 110, 108, 105, 104, 103, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 86, 85, 84, 83, 82, 81, 78, 75, 74, 73, 72, 70, 69, 68, 67, 66, 65, 63, 62, 61, 60, 59, 58, 57, 56, 52, 48, 42, 40, 39, 36, 35, 34, 33, 30, 28, 27, 26, 25, 24, 23, 22, 21, 20, 18, 12, 10, 9, 8, 7, 5, 3, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143 } ;static yy_state_type yy_last_accepting_state;static YY_CHAR *yy_last_accepting_cpos;/* the intent behind this definition is that it'll catch * any uses of REJECT which flex missed */#define REJECT reject_used_but_not_detected#define yymore() yymore_used_but_not_detected#define YY_MORE_ADJ 0/* these variables are all declared out here so that section 3 code can * manipulate them *//* points to current character in buffer */static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;static int yy_init = 1; /* whether we need to initialize */static int yy_start = 0; /* start state number *//* flag which is used to allow yywrap()'s to do buffer switches * instead of setting up a fresh yyin. A bit of a hack ... */static int yy_did_buffer_switch_on_eof;static yy_state_type yy_get_previous_state YY_PROTO(( void ));static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));static int yy_get_next_buffer YY_PROTO(( void ));static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));void yyrestart YY_PROTO(( FILE *input_file ));void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));void yy_load_buffer_state YY_PROTO(( void ));YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));#define yy_new_buffer yy_create_buffer#ifdef __cplusplusstatic int yyinput YY_PROTO(( void ));#elsestatic int input YY_PROTO(( void ));#endifYY_DECL { register yy_state_type yy_current_state; register YY_CHAR *yy_cp, *yy_bp; register int yy_act; if ( yy_init ) { YY_USER_INIT; if ( ! yy_start ) yy_start = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( yy_current_buffer ) yy_init_buffer( yy_current_buffer, yyin ); else yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_load_buffer_state(); yy_init = 0; } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = yy_c_buf_p; /* support of yytext */ *yy_cp = yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of the * current run. */ yy_bp = yy_cp; yy_current_state = yy_start;yy_match: do { register YY_CHAR yy_c = yy_ec[*yy_cp]; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = yy_def[yy_current_state]; if ( yy_current_state >= 144 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 194 );yy_find_action: yy_act = yy_accept[yy_current_state]; YY_DO_BEFORE_ACTION; YY_USER_ACTION;do_action: /* this label is used only to access EOF actions */ switch ( yy_act ) { case 0: /* must backtrack */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yy_hold_char; yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; goto yy_find_action;case 1:# line 61 "scan.l"return(Define); YY_BREAKcase 2:# line 62 "scan.l"return(Break); YY_BREAKcase 3:# line 63 "scan.l"return(Quit); YY_BREAKcase 4:# line 64 "scan.l"return(Length); YY_BREAKcase 5:# line 65 "scan.l"return(Return); YY_BREAKcase 6:# line 66 "scan.l"return(For); YY_BREAKcase 7:# line 67 "scan.l"return(If); YY_BREAKcase 8:# line 68 "scan.l"return(While); YY_BREAKcase 9:# line 69 "scan.l"return(Sqrt); YY_BREAKcase 10:# line 70 "scan.l"return(Scale); YY_BREAKcase 11:# line 71 "scan.l"return(Ibase); YY_BREAKcase 12:# line 72 "scan.l"return(Obase); YY_BREAKcase 13:# line 73 "scan.l"return(Auto); YY_BREAKcase 14:# line 74 "scan.l"return(Else); YY_BREAKcase 15:# line 75 "scan.l"return(Read); YY_BREAKcase 16:# line 76 "scan.l"return(Halt); YY_BREAKcase 17:# line 77 "scan.l"return(Last); YY_BREAKcase 18:# line 78 "scan.l"return(Warranty); YY_BREAKcase 19:# line 79 "scan.l"return(Continue); YY_BREAKcase 20:# line 80 "scan.l"return(Print); YY_BREAKcase 21:# line 81 "scan.l"return(Limits); YY_BREAKcase 22:# line 82 "scan.l"{ yylval.c_value = yytext[0]; return((int)yytext[0]); } YY_BREAKcase 23:# line 84 "scan.l"{ return(AND); } YY_BREAKcase 24:# line 85 "scan.l"{ return(OR); } YY_BREAKcase 25:# line 86 "scan.l"{ return(NOT); } YY_BREAKcase 26:# line 87 "scan.l"{ yylval.c_value = yytext[0]; return(MUL_OP); } YY_BREAKcase 27:# line 88 "scan.l"{ yylval.c_value = yytext[0]; return(ASSIGN_OP); } YY_BREAKcase 28:# line 89 "scan.l"{ #ifdef OLD_EQ_OP char warn_save; warn_save = warn_not_std; warn_not_std = TRUE; warn ("Old fashioned =<op>"); warn_not_std = warn_save; yylval.c_value = yytext[1];#else yylval.c_value = '='; yyless (1);#endif return(ASSIGN_OP); } YY_BREAKcase 29:# line 103 "scan.l"{ yylval.s_value = strcopyof(yytext); return(REL_OP); } YY_BREAKcase 30:# line 104 "scan.l"{ yylval.c_value = yytext[0]; return(INCR_DECR); } YY_BREAKcase 31:# line 105 "scan.l"{ line_no++; return(NEWLINE); } YY_BREAKcase 32:# line 106 "scan.l"{ line_no++; /* ignore a "quoted" newline */ } YY_BREAKcase 33:# line 107 "scan.l"{ /* ignore spaces and tabs */ } YY_BREAKcase 34:# line 108 "scan.l"{ int c; for (;;) { while ( ((c=input()) != '*') && (c != EOF)) /* eat it */ if (c == '\n') line_no++; if (c == '*') { while ( (c=input()) == '*') /* eat it*/; if (c == '/') break; /* at end of comment */ if (c == '\n') line_no++; } if (c == EOF) { fprintf (stderr,"EOF encountered in a comment.\n"); break; } } } YY_BREAKcase 35:# line 129 "scan.l"{ yylval.s_value = strcopyof(yytext); return(NAME); } YY_BREAKcase 36:# line 130 "scan.l"{ unsigned char *look; int count = 0; yylval.s_value = strcopyof(yytext); for (look = yytext; *look != 0; look++) { if (*look == '\n') line_no++; if (*look == '"') count++; } if (count != 2) yyerror ("NUL character in string."); return(STRING); } YY_BREAKcase 37:# line 142 "scan.l"{ unsigned char *src, *dst; int len; /* remove a trailing decimal point. */ len = strlen(yytext); if (yytext[len-1] == '.') yytext[len-1] = 0; /* remove leading zeros. */ src = yytext; dst = yytext; while (*src == '0') src++; if (*src == 0) src--; /* Copy strings removing the newlines. */ while (*src != 0) { if (*src == '\\') { src++; src++; line_no++; } else *dst++ = *src++; } *dst = 0; yylval.s_value = strcopyof(yytext); return(NUMBER); } YY_BREAKcase 38:# line 169 "scan.l"{ if (yytext[0] < ' ') yyerror ("illegal character: ^%c",yytext[0] + '@'); else if (yytext[0] > '~') yyerror ("illegal character: \\%3d", (int) yytext[0]); else yyerror ("illegal character: %s",yytext); } YY_BREAKcase 39:# line 178 "scan.l"ECHO; YY_BREAKcase YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* amount of text matched not including the EOB char */ int yy_amount_of_matched_text = yy_cp - yytext - 1; /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yy_hold_char; /* note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the end- * of-buffer state). Contrast this with the test in yyinput(). */ if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) /* this was really a NUL */ { yy_state_type yy_next_state; yy_c_buf_p = yytext + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); /* okay, we're now positioned to make the * NUL transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we * don't want to build jamming into it because * then it will run more slowly) */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = yytext + YY_MORE_ADJ; if ( yy_next_state ) { /* consume the NUL */ yy_cp = ++yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { goto yy_find_action; } } else switch ( yy_get_next_buffer() ) { case EOB_ACT_END_OF_FILE: { yy_did_buffer_switch_on_eof = 0; if ( yywrap() ) { /* note: because we've taken care in * yy_get_next_buffer() to have set up yytext, * we can now set up yy_c_buf_p so that if some * total hoser (like flex itself) wants * to call the scanner after we return the * YY_NULL, it'll still work - another YY_NULL * will get returned. */ yy_c_buf_p = yytext + YY_MORE_ADJ; yy_act = YY_STATE_EOF((yy_start - 1) / 2); goto do_action; } else { if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -