/* A lexical scanner generated by flex */ /* Scanner skeleton version: * $Header: /db0/home/nsl/www.export/protected/NS/cvsroot/pp/src/jbf/yylex.template,v 1.2 1997/03/28 02:06:50 aalx Exp $ */ /* * Copyright (c) 1996 Dennis Heimbigner. email dennis@cs.colorado.edu */ /**************************************************/ @package@ /**************************************************/ /**************************************************/ // PREFIX @PREFIX@ /**************************************************/ public class @YYlex@ { // Set up the fake goto mechanism protected int Goto; protected static final int yynobranch = 0; protected static final int yy_find_action = 1; protected static final int yy_match = 2; protected static final int do_action = 3; // CONSTANTS @CONSTANTS@ // STATES @STATES@ // MISC. protected static final int EOF = -1; // Class State Int_Stack yy_start_stack; java.io.InputStream yyin; java.io.PrintStream yyout; int yy_start; /* start state number */ int yy_last_accepting_state; int yy_last_accepting_cpos; YYtoken yylval; YYtoken yylvalundef; protected StringBuffer lexeme; YYlexbuffer yytext; public int yydebug; boolean yy_at_bol; boolean is_interactive; int yy_current_state; int yy_act; // PROCS @PROCS@ public @YYlex@(java.io.InputStream fin) {this(fin,System.out);} public @YYlex@() {this(System.in,System.out);} public @YYlex@(java.io.InputStream fin, java.io.PrintStream fout) { yyin = fin; yyout = fout; yy_start_stack = new Int_Stack(); yy_start = 1; /* start state number */ yy_last_accepting_state = 0; yy_last_accepting_cpos = 0; yy_current_state = 0; yy_act = 0; yy_at_bol = true; //pretend is_interactive= false; yylval = null; yylvalundef = new YYtoken(0); yydebug = 0; yytext = new YYlexbuffer(yyin,yyout); lexeme = new StringBuffer(); @constructor@ } public @YYtoken@ @yylex@() throws LexException, IOException, EmptyStackException { yytext.purge(); scanloop: while( true ) { /* loops until end-of-file is reached */ yytext.mark(); int thisch = yytext.nextchar(); if(thisch == EOF) thisch = YY_END_OF_BUFFER_CHAR; branch: switch (Goto) { case yynobranch: yy_current_state = yy_start; yy_current_state += YY_AT_BOL(); //<< //yy_match: do { ///**/yyout.println("(1)yy_current_state=" + yy_current_state); int yy_c; // yy_c = yy_ec[YY_SC_TO_UI(thisch)]; yy_c = yy_ec[thisch]; ///**/yyout.println("(1)yy_c=" + yy_c); ///**/yyout.println("(1)yy_accept[yy_current_state]=" + yy_accept[yy_current_state]); if ( yy_accept[yy_current_state] != 0) { yy_last_accepting_cpos = yytext.currentpos(); yy_last_accepting_state = yy_current_state; ///**/yyout.println("(1)yy_last_accepting_state=" + yy_last_accepting_state); ///**/yyout.println("(1)yy_last_accepting_cpos=" + yy_last_accepting_cpos); } while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) { ///**/yyout.println("(2)yy_chk[yy_base[yy_current_state]+yy_c]="+yy_chk[yy_base[yy_current_state] + yy_c]); yy_current_state = (int) yy_def[yy_current_state]; ///**/yyout.println("(2)yy_current_state=" + yy_current_state); if ( yy_current_state >= yy_accept.length ) { yy_c = yy_meta[yy_c]; ///**/yyout.println("(2)yy_c=" + yy_c); } } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ///**/yyout.println("(3)yy_current_state=" + yy_current_state); ///**/yyout.println("yy_at_bol=" + yy_at_bol); yy_at_bol = (thisch == '\n'); thisch = yytext.nextchar(); if(thisch == EOF) thisch = YY_END_OF_BUFFER_CHAR; } while ( yy_base[yy_current_state] != YY_SPECIAL ); case yy_find_action: yy_act = yy_accept[yy_current_state]; ///**/yyout.println("(4)yy_act=" + yy_act); if ( yy_act == 0 ) { /* have to back up to last accepting state*/ do { yytext.backup(); } while(yytext.currentpos() >= yy_last_accepting_cpos); thisch = yytext.nextchar(); ///**/yyout.print("backup:"+" yyline="+yyline()+" ; yychar="+yychar0()+" ; yylinechar="+yychar()+" ; yytext=/"+yytext.contents()+"/"); yy_current_state = yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; ///**/yyout.println("(5)yy_current_state=" + yy_current_state); ///**/yyout.println("(5)yy_act=" + yy_act); } // YY_DO_BEFORE_ACTION; case do_action: /* This label is used only to access EOF actions. */ yy_at_bol = (yytext.yychar0() == 0); yylval = yylvalundef; yytext.backup(); ///**/yyout.println("(6)yy_act=" + yy_act); ///**/yyout.println("(6)yytext=/" + yytext.contents() + "/"); ///**/yyout.println("(6)yy_at_bol=" + yy_at_bol); ///**/yyout.println("yytext.lexeme=/" + yytext.lexeme() + "/"); switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* have to back up to last accepting state*/ do { yytext.backup(); } while(yytext.currentpos() > yy_last_accepting_cpos); thisch = yytext.nextchar(); ///**/yyout.print("backup:"+" yyline="+yyline()+" ; yychar="+yychar0()+" ; yylinechar="+yychar()+" ; yytext=/"+yytext.contents()+"/"); yy_current_state = yy_last_accepting_state; {Goto = yy_find_action; break branch;} // ACTIONS @ACTIONS@ case YY_END_OF_BUFFER: yy_act = YY_STATE_EOF(YY_START()); {Goto = do_action; break branch;} default: yyfatalerror( "fatal flex scanner internal error--no action found" ); break; } /* end of action switch */ if(yylval != yylvalundef) { if(yydebug >= 1) yyreport(yylval); return yylval; } else { if(yydebug >= 10) yyout.println("@yylex@: no token produced"); } } //branch } /* end of scanning one token */ } /* end of yylex */ public void yy_push_state( int new_state ) { yy_start_stack.push(YY_START()); BEGIN(new_state); } public void yy_pop_state() { BEGIN(yy_start_stack.pop()); } protected int yy_top_state() { return yy_start_stack.top(); } protected void yyfatalerror( String msg) throws LexException { throw new LexException("yylex: fatalerror: " + msg); } public void yylexerror(String s) throws LexException { yyout.println("yylexerror: " + "char/line+char " + yytext.yychar0() + "/" + yytext.yyline() + "+" + yytext.yychar0() + " ; " + s); throw new LexException(s); } public YYtoken yyreport(YYtoken yylval) { if(yylval != null) { yyout.println("yylex: " + " char/line+char " + yylval.charno0() + "/" + yylval.lineno() + "+" + yylval.charno() + " /" + YYtokentypes.tokenname(yylval.tokentype) + "/(" + yylval.tokentype + ") ; text=#" + yylval.text + "#"); } else { yyout.println("yylex: " + " char/line+char " + yytext.yychar0() + "/" + yytext.yyline() + "+" + yytext.yychar0() + " /EOF/"); } return yylval; } protected void BEGIN(int n) {yy_start = 1+2*n;} public void yybegin(int n) {BEGIN(n);} public int YY_START() {return (yy_start-1)/2;} protected int YY_AT_BOL() {return (yy_at_bol)?1:0;} protected int YY_STATE_EOF(int st) {return YY_END_OF_BUFFER + st + 1;} /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ protected int YY_SC_TO_UI(byte c) {return (int)((byte)c);} public void yy_set_interactive(boolean is_interactive) { this.is_interactive= is_interactive; } protected void yy_set_bol(boolean at_bol) { yy_at_bol = at_bol; } // TABLES @TABLES@ // SUFFIX @SUFFIX@ public void setdebug(boolean d) {yydebug = d?1:0; yytext.setdebug(d);} public void setdebug(int i) {yydebug = i>0?i:0; yytext.setdebug(i);} public void yyreturn(YYtoken t) {yylval = t;} // return 0 based line number public int yyline() {return yytext.yyline();} // return 0 based absolute char number public int yychar0() {return yytext.yychar0();} // return 0 based char number within line public int yychar() {return yytext.yychar();} } // class YYlex