/** Get the next Symbol from the input (supplied by generated subclass). * Once end of file has been reached, all subsequent calls to scan * should return an EOF Symbol (which is Symbol number 0). By default * this method returns getScanner().next_token(); this implementation * can be overriden by the generated parser using the code declared in * the "scan with" clause. Do not recycle objects; every call to * scan() should return a fresh object. */ public Symbol scan() throws java.lang.Exception { Symbol sym = getScanner().next_token(); return (sym!=null) ? sym : getSymbolFactory().newSymbol("END_OF_FILE",EOF_sym()); }
/** Do debug output for a reduce. * * @param prod_num the production we are reducing with. * @param nt_num the index of the LHS non terminal. * @param rhs_size the size of the RHS. */ public void debug_reduce(int prod_num, int nt_num, int rhs_size) { debug_message("# Reduce with prod #" + prod_num + " [NT=" + nt_num + ", " + "SZ=" + rhs_size + "]"); }
/** This method is called if it is determined that syntax error recovery * has been unsuccessful. Here in the base class we report a fatal error. * * @param cur_token the current lookahead Symbol. */ public void unrecovered_syntax_error(Symbol cur_token) throws java.lang.Exception { report_fatal_error("Couldn't repair and continue parse", cur_token); }
Symbol newSymbol(int ss, String value) { last = ss; return new Symbol(ss, value); } Symbol newSymbol(int ss, Long value) {
/** * Constructor that sets the default scanner and a SymbolFactory */ public lr_parser(Scanner s, SymbolFactory symfac) { this(); // in case default constructor someday does something symbolFactory = symfac; setScanner(s); } public SymbolFactory symbolFactory;// = new DefaultSymbolFactory();
/** Advance to next "parse ahead" input Symbol. Return true if we have * input to advance to, false otherwise. */ protected boolean advance_lookahead() { /* advance the input location */ lookahead_pos++; /* return true if we didn't go off the end */ return lookahead_pos < error_sync_size(); }
/** This method is called when a syntax error has been detected and recovery * is about to be invoked. Here in the base class we just emit a * "Syntax error" error message. * * @param cur_token the current lookahead Symbol. */ public void syntax_error(Symbol cur_token) { report_error("Syntax error", cur_token); }
/** * Constructor that sets the default scanner. [CSA/davidm] */ @SuppressWarnings("deprecation") public lr_parser(Scanner s) { this(s,new DefaultSymbolFactory()); // TUM 20060327 old cup v10 Symbols as default } /**
public Symbol newSymbol(String name, int id){ return new ComplexSymbol(name,id); } public Symbol newSymbol(String name, int id, Object value){
Symbol newSymbol(int ss) { last = ss; return new Symbol(ss); } Symbol newSymbol(int ss, String value) {
/** Do debug output for shift. * * @param shift_tkn the Symbol being shifted onto the stack. */ public void debug_shift(Symbol shift_tkn) { debug_message("# Shift under term #" + shift_tkn.sym + " to state #" + shift_tkn.parse_state); }
public Symbol newSymbol(String name, int id, Location left, Location right){ return new ComplexSymbol(name,id,left,right); } public Symbol newSymbol(String name, int id, Symbol left, Symbol right, Object value){
public Symbol newSymbol(String name, int id, int left, int right, Object value){ return new Symbol(id,left,right,value); } public Symbol newSymbol(String name, int id, int left, int right){
public Symbol newSymbol(String name, int id, Symbol left, Symbol right, Object value){ return new ComplexSymbol(name,id,left,right,value); } public Symbol newSymbol(String name, int id, Symbol left, Symbol right){
public Symbol newSymbol(String name, int id){ return new Symbol(id); } public Symbol newSymbol(String name, int id, Object value){
public Symbol newSymbol(String name, int id, Symbol left, Symbol right){ return new ComplexSymbol(name,id,left,right); } public Symbol newSymbol(String name, int id){
Symbol newSymbol(int ss, Double value) { last = ss; return new Symbol(ss, value); } private java.io.BufferedReader yy_reader;
public Symbol startSymbol(String name, int id, int state){ return new ComplexSymbol(name,id,state); } }
Symbol newSymbol(int ss, Long value) { last = ss; return new Symbol(ss, value); } Symbol newSymbol(int ss, Double value) {
public Symbol newSymbol(String name ,int id, Symbol left, Symbol right, Object value){ return new Symbol(id,left,right,value); } public Symbol newSymbol(String name, int id, Symbol left, Symbol right){