Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix# fixed parse method in JavaSignatureBeaverParser.grammr and JavaS…

…ignatureBeaverLexer.flex
  • Loading branch information...
commit 0819c27dad70d69d1b841855b27cd18f21ea687d 1 parent 4a50070
@prathamesh-sonpatki authored
View
1,369 src/beaver/Parser.java
@@ -16,688 +16,689 @@
*/
public abstract class Parser
{
- static public class Exception extends java.lang.Exception
- {
- Exception(String msg)
- {
- super(msg);
- }
- }
-
- /**
- * This class "lists" reportable events that might happen during parsing.
- */
- static public class Events
- {
- public void scannerError(Scanner.Exception e)
- {
- System.err.print("Scanner Error:");
- if (e.line > 0)
- {
- System.err.print(e.line);
- System.err.print(',');
- System.err.print(e.column);
- System.err.print(':');
- }
- System.err.print(' ');
- System.err.println(e.getMessage());
- }
- public void syntaxError(Symbol token)
- {
- System.err.print(Symbol.getLine(token.start));
- System.err.print(',');
- System.err.print(Symbol.getColumn(token.start));
- System.err.print('-');
- System.err.print(Symbol.getLine(token.end));
- System.err.print(',');
- System.err.print(Symbol.getColumn(token.end));
- System.err.print(": Syntax Error: unexpected token ");
- if (token.value != null)
- {
- System.err.print('"');
- System.err.print(token.value);
- System.err.println('"');
- }
- else
- {
- System.err.print('#');
- System.err.println(token.id);
- }
- }
- public void unexpectedTokenRemoved(Symbol token)
- {
- System.err.print(Symbol.getLine(token.start));
- System.err.print(',');
- System.err.print(Symbol.getColumn(token.start));
- System.err.print('-');
- System.err.print(Symbol.getLine(token.end));
- System.err.print(',');
- System.err.print(Symbol.getColumn(token.end));
- System.err.print(": Recovered: removed unexpected token ");
- if (token.value != null)
- {
- System.err.print('"');
- System.err.print(token.value);
- System.err.println('"');
- }
- else
- {
- System.err.print('#');
- System.err.println(token.id);
- }
- }
- public void missingTokenInserted(Symbol token)
- {
- System.err.print(Symbol.getLine(token.start));
- System.err.print(',');
- System.err.print(Symbol.getColumn(token.start));
- System.err.print('-');
- System.err.print(Symbol.getLine(token.end));
- System.err.print(',');
- System.err.print(Symbol.getColumn(token.end));
- System.err.print(": Recovered: inserted missing token ");
- if (token.value != null)
- {
- System.err.print('"');
- System.err.print(token.value);
- System.err.println('"');
- }
- else
- {
- System.err.print('#');
- System.err.println(token.id);
- }
- }
- public void misspelledTokenReplaced(Symbol token)
- {
- System.err.print(Symbol.getLine(token.start));
- System.err.print(',');
- System.err.print(Symbol.getColumn(token.start));
- System.err.print('-');
- System.err.print(Symbol.getLine(token.end));
- System.err.print(',');
- System.err.print(Symbol.getColumn(token.end));
- System.err.print(": Recovered: replaced unexpected token with ");
- if (token.value != null)
- {
- System.err.print('"');
- System.err.print(token.value);
- System.err.println('"');
- }
- else
- {
- System.err.print('#');
- System.err.println(token.id);
- }
- }
- public void errorPhraseRemoved(Symbol error)
- {
- System.err.print(Symbol.getLine(error.start));
- System.err.print(',');
- System.err.print(Symbol.getColumn(error.start));
- System.err.print('-');
- System.err.print(Symbol.getLine(error.end));
- System.err.print(',');
- System.err.print(Symbol.getColumn(error.end));
- System.err.println(": Recovered: removed error phrase");
- }
- }
-
- /**
- * This class wrapps a Scanner and provides a token "accumulator" for a parsing simulation.
- * <p>If a source that is being parsed does not have syntax errors this wrapper only adds
- * one indirection while it delivers the next token. However when parser needs to recover
- * from a syntax error this wrapper accumulates tokens shifted by a forward parsing simulation
- * and later feeds them to the recovered parser.
- */
- public class TokenStream
- {
- public static final boolean BUFFER = true;
- public static final boolean FLUSH = false;
-
- private static final int BUF_SIZE = 4;
- private static final int IDX_MASK = BUF_SIZE - 1;
-
- private Scanner scanner;
- private Symbol[] buffer;
- private int idx_add;
- private int idx_get;
- private int ix_mark;
-
- public TokenStream(Scanner scanner)
- {
- this.scanner = scanner;
- this.buffer = new Symbol[BUF_SIZE];
- this.ix_mark = -1;
- }
-
- public void setMode(boolean buffering)
- {
- ix_mark = (buffering ? idx_get : -1);
- }
-
- public boolean isBuffering()
- {
- return ix_mark >= 0;
- }
-
- public boolean isEmpty()
- {
- return idx_get == idx_add;
- }
-
- public boolean isFull()
- {
- return ((idx_add + 1) & IDX_MASK) == (isBuffering() ? ix_mark : idx_get);
- }
-
- public int size()
- {
- return (idx_add - idx_get + BUF_SIZE) & IDX_MASK;
- }
-
- public void enque(Symbol symbol)
- {
- if (isFull())
- throw new IllegalStateException ("buffer is full");
- buffer[idx_add++] = symbol;
- idx_add &= IDX_MASK;
- }
-
- public Symbol peek()
- {
- if (isEmpty())
- throw new IllegalStateException ("buffer is empty");
- return buffer[idx_get];
- }
-
- public Symbol deque()
- {
- if (isEmpty())
- throw new IllegalStateException ("buffer is empty");
- Symbol symbol = buffer[idx_get++];
- idx_get &= IDX_MASK;
- return symbol;
- }
-
- public TokenStream(Scanner scanner, Symbol first_symbol)
- {
- this(scanner);
- enque(first_symbol);
- }
-
- public Symbol nextToken() throws IOException
- {
- if (isBuffering())
- {
- if (isEmpty())
- {
- enque(readToken());
- }
- return deque();
- }
- else
- {
- return (isEmpty() ? readToken() : deque());
- }
- }
-
- /**
- * Prepare accumulated tokens to be reread by a next simulation run
- * or by a recovered parser.
- */
- public void rewind()
- {
- if (!isBuffering())
- throw new IllegalStateException ("stream is not buffering");
- idx_get = ix_mark;
- }
-
- /**
- * Removes a symbol from the buffer.
- */
- public void remove(int offset)
- {
- if (!isBuffering())
- throw new IllegalStateException ("stream is not buffering");
- switch (offset)
- {
- case 0:
- deque();
- ix_mark = idx_get;
- break;
- case 1:
- Symbol s0 = deque();
- buffer[idx_get] = s0;
- ix_mark = idx_get;
- break;
- default:
- throw new IllegalStateException ("unsupported offset");
- }
- }
-
- /**
- * Reads next recognized token from the scanner. If scanner fails to recognize a token and
- * throws an exception it will be reported via Parser.scannerError().
- * <p>It is expected that scanner is capable of returning at least an EOF token after the
- * exception.</p>
- *
- * @return next recognized token
- * @throws IOException
- * as thrown by a scanner
- */
- private Symbol readToken() throws IOException
- {
- while (true)
- {
- try
- {
- return scanner.nextToken();
- }
- catch (Scanner.Exception e)
- {
- report.scannerError(e);
- }
- }
- }
- }
-
- /**
- * Simulator is a stripped (of action code) version of a parser that will try to parse ahead
- * token stream after a syntax error. The simulation is considered successful if 3 tokens were
- * shifted successfully. If during simulation this parser enconters an error it drops the first
- * token it tried to use and restarts the simulated parsing.
- * <p>
- * Note: Without a special "error" rule present in a grammar, which a parser will try to shift
- * at the beginning of an error recovery, simulation continues without removing anything from
- * the original states stack. This often will lead to cases when no parsing ahead will recover
- * the parser from a syntax error.
- * </p>
- */
- public class Simulator
- {
- private short[] states;
- private int top, min_top;
-
- public boolean parse(TokenStream in) throws IOException
- {
- initStack();
- do {
- Symbol token = in.nextToken();
- while (true)
- {
- short act = tables.findParserAction(states[top], token.id);
- if (act > 0)
- {
- shift(act);
- break;
- }
- else if (act == accept_action_id)
- {
- return true;
- }
- else if (act < 0)
- {
- short nt_id = reduce(~act);
-
- act = tables.findNextState(states[top], nt_id);
- if (act > 0)
- shift(act);
- else
- return act == accept_action_id;
- }
- else // act == 0, i.e. this is an error
- {
- return false;
- }
- }
- }
- while (!in.isFull());
- return true;
- }
-
- private void initStack() throws IOException
- {
- if (states == null || states.length < Parser.this.states.length)
- {
- states = new short[Parser.this.states.length];
- min_top = 0;
- }
- System.arraycopy(Parser.this.states, min_top, states, min_top, (top = Parser.this.top) + 1);
- }
-
- private void increaseStackCapacity()
- {
- short[] new_states = new short[states.length * 2];
- System.arraycopy(states, 0, new_states, 0, states.length);
- states = new_states;
- }
-
- private void shift(short state)
- {
- if (++top == states.length)
- increaseStackCapacity();
- states[top] = state;
- }
-
- private short reduce(int rule_id)
- {
- int rule_info = tables.rule_infos[rule_id];
- int rhs_size = rule_info & 0xFFFF;
- top -= rhs_size;
- min_top = Math.min(min_top, top);
- return (short) (rule_info >>> 16);
- }
- }
-
- /** The automaton tables. */
- protected final ParsingTables tables;
-
- /** Cached ID of the ACCEPT action. */
- protected final short accept_action_id;
-
- /** The parser's stack. */
- protected short[] states;
-
- /** Index of the stack's top element, i.e. it's = -1 when the stack is empty; */
- protected int top;
-
- /** The stack of shifted symbols. */
- protected Symbol[] _symbols;
-
- /** Parsing events notification "gateway" */
- protected Events report;
-
-
- protected Parser(ParsingTables tables)
- {
- this.tables = tables;
- this.accept_action_id = (short) ~tables.rule_infos.length;
- this.states = new short[256];
- }
-
- /**
- * Parses a source and returns a semantic value of the accepted nonterminal
- *
- * @param source of tokens - a Scanner
- * @return semantic value of the accepted nonterminal
- */
- public Object parse(Scanner source) throws IOException, Parser.Exception
- {
- init();
- return parse(new TokenStream(source));
- }
-
- /**
- * Parses a source and returns a semantic value of the accepted nonterminal.
- * Before parsing starts injects alternative goal marker into the source to
- * indicate that an alternative goal should be matched.
- *
- * @param source of tokens - a Scanner
- * @param alt_goal_marker_id ID of a token like symbol that will be used as a marker
- * @return semantic value of the accepted nonterminal
- */
- public Object parse(Scanner source, short alt_goal_marker_id) throws IOException, Parser.Exception
- {
- init();
- TokenStream in = new TokenStream(source, new Symbol(alt_goal_marker_id));
- return parse(in);
- }
-
- private Object parse(TokenStream in) throws IOException, Parser.Exception
- {
- while (true)
- {
- Symbol token = in.nextToken();
- while (true)
- {
- short act = tables.findParserAction(states[top], token.id);
- if (act > 0)
- {
- shift(token, act);
- break;
- }
- else if (act == accept_action_id)
- {
- Symbol goal = _symbols[top];
- _symbols = null; // drop this stack to prevent loitering
- return goal.value;
- }
- else if (act < 0)
- {
- Symbol nt = reduce(~act);
- act = tables.findNextState(states[top], nt.id);
- if (act > 0)
- {
- shift(nt, act);
- }
- else if (act == accept_action_id)
- {
- _symbols = null; // no loitering
- return nt.value;
- }
- else
- {
- throw new IllegalStateException("Cannot shift a nonterminal");
- }
- }
- else // act == 0, i.e. this is an error
- {
- report.syntaxError(token);
- recoverFromError(token, in);
- break; // because error recovery altered token stream - parser needs to refetch the next token
- }
- }
- }
- }
-
- /**
- * Invoke actual reduce action routine.
- * Method must be implemented by a generated parser
- *
- * @param rule_num ID of a reduce action routine to invoke
- * @param offset to the symbol before first action routine argument
- * @return reduced nonterminal
- */
- protected abstract Symbol invokeReduceAction(int rule_num, int offset);
-
- /**
- * Performs stacks and, if not initialized yet, reduce actions array initialization.
- */
- private void init()
- {
- if (report == null)
- report = new Events();
-
- _symbols = new Symbol[states.length];
- top = 0; // i.e. it's not empty
- _symbols[top] = new Symbol("none"); // need a symbol here for a default reduce on the very first erroneous token
- states[top] = 1; // initial/first state
- }
-
- /**
- * Increases the stack capacity if it has no room for new entries.
- */
- private void increaseStackCapacity()
- {
- short[] new_states = new short[states.length * 2];
- System.arraycopy(states, 0, new_states, 0, states.length);
- states = new_states;
-
- Symbol[] new_stack = new Symbol[states.length];
- System.arraycopy(_symbols, 0, new_stack, 0, _symbols.length);
- _symbols = new_stack;
- }
-
- /**
- * Shift a symbol to stack and go to a new state
- *
- * @param sym
- * symbol that will be shifted
- * @param goto_state
- * to switch to
- */
- private void shift(Symbol sym, short goto_state)
- {
- if (++top == states.length)
- increaseStackCapacity();
- _symbols[top] = sym;
- states[top] = goto_state;
- }
-
- /**
- * Perform a reduce action.
- *
- * @param rule_id
- * Number of the production by which to reduce
- * @return nonterminal created by a reduction
- */
- private Symbol reduce(int rule_id)
- {
- int rule_info = tables.rule_infos[rule_id];
- int rhs_size = rule_info & 0xFFFF;
-
- top -= rhs_size;
- Symbol lhs_sym = invokeReduceAction(rule_id, top);
- lhs_sym.id = (short) (rule_info >>> 16);
- if (rhs_size == 0)
- {
- lhs_sym.start = lhs_sym.end = _symbols[top].end;
- }
- else
- {
- lhs_sym.start = _symbols[top + 1].start;
- lhs_sym.end = _symbols[top + rhs_size].end;
- }
- return lhs_sym;
- }
-
- /**
- * Implements parsing error recovery. Tries several simple approches first, like deleting "bad" token
- * or replacing the latter with one of the expected (if possible). If simple methods have not worked
- * out, tries to do error phrase recovery.
- *
- * It is expected that normally descendand parsers do not need to alter this method. In same cases though
- * they may want to override it if they need a different error recovery strategy.
- *
- * @param token a lookahead terminal symbol that messed parsing
- * @param in token stream
- * @throws IOException propagated from a scanner if it has issues with the source
- * @throws Parser.Exception if Parser cannot recover
- */
- protected void recoverFromError(Symbol token, TokenStream in) throws IOException, Parser.Exception
- {
- if (token.id == 0) // end of input
- throw new Parser.Exception("Cannot recover from the syntax error");
-
- in.setMode(TokenStream.BUFFER);
-
- Simulator sim = new Simulator();
- short current_state = states[top];
- if (!tables.compressed) // then we can try "insert missing" and "replace unexpected" recoveries
- {
- short first_term_id = tables.findFirstTerminal(current_state);
- if (first_term_id >= 0)
- {
- Symbol term = new Symbol(first_term_id, _symbols[top].end, token.start);
- in.enque(term); // insert expected terminal before the unexpected one
- in.enque(token);
- if (sim.parse(in))
- {
- in.rewind();
- in.setMode(TokenStream.FLUSH);
- report.missingTokenInserted(term);
- return;
- }
- in.rewind();
-
- int offset = tables.actn_offsets[current_state];
-
- for (short term_id = (short) (first_term_id + 1); term_id < tables.n_term; term_id++)
- {
- int index = offset + term_id;
- if (index >= tables.lookaheads.length)
- break;
- if (tables.lookaheads[index] == term_id)
- {
- term.id = term_id;
- if (sim.parse(in))
- {
- in.rewind();
- in.setMode(TokenStream.FLUSH);
- report.missingTokenInserted(term);
- return;
- }
- in.rewind();
- }
- }
- in.remove(1); // alter stream as if an expected terminal replaced the unexpected one
-
- term.start = token.start;
- term.end = token.end;
-
- for (short term_id = first_term_id; term_id < tables.n_term; term_id++)
- {
- int index = offset + term_id;
- if (index >= tables.lookaheads.length)
- break;
- if (tables.lookaheads[index] == term_id)
- {
- term.id = term_id;
- if (sim.parse(in))
- {
- in.rewind();
- in.setMode(TokenStream.FLUSH);
- report.misspelledTokenReplaced(term);
- return;
- }
- in.rewind();
- }
- }
- in.remove(0); // simple recoveries failed - remove all stream changes
- }
- }
- // finally try parsing without the unexpected token (as if it was "deleted")
- if (sim.parse(in))
- {
- in.rewind();
- in.setMode(TokenStream.FLUSH);
- report.unexpectedTokenRemoved(token);
- return;
- }
- in.rewind();
-
- // Simple recoveries failed or are not applicable. Next step is an error phrase recovery.
- /*
- * Find a state where parser can shift "error" symbol. Discard already reduced (and shifted)
- * productions, which are part of a phrase where unexpected terminal is found. (Note that if
- * "error" symbol was not used by a grammar, in the end the entire input becomes an error phrase,
- * and ... parser won't recover from it :)
- */
- Symbol first_sym = token, last_sym = token;
- short goto_state;
- while ((goto_state = tables.findNextState(states[top], tables.error_symbol_id)) <= 0)
- {
- // parser cannot shift "error" in this state, so use the top symbol
- // as the leftmost symbol of an error phrase
- first_sym = _symbols[top];
- // and go to the previous state
- if (--top < 0)
- throw new Parser.Exception("Cannot recover from the syntax error");
- }
- Symbol error = new Symbol(tables.error_symbol_id, first_sym.start, last_sym.end); // the end is temporary
- shift(error, goto_state);
-
- while (!sim.parse(in))
- {
- in.rewind();
- if (in.peek().id == 0) // EOF
- throw new Parser.Exception("Cannot recover from the syntax error");
- in.remove(0);
- }
- in.rewind();
- error.end = in.peek().end;
- in.setMode(TokenStream.FLUSH);
- report.errorPhraseRemoved(error);
- }
+ static public class Exception extends java.lang.Exception
+ {
+ Exception(String msg)
+ {
+ super(msg);
+ }
+ }
+
+ /**
+ * This class "lists" reportable events that might happen during parsing.
+ */
+ static public class Events
+ {
+ public void scannerError(Scanner.Exception e)
+ {
+ System.err.print("Scanner Error:");
+ if (e.line > 0)
+ {
+ System.err.print(e.line);
+ System.err.print(',');
+ System.err.print(e.column);
+ System.err.print(':');
+ }
+ System.err.print(' ');
+ System.err.println(e.getMessage());
+ }
+ public void syntaxError(Symbol token)
+ {
+ System.err.print(Symbol.getLine(token.start));
+ System.err.print(',');
+ System.err.print(Symbol.getColumn(token.start));
+ System.err.print('-');
+ System.err.print(Symbol.getLine(token.end));
+ System.err.print(',');
+ System.err.print(Symbol.getColumn(token.end));
+ System.err.print(": Syntax Error: unexpected token ");
+ if (token.value != null)
+ {
+ System.err.print('"');
+ System.err.print(token.value);
+ System.err.println('"');
+ }
+ else
+ {
+ System.err.print('#');
+ System.err.println(token.id);
+ }
+ }
+ public void unexpectedTokenRemoved(Symbol token)
+ {
+ System.err.print(Symbol.getLine(token.start));
+ System.err.print(',');
+ System.err.print(Symbol.getColumn(token.start));
+ System.err.print('-');
+ System.err.print(Symbol.getLine(token.end));
+ System.err.print(',');
+ System.err.print(Symbol.getColumn(token.end));
+ System.err.print(": Recovered: removed unexpected token ");
+ if (token.value != null)
+ {
+ System.err.print('"');
+ System.err.print(token.value);
+ System.err.println('"');
+ }
+ else
+ {
+ System.err.print('#');
+ System.err.println(token.id);
+ }
+ }
+ public void missingTokenInserted(Symbol token)
+ {
+ System.err.print(Symbol.getLine(token.start));
+ System.err.print(',');
+ System.err.print(Symbol.getColumn(token.start));
+ System.err.print('-');
+ System.err.print(Symbol.getLine(token.end));
+ System.err.print(',');
+ System.err.print(Symbol.getColumn(token.end));
+ System.err.print(": Recovered: inserted missing token ");
+ if (token.value != null)
+ {
+ System.err.print('"');
+ System.err.print(token.value);
+ System.err.println('"');
+ }
+ else
+ {
+ System.err.print('#');
+ System.err.println(token.id);
+ }
+ }
+ public void misspelledTokenReplaced(Symbol token)
+ {
+ System.err.print(Symbol.getLine(token.start));
+ System.err.print(',');
+ System.err.print(Symbol.getColumn(token.start));
+ System.err.print('-');
+ System.err.print(Symbol.getLine(token.end));
+ System.err.print(',');
+ System.err.print(Symbol.getColumn(token.end));
+ System.err.print(": Recovered: replaced unexpected token with ");
+ if (token.value != null)
+ {
+ System.err.print('"');
+ System.err.print(token.value);
+ System.err.println('"');
+ }
+ else
+ {
+ System.err.print('#');
+ System.err.println(token.id);
+ }
+ }
+ public void errorPhraseRemoved(Symbol error)
+ {
+ System.err.print(Symbol.getLine(error.start));
+ System.err.print(',');
+ System.err.print(Symbol.getColumn(error.start));
+ System.err.print('-');
+ System.err.print(Symbol.getLine(error.end));
+ System.err.print(',');
+ System.err.print(Symbol.getColumn(error.end));
+ System.err.println(": Recovered: removed error phrase");
+ }
+ }
+
+ /**
+ * This class wrapps a Scanner and provides a token "accumulator" for a parsing simulation.
+ * <p>If a source that is being parsed does not have syntax errors this wrapper only adds
+ * one indirection while it delivers the next token. However when parser needs to recover
+ * from a syntax error this wrapper accumulates tokens shifted by a forward parsing simulation
+ * and later feeds them to the recovered parser.
+ */
+ public class TokenStream
+ {
+ public static final boolean BUFFER = true;
+ public static final boolean FLUSH = false;
+
+ private static final int BUF_SIZE = 4;
+ private static final int IDX_MASK = BUF_SIZE - 1;
+
+ private Scanner scanner;
+ private Symbol[] buffer;
+ private int idx_add;
+ private int idx_get;
+ private int ix_mark;
+
+ public TokenStream(Scanner scanner)
+ {
+ this.scanner = scanner;
+ this.buffer = new Symbol[BUF_SIZE];
+ this.ix_mark = -1;
+ }
+
+ public void setMode(boolean buffering)
+ {
+ ix_mark = (buffering ? idx_get : -1);
+ }
+
+ public boolean isBuffering()
+ {
+ return ix_mark >= 0;
+ }
+
+ public boolean isEmpty()
+ {
+ return idx_get == idx_add;
+ }
+
+ public boolean isFull()
+ {
+ return ((idx_add + 1) & IDX_MASK) == (isBuffering() ? ix_mark : idx_get);
+ }
+
+ public int size()
+ {
+ return (idx_add - idx_get + BUF_SIZE) & IDX_MASK;
+ }
+
+ public void enque(Symbol symbol)
+ {
+ if (isFull())
+ throw new IllegalStateException ("buffer is full");
+ buffer[idx_add++] = symbol;
+ idx_add &= IDX_MASK;
+ }
+
+ public Symbol peek()
+ {
+ if (isEmpty())
+ throw new IllegalStateException ("buffer is empty");
+ return buffer[idx_get];
+ }
+
+ public Symbol deque()
+ {
+ if (isEmpty())
+ throw new IllegalStateException ("buffer is empty");
+ Symbol symbol = buffer[idx_get++];
+ idx_get &= IDX_MASK;
+ return symbol;
+ }
+
+ public TokenStream(Scanner scanner, Symbol first_symbol)
+ {
+ this(scanner);
+ enque(first_symbol);
+ }
+
+ public Symbol nextToken() throws IOException
+ {
+ if (isBuffering())
+ {
+ if (isEmpty())
+ {
+ enque(readToken());
+ }
+ return deque();
+ }
+ else
+ {
+ return (isEmpty() ? readToken() : deque());
+ }
+ }
+
+ /**
+ * Prepare accumulated tokens to be reread by a next simulation run
+ * or by a recovered parser.
+ */
+ public void rewind()
+ {
+ if (!isBuffering())
+ throw new IllegalStateException ("stream is not buffering");
+ idx_get = ix_mark;
+ }
+
+ /**
+ * Removes a symbol from the buffer.
+ */
+ public void remove(int offset)
+ {
+ if (!isBuffering())
+ throw new IllegalStateException ("stream is not buffering");
+ switch (offset)
+ {
+ case 0:
+ deque();
+ ix_mark = idx_get;
+ break;
+ case 1:
+ Symbol s0 = deque();
+ buffer[idx_get] = s0;
+ ix_mark = idx_get;
+ break;
+ default:
+ throw new IllegalStateException ("unsupported offset");
+ }
+ }
+
+ /**
+ * Reads next recognized token from the scanner. If scanner fails to recognize a token and
+ * throws an exception it will be reported via Parser.scannerError().
+ * <p>It is expected that scanner is capable of returning at least an EOF token after the
+ * exception.</p>
+ *
+ * @return next recognized token
+ * @throws IOException
+ * as thrown by a scanner
+ */
+ private Symbol readToken() throws IOException
+ {
+ while (true)
+ {
+ try
+ {
+ return scanner.nextToken();
+ }
+ catch (Scanner.Exception e)
+ {
+ report.scannerError(e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Simulator is a stripped (of action code) version of a parser that will try to parse ahead
+ * token stream after a syntax error. The simulation is considered successful if 3 tokens were
+ * shifted successfully. If during simulation this parser enconters an error it drops the first
+ * token it tried to use and restarts the simulated parsing.
+ * <p>
+ * Note: Without a special "error" rule present in a grammar, which a parser will try to shift
+ * at the beginning of an error recovery, simulation continues without removing anything from
+ * the original states stack. This often will lead to cases when no parsing ahead will recover
+ * the parser from a syntax error.
+ * </p>
+ */
+ public class Simulator
+ {
+ private short[] states;
+ private int top, min_top;
+
+ public boolean parse(TokenStream in) throws IOException
+ {
+ initStack();
+ do {
+ Symbol token = in.nextToken();
+ while (true)
+ {
+ short act = tables.findParserAction(states[top], token.id);
+ if (act > 0)
+ {
+ shift(act);
+ break;
+ }
+ else if (act == accept_action_id)
+ {
+ return true;
+ }
+ else if (act < 0)
+ {
+ short nt_id = reduce(~act);
+
+ act = tables.findNextState(states[top], nt_id);
+ if (act > 0)
+ shift(act);
+ else
+ return act == accept_action_id;
+ }
+ else // act == 0, i.e. this is an error
+ {
+ return false;
+ }
+ }
+ }
+ while (!in.isFull());
+ return true;
+ }
+
+ private void initStack() throws IOException
+ {
+ if (states == null || states.length < Parser.this.states.length)
+ {
+ states = new short[Parser.this.states.length];
+ min_top = 0;
+ }
+ System.arraycopy(Parser.this.states, min_top, states, min_top, (top = Parser.this.top) + 1);
+ }
+
+ private void increaseStackCapacity()
+ {
+ short[] new_states = new short[states.length * 2];
+ System.arraycopy(states, 0, new_states, 0, states.length);
+ states = new_states;
+ }
+
+ private void shift(short state)
+ {
+ if (++top == states.length)
+ increaseStackCapacity();
+ states[top] = state;
+ }
+
+ private short reduce(int rule_id)
+ {
+ int rule_info = tables.rule_infos[rule_id];
+ int rhs_size = rule_info & 0xFFFF;
+ top -= rhs_size;
+ min_top = Math.min(min_top, top);
+ return (short) (rule_info >>> 16);
+ }
+ }
+
+ /** The automaton tables. */
+ protected final ParsingTables tables;
+
+ /** Cached ID of the ACCEPT action. */
+ protected final short accept_action_id;
+
+ /** The parser's stack. */
+ protected short[] states;
+
+ /** Index of the stack's top element, i.e. it's = -1 when the stack is empty; */
+ protected int top;
+
+ /** The stack of shifted symbols. */
+ protected Symbol[] _symbols;
+
+ /** Parsing events notification "gateway" */
+ protected Events report;
+
+
+ protected Parser(ParsingTables tables)
+ {
+ this.tables = tables;
+ this.accept_action_id = (short) ~tables.rule_infos.length;
+ this.states = new short[256];
+ }
+
+ /**
+ * Parses a source and returns a semantic value of the accepted nonterminal
+ *
+ * @param source of tokens - a Scanner
+ * @return semantic value of the accepted nonterminal
+ */
+
+ public Object parse(Scanner source) throws IOException, Parser.Exception
+ {
+ init();
+ return parse(new TokenStream(source));
+ }
+
+ /**
+ * Parses a source and returns a semantic value of the accepted nonterminal.
+ * Before parsing starts injects alternative goal marker into the source to
+ * indicate that an alternative goal should be matched.
+ *
+ * @param source of tokens - a Scanner
+ * @param alt_goal_marker_id ID of a token like symbol that will be used as a marker
+ * @return semantic value of the accepted nonterminal
+ */
+ public Object parse(Scanner source, short alt_goal_marker_id) throws IOException, Parser.Exception
+ {
+ init();
+ TokenStream in = new TokenStream(source, new Symbol(alt_goal_marker_id));
+ return parse(in);
+ }
+
+ private Object parse(TokenStream in) throws IOException, Parser.Exception
+ {
+ while (true)
+ {
+ Symbol token = in.nextToken();
+ while (true)
+ {
+ short act = tables.findParserAction(states[top], token.id);
+ if (act > 0)
+ {
+ shift(token, act);
+ break;
+ }
+ else if (act == accept_action_id)
+ {
+ Symbol goal = _symbols[top];
+ _symbols = null; // drop this stack to prevent loitering
+ return goal.value;
+ }
+ else if (act < 0)
+ {
+ Symbol nt = reduce(~act);
+ act = tables.findNextState(states[top], nt.id);
+ if (act > 0)
+ {
+ shift(nt, act);
+ }
+ else if (act == accept_action_id)
+ {
+ _symbols = null; // no loitering
+ return nt.value;
+ }
+ else
+ {
+ throw new IllegalStateException("Cannot shift a nonterminal");
+ }
+ }
+ else // act == 0, i.e. this is an error
+ {
+ report.syntaxError(token);
+ recoverFromError(token, in);
+ break; // because error recovery altered token stream - parser needs to refetch the next token
+ }
+ }
+ }
+ }
+
+ /**
+ * Invoke actual reduce action routine.
+ * Method must be implemented by a generated parser
+ *
+ * @param rule_num ID of a reduce action routine to invoke
+ * @param offset to the symbol before first action routine argument
+ * @return reduced nonterminal
+ */
+ protected abstract Symbol invokeReduceAction(int rule_num, int offset);
+
+ /**
+ * Performs stacks and, if not initialized yet, reduce actions array initialization.
+ */
+ private void init()
+ {
+ if (report == null)
+ report = new Events();
+
+ _symbols = new Symbol[states.length];
+ top = 0; // i.e. it's not empty
+ _symbols[top] = new Symbol("none"); // need a symbol here for a default reduce on the very first erroneous token
+ states[top] = 1; // initial/first state
+ }
+
+ /**
+ * Increases the stack capacity if it has no room for new entries.
+ */
+ private void increaseStackCapacity()
+ {
+ short[] new_states = new short[states.length * 2];
+ System.arraycopy(states, 0, new_states, 0, states.length);
+ states = new_states;
+
+ Symbol[] new_stack = new Symbol[states.length];
+ System.arraycopy(_symbols, 0, new_stack, 0, _symbols.length);
+ _symbols = new_stack;
+ }
+
+ /**
+ * Shift a symbol to stack and go to a new state
+ *
+ * @param sym
+ * symbol that will be shifted
+ * @param goto_state
+ * to switch to
+ */
+ private void shift(Symbol sym, short goto_state)
+ {
+ if (++top == states.length)
+ increaseStackCapacity();
+ _symbols[top] = sym;
+ states[top] = goto_state;
+ }
+
+ /**
+ * Perform a reduce action.
+ *
+ * @param rule_id
+ * Number of the production by which to reduce
+ * @return nonterminal created by a reduction
+ */
+ private Symbol reduce(int rule_id)
+ {
+ int rule_info = tables.rule_infos[rule_id];
+ int rhs_size = rule_info & 0xFFFF;
+
+ top -= rhs_size;
+ Symbol lhs_sym = invokeReduceAction(rule_id, top);
+ lhs_sym.id = (short) (rule_info >>> 16);
+ if (rhs_size == 0)
+ {
+ lhs_sym.start = lhs_sym.end = _symbols[top].end;
+ }
+ else
+ {
+ lhs_sym.start = _symbols[top + 1].start;
+ lhs_sym.end = _symbols[top + rhs_size].end;
+ }
+ return lhs_sym;
+ }
+
+ /**
+ * Implements parsing error recovery. Tries several simple approches first, like deleting "bad" token
+ * or replacing the latter with one of the expected (if possible). If simple methods have not worked
+ * out, tries to do error phrase recovery.
+ *
+ * It is expected that normally descendand parsers do not need to alter this method. In same cases though
+ * they may want to override it if they need a different error recovery strategy.
+ *
+ * @param token a lookahead terminal symbol that messed parsing
+ * @param in token stream
+ * @throws IOException propagated from a scanner if it has issues with the source
+ * @throws Parser.Exception if Parser cannot recover
+ */
+ protected void recoverFromError(Symbol token, TokenStream in) throws IOException, Parser.Exception
+ {
+ if (token.id == 0) // end of input
+ throw new Parser.Exception("Cannot recover from the syntax error");
+
+ in.setMode(TokenStream.BUFFER);
+
+ Simulator sim = new Simulator();
+ short current_state = states[top];
+ if (!tables.compressed) // then we can try "insert missing" and "replace unexpected" recoveries
+ {
+ short first_term_id = tables.findFirstTerminal(current_state);
+ if (first_term_id >= 0)
+ {
+ Symbol term = new Symbol(first_term_id, _symbols[top].end, token.start);
+ in.enque(term); // insert expected terminal before the unexpected one
+ in.enque(token);
+ if (sim.parse(in))
+ {
+ in.rewind();
+ in.setMode(TokenStream.FLUSH);
+ report.missingTokenInserted(term);
+ return;
+ }
+ in.rewind();
+
+ int offset = tables.actn_offsets[current_state];
+
+ for (short term_id = (short) (first_term_id + 1); term_id < tables.n_term; term_id++)
+ {
+ int index = offset + term_id;
+ if (index >= tables.lookaheads.length)
+ break;
+ if (tables.lookaheads[index] == term_id)
+ {
+ term.id = term_id;
+ if (sim.parse(in))
+ {
+ in.rewind();
+ in.setMode(TokenStream.FLUSH);
+ report.missingTokenInserted(term);
+ return;
+ }
+ in.rewind();
+ }
+ }
+ in.remove(1); // alter stream as if an expected terminal replaced the unexpected one
+
+ term.start = token.start;
+ term.end = token.end;
+
+ for (short term_id = first_term_id; term_id < tables.n_term; term_id++)
+ {
+ int index = offset + term_id;
+ if (index >= tables.lookaheads.length)
+ break;
+ if (tables.lookaheads[index] == term_id)
+ {
+ term.id = term_id;
+ if (sim.parse(in))
+ {
+ in.rewind();
+ in.setMode(TokenStream.FLUSH);
+ report.misspelledTokenReplaced(term);
+ return;
+ }
+ in.rewind();
+ }
+ }
+ in.remove(0); // simple recoveries failed - remove all stream changes
+ }
+ }
+ // finally try parsing without the unexpected token (as if it was "deleted")
+ if (sim.parse(in))
+ {
+ in.rewind();
+ in.setMode(TokenStream.FLUSH);
+ report.unexpectedTokenRemoved(token);
+ return;
+ }
+ in.rewind();
+
+ // Simple recoveries failed or are not applicable. Next step is an error phrase recovery.
+ /*
+ * Find a state where parser can shift "error" symbol. Discard already reduced (and shifted)
+ * productions, which are part of a phrase where unexpected terminal is found. (Note that if
+ * "error" symbol was not used by a grammar, in the end the entire input becomes an error phrase,
+ * and ... parser won't recover from it :)
+ */
+ Symbol first_sym = token, last_sym = token;
+ short goto_state;
+ while ((goto_state = tables.findNextState(states[top], tables.error_symbol_id)) <= 0)
+ {
+ // parser cannot shift "error" in this state, so use the top symbol
+ // as the leftmost symbol of an error phrase
+ first_sym = _symbols[top];
+ // and go to the previous state
+ if (--top < 0)
+ throw new Parser.Exception("Cannot recover from the syntax error");
+ }
+ Symbol error = new Symbol(tables.error_symbol_id, first_sym.start, last_sym.end); // the end is temporary
+ shift(error, goto_state);
+
+ while (!sim.parse(in))
+ {
+ in.rewind();
+ if (in.peek().id == 0) // EOF
+ throw new Parser.Exception("Cannot recover from the syntax error");
+ in.remove(0);
+ }
+ in.rewind();
+ error.end = in.peek().end;
+ in.setMode(TokenStream.FLUSH);
+ report.errorPhraseRemoved(error);
+ }
}
View
12 src/org/jruby/lexer/JavaSignatureBeaverLexer.flex
@@ -21,9 +21,7 @@ import org.jruby.parser.JavaSignatureBeaverParser.Terminals;
%line
%column
%{
- public static java.io.InputStream create(java.io.InputStream stream) {
- return (stream);
- }
+
boolean stringResult = false;
boolean characterResult = false;
@@ -53,6 +51,10 @@ import org.jruby.parser.JavaSignatureBeaverParser.Terminals;
{
return new Symbol(id, yyline + 1, yycolumn + 1, yylength(), value);
}
+ public static JavaSignatureBeaverLexer create(java.io.InputStream stream) {
+ return new JavaSignatureBeaverLexer(stream);
+ }
+
%}
@@ -64,8 +66,8 @@ Identifier = [:jletter:] [:jletterdigit:]*
//UnicodeEscape = "\\u" {HexDigit} {HexDigit} {HexDigit} {HexDigit}
//EscapedChar = "\\" [nybrf\\'\"]
//NonEscapedChar = [^nybrf\\'\"]
-CharacterLiteral = "'" ({NonEscapedChar} | {EscapedChar} | {UnicodeEscape}) "'"
-StringLiteral = "\"" ({NonEscapedChar} | {EscapedChar} | {UnicodeEscape})* "\""
+//CharacterLiteral = "'" ({NonEscapedChar} | {EscapedChar} | {UnicodeEscape}) "'"
+//StringLiteral = "\"" ({NonEscapedChar} | {EscapedChar} | {UnicodeEscape})* "\""
%state CHARACTER
%state STRING
View
318 src/org/jruby/lexer/JavaSignatureBeaverLexer.java
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.3 on 6/21/12 1:15 PM */
+/* The following code was generated by JFlex 1.4.3 on 6/26/12 1:48 AM */
package org.jruby.lexer;
@@ -11,7 +11,7 @@
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
- * on 6/21/12 1:15 PM from the specification file
+ * on 6/26/12 1:48 AM from the specification file
* <tt>/home/chaitanya/projects/jruby/src/org/jruby/lexer/JavaSignatureBeaverLexer.flex</tt>
*/
public class JavaSignatureBeaverLexer extends Scanner {
@@ -42,12 +42,12 @@
*/
private static final String ZZ_CMAP_PACKED =
"\11\5\1\3\1\2\1\0\1\3\1\1\16\5\4\0\1\3\1\0"+
- "\1\7\1\0\1\4\1\0\1\35\1\6\1\44\1\45\2\0\1\37"+
- "\1\0\1\36\1\0\12\5\2\0\1\51\1\41\1\52\1\50\1\34"+
- "\32\4\1\46\1\55\1\47\1\0\1\4\1\0\1\14\1\10\1\25"+
- "\1\27\1\13\1\26\1\24\1\21\1\23\2\4\1\12\1\4\1\15"+
- "\1\11\1\32\1\4\1\22\1\20\1\17\1\30\1\31\1\53\1\54"+
- "\1\16\1\33\1\42\1\0\1\43\1\0\41\5\2\0\4\4\4\0"+
+ "\1\53\1\0\1\4\1\0\1\33\1\54\1\42\1\43\2\0\1\35"+
+ "\1\0\1\34\1\0\12\5\2\0\1\47\1\37\1\50\1\46\1\32"+
+ "\32\4\1\44\1\55\1\45\1\0\1\4\1\0\1\12\1\6\1\23"+
+ "\1\25\1\11\1\24\1\22\1\17\1\21\2\4\1\10\1\4\1\13"+
+ "\1\7\1\30\1\4\1\20\1\16\1\15\1\26\1\27\1\51\1\52"+
+ "\1\14\1\31\1\40\1\0\1\41\1\0\41\5\2\0\4\4\4\0"+
"\1\4\2\0\1\5\7\0\1\4\4\0\1\4\5\0\27\4\1\0"+
"\37\4\1\0\u013f\4\31\0\162\4\4\0\14\4\16\0\5\4\11\0"+
"\1\4\21\0\130\5\5\0\23\5\12\0\1\4\13\0\1\4\1\0"+
@@ -112,7 +112,7 @@
"\2\0\6\4\2\0\46\4\2\0\6\4\2\0\10\4\1\0\1\4"+
"\1\0\1\4\1\0\1\4\1\0\37\4\2\0\65\4\1\0\7\4"+
"\1\0\1\4\3\0\3\4\1\0\7\4\3\0\4\4\2\0\6\4"+
- "\4\0\15\4\5\0\3\4\1\0\7\4\17\0\4\5\26\0\1\40"+
+ "\4\0\15\4\5\0\3\4\1\0\7\4\17\0\4\5\26\0\1\36"+
"\3\0\5\5\20\0\2\4\23\0\1\4\13\0\4\5\6\0\6\5"+
"\1\0\1\4\15\0\1\4\40\0\22\4\36\0\15\5\4\0\1\5"+
"\3\0\6\5\27\0\1\4\4\0\1\4\2\0\12\4\1\0\1\4"+
@@ -141,16 +141,15 @@
private static final int [] ZZ_ACTION = zzUnpackAction();
private static final String ZZ_ACTION_PACKED_0 =
- "\3\0\1\1\2\2\1\3\1\4\1\5\15\3\1\6"+
- "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1\16"+
- "\1\17\1\20\1\21\1\22\1\23\1\24\1\25\1\26"+
- "\1\27\1\30\1\31\24\3\1\0\1\32\1\33\1\34"+
- "\1\35\1\36\15\3\1\37\11\3\1\40\1\3\1\41"+
- "\1\42\12\3\1\43\4\3\1\44\14\3\1\45\1\46"+
- "\1\47\1\50\10\3\1\51\1\52\2\3\1\53\1\3"+
- "\1\54\3\3\1\55\1\56\1\57\6\3\1\60\1\61"+
- "\2\3\1\62\1\63\1\3\1\64\1\3\1\65\2\3"+
- "\1\66";
+ "\3\0\1\1\2\2\16\3\1\4\1\5\1\6\1\7"+
+ "\1\10\1\11\1\12\1\13\1\14\1\15\1\16\1\17"+
+ "\1\20\1\21\1\22\1\23\1\24\1\25\1\26\1\27"+
+ "\1\30\1\31\24\3\1\0\1\32\1\33\1\34\1\35"+
+ "\1\36\15\3\1\37\11\3\1\40\1\3\1\41\1\42"+
+ "\12\3\1\43\4\3\1\44\14\3\1\45\1\46\1\47"+
+ "\1\50\10\3\1\51\1\52\2\3\1\53\1\3\1\54"+
+ "\3\3\1\55\1\56\1\57\6\3\1\60\1\61\2\3"+
+ "\1\62\1\63\1\3\1\64\1\3\1\65\2\3\1\66";
private static int [] zzUnpackAction() {
int [] result = new int[167];
@@ -178,11 +177,11 @@ private static int zzUnpackAction(String packed, int offset, int [] result) {
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
- "\0\0\0\56\0\134\0\212\0\270\0\212\0\346\0\212"+
- "\0\212\0\u0114\0\u0142\0\u0170\0\u019e\0\u01cc\0\u01fa\0\u0228"+
- "\0\u0256\0\u0284\0\u02b2\0\u02e0\0\u030e\0\u033c\0\212\0\212"+
- "\0\u036a\0\212\0\212\0\212\0\212\0\212\0\212\0\212"+
- "\0\212\0\212\0\212\0\212\0\u0398\0\212\0\212\0\u03c6"+
+ "\0\0\0\56\0\134\0\212\0\270\0\212\0\346\0\u0114"+
+ "\0\u0142\0\u0170\0\u019e\0\u01cc\0\u01fa\0\u0228\0\u0256\0\u0284"+
+ "\0\u02b2\0\u02e0\0\u030e\0\u033c\0\212\0\212\0\u036a\0\212"+
+ "\0\212\0\212\0\212\0\212\0\212\0\212\0\212\0\212"+
+ "\0\212\0\212\0\u0398\0\212\0\212\0\212\0\212\0\u03c6"+
"\0\212\0\u03f4\0\u0422\0\u0450\0\u047e\0\u04ac\0\u04da\0\u0508"+
"\0\u0536\0\u0564\0\u0592\0\u05c0\0\u05ee\0\u061c\0\u064a\0\u0678"+
"\0\u06a6\0\u06d4\0\u0702\0\u0730\0\u075e\0\u078c\0\u07ba\0\u07e8"+
@@ -224,127 +223,100 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) {
private static final int [] ZZ_TRANS = zzUnpackTrans();
private static final String ZZ_TRANS_PACKED_0 =
- "\1\4\1\5\2\6\1\7\1\4\1\10\1\11\1\12"+
- "\1\7\1\13\1\14\1\15\1\16\1\7\1\17\1\20"+
- "\2\7\1\21\1\7\1\22\1\23\1\24\1\7\1\25"+
- "\1\26\1\7\1\27\1\30\1\31\1\32\1\33\1\34"+
- "\1\35\1\36\1\37\1\40\1\41\1\42\1\43\1\44"+
- "\1\45\2\7\1\4\2\46\1\4\3\46\1\47\47\46"+
- "\1\50\2\4\4\50\1\51\45\50\1\52\60\0\1\6"+
- "\57\0\2\7\2\0\24\7\17\0\2\7\5\0\2\7"+
- "\2\0\1\7\1\53\4\7\1\54\15\7\17\0\2\7"+
- "\5\0\2\7\2\0\1\7\1\55\22\7\17\0\2\7"+
- "\5\0\2\7\2\0\24\7\17\0\1\7\1\56\5\0"+
- "\2\7\2\0\1\57\23\7\17\0\2\7\5\0\2\7"+
- "\2\0\4\7\1\60\17\7\17\0\2\7\5\0\2\7"+
- "\2\0\11\7\1\61\1\62\11\7\17\0\2\7\5\0"+
- "\2\7\2\0\6\7\1\63\1\64\1\7\1\65\6\7"+
- "\1\66\3\7\17\0\2\7\5\0\2\7\2\0\5\7"+
- "\1\67\16\7\17\0\2\7\5\0\2\7\2\0\11\7"+
- "\1\70\12\7\17\0\2\7\5\0\2\7\2\0\2\7"+
- "\1\71\10\7\1\72\10\7\17\0\2\7\5\0\2\7"+
- "\2\0\1\7\1\73\22\7\17\0\2\7\5\0\2\7"+
- "\2\0\1\7\1\74\22\7\17\0\2\7\5\0\2\7"+
- "\2\0\12\7\1\75\5\7\1\76\3\7\17\0\2\7"+
- "\37\0\1\77\71\0\1\100\3\0\1\50\2\0\4\50"+
- "\1\0\45\50\10\0\1\101\5\0\1\102\1\0\1\103"+
- "\2\0\1\104\37\0\2\7\2\0\1\7\1\105\22\7"+
- "\17\0\2\7\5\0\2\7\2\0\7\7\1\106\14\7"+
- "\17\0\2\7\5\0\2\7\2\0\5\7\1\107\16\7"+
- "\17\0\2\7\5\0\2\7\2\0\7\7\1\110\14\7"+
- "\17\0\2\7\5\0\2\7\2\0\10\7\1\111\13\7"+
- "\17\0\2\7\5\0\2\7\2\0\7\7\1\112\14\7"+
- "\17\0\2\7\5\0\2\7\2\0\12\7\1\113\11\7"+
- "\17\0\2\7\5\0\2\7\2\0\4\7\1\114\17\7"+
- "\17\0\2\7\5\0\2\7\2\0\5\7\1\115\16\7"+
- "\17\0\2\7\5\0\2\7\2\0\4\7\1\116\5\7"+
- "\1\117\11\7\17\0\2\7\5\0\2\7\2\0\1\7"+
- "\1\120\22\7\17\0\2\7\5\0\2\7\2\0\22\7"+
- "\1\121\1\7\17\0\2\7\5\0\2\7\2\0\7\7"+
- "\1\122\14\7\17\0\2\7\5\0\2\7\2\0\4\7"+
- "\1\123\17\7\17\0\2\7\5\0\2\7\2\0\1\7"+
- "\1\124\22\7\17\0\2\7\5\0\2\7\2\0\5\7"+
- "\1\125\16\7\17\0\2\7\5\0\2\7\2\0\20\7"+
- "\1\126\3\7\17\0\2\7\5\0\2\7\2\0\2\7"+
- "\1\127\10\7\1\130\10\7\17\0\2\7\5\0\2\7"+
- "\2\0\1\7\1\131\11\7\1\132\10\7\17\0\2\7"+
- "\5\0\2\7\2\0\1\133\23\7\17\0\2\7\37\0"+
- "\1\33\71\0\1\134\7\0\2\7\2\0\2\7\1\135"+
- "\21\7\17\0\2\7\5\0\2\7\2\0\3\7\1\136"+
- "\20\7\17\0\2\7\5\0\2\7\2\0\14\7\1\137"+
- "\7\7\17\0\2\7\5\0\2\7\2\0\3\7\1\140"+
- "\20\7\17\0\2\7\5\0\2\7\2\0\7\7\1\141"+
- "\14\7\17\0\2\7\5\0\2\7\2\0\13\7\1\142"+
- "\10\7\17\0\2\7\5\0\2\7\2\0\1\7\1\143"+
- "\22\7\17\0\2\7\5\0\2\7\2\0\5\7\1\144"+
- "\16\7\17\0\2\7\5\0\2\7\2\0\15\7\1\145"+
- "\6\7\17\0\2\7\5\0\2\7\2\0\7\7\1\146"+
- "\14\7\17\0\2\7\5\0\2\7\2\0\13\7\1\147"+
- "\10\7\17\0\2\7\5\0\2\7\2\0\12\7\1\150"+
- "\11\7\17\0\2\7\5\0\2\7\2\0\3\7\1\151"+
- "\20\7\17\0\2\7\5\0\2\7\2\0\12\7\1\152"+
- "\11\7\17\0\2\7\5\0\2\7\2\0\4\7\1\153"+
- "\17\7\17\0\2\7\5\0\2\7\2\0\4\7\1\154"+
- "\17\7\17\0\2\7\5\0\2\7\2\0\1\155\23\7"+
- "\17\0\2\7\5\0\2\7\2\0\4\7\1\156\17\7"+
- "\17\0\2\7\5\0\2\7\2\0\17\7\1\157\4\7"+
- "\17\0\2\7\5\0\2\7\2\0\7\7\1\160\14\7"+
- "\17\0\2\7\5\0\2\7\2\0\21\7\1\161\2\7"+
- "\17\0\2\7\5\0\2\7\2\0\2\7\1\162\21\7"+
- "\17\0\2\7\5\0\2\7\2\0\3\7\1\163\20\7"+
- "\17\0\2\7\5\0\2\7\2\0\5\7\1\164\16\7"+
- "\17\0\2\7\5\0\2\7\2\0\12\7\1\165\11\7"+
- "\17\0\2\7\5\0\2\7\2\0\21\7\1\166\2\7"+
- "\17\0\2\7\5\0\2\7\2\0\24\7\17\0\1\167"+
- "\1\7\5\0\2\7\2\0\10\7\1\170\13\7\17\0"+
- "\2\7\5\0\2\7\2\0\11\7\1\171\12\7\17\0"+
- "\2\7\5\0\2\7\2\0\13\7\1\172\10\7\17\0"+
- "\2\7\5\0\2\7\2\0\15\7\1\173\6\7\17\0"+
- "\2\7\5\0\2\7\2\0\7\7\1\174\14\7\17\0"+
- "\2\7\5\0\2\7\2\0\12\7\1\175\11\7\17\0"+
- "\2\7\5\0\2\7\2\0\7\7\1\176\14\7\17\0"+
- "\2\7\5\0\2\7\2\0\2\7\1\177\21\7\17\0"+
- "\2\7\5\0\2\7\2\0\2\7\1\200\21\7\17\0"+
- "\2\7\5\0\2\7\2\0\7\7\1\201\14\7\17\0"+
- "\2\7\5\0\2\7\2\0\3\7\1\202\20\7\17\0"+
- "\2\7\5\0\2\7\2\0\4\7\1\203\17\7\17\0"+
- "\2\7\5\0\2\7\2\0\13\7\1\204\10\7\17\0"+
- "\2\7\5\0\2\7\2\0\4\7\1\205\17\7\17\0"+
- "\2\7\5\0\2\7\2\0\17\7\1\206\4\7\17\0"+
- "\2\7\5\0\2\7\2\0\4\7\1\207\17\7\17\0"+
- "\2\7\5\0\2\7\2\0\3\7\1\210\20\7\17\0"+
- "\2\7\5\0\2\7\2\0\10\7\1\211\13\7\17\0"+
- "\2\7\5\0\2\7\2\0\13\7\1\212\10\7\17\0"+
- "\2\7\5\0\2\7\2\0\12\7\1\213\11\7\17\0"+
- "\2\7\5\0\2\7\2\0\15\7\1\214\6\7\17\0"+
- "\2\7\5\0\2\7\2\0\7\7\1\215\14\7\17\0"+
- "\2\7\5\0\2\7\2\0\3\7\1\216\20\7\17\0"+
- "\2\7\5\0\2\7\2\0\13\7\1\217\10\7\17\0"+
- "\2\7\5\0\2\7\2\0\15\7\1\220\6\7\17\0"+
- "\2\7\5\0\2\7\2\0\7\7\1\221\14\7\17\0"+
- "\2\7\5\0\2\7\2\0\15\7\1\222\6\7\17\0"+
- "\2\7\5\0\2\7\2\0\5\7\1\223\16\7\17\0"+
- "\2\7\5\0\2\7\2\0\10\7\1\224\13\7\17\0"+
- "\2\7\5\0\2\7\2\0\15\7\1\225\6\7\17\0"+
- "\2\7\5\0\2\7\2\0\3\7\1\226\20\7\17\0"+
- "\2\7\5\0\2\7\2\0\1\7\1\227\22\7\17\0"+
- "\2\7\5\0\2\7\2\0\16\7\1\230\5\7\17\0"+
- "\2\7\5\0\2\7\2\0\2\7\1\231\21\7\17\0"+
- "\2\7\5\0\2\7\2\0\7\7\1\232\14\7\17\0"+
- "\2\7\5\0\2\7\2\0\3\7\1\233\20\7\17\0"+
- "\2\7\5\0\2\7\2\0\7\7\1\234\14\7\17\0"+
- "\2\7\5\0\2\7\2\0\5\7\1\235\16\7\17\0"+
- "\2\7\5\0\2\7\2\0\5\7\1\236\16\7\17\0"+
- "\2\7\5\0\2\7\2\0\22\7\1\237\1\7\17\0"+
- "\2\7\5\0\2\7\2\0\3\7\1\240\20\7\17\0"+
- "\2\7\5\0\2\7\2\0\3\7\1\241\20\7\17\0"+
- "\2\7\5\0\2\7\2\0\7\7\1\242\14\7\17\0"+
- "\2\7\5\0\2\7\2\0\13\7\1\243\10\7\17\0"+
- "\2\7\5\0\2\7\2\0\17\7\1\244\4\7\17\0"+
- "\2\7\5\0\2\7\2\0\23\7\1\245\17\0\2\7"+
- "\5\0\2\7\2\0\3\7\1\246\20\7\17\0\2\7"+
- "\5\0\2\7\2\0\17\7\1\247\4\7\17\0\2\7"+
- "\1\0";
+ "\1\4\1\5\2\6\1\7\1\4\1\10\1\7\1\11"+
+ "\1\12\1\13\1\14\1\7\1\15\1\16\2\7\1\17"+
+ "\1\7\1\20\1\21\1\22\1\7\1\23\1\24\1\7"+
+ "\1\25\1\26\1\27\1\30\1\31\1\32\1\33\1\34"+
+ "\1\35\1\36\1\37\1\40\1\41\1\42\1\43\2\7"+
+ "\1\44\1\45\1\4\2\46\1\4\51\46\1\47\1\46"+
+ "\1\50\2\4\50\50\1\51\1\50\1\52\60\0\1\6"+
+ "\57\0\26\7\17\0\2\7\7\0\3\7\1\53\4\7"+
+ "\1\54\15\7\17\0\2\7\7\0\3\7\1\55\22\7"+
+ "\17\0\2\7\7\0\26\7\17\0\1\7\1\56\7\0"+
+ "\2\7\1\57\23\7\17\0\2\7\7\0\6\7\1\60"+
+ "\17\7\17\0\2\7\7\0\13\7\1\61\1\62\11\7"+
+ "\17\0\2\7\7\0\10\7\1\63\1\64\1\7\1\65"+
+ "\6\7\1\66\3\7\17\0\2\7\7\0\7\7\1\67"+
+ "\16\7\17\0\2\7\7\0\13\7\1\70\12\7\17\0"+
+ "\2\7\7\0\4\7\1\71\10\7\1\72\10\7\17\0"+
+ "\2\7\7\0\3\7\1\73\22\7\17\0\2\7\7\0"+
+ "\3\7\1\74\22\7\17\0\2\7\7\0\14\7\1\75"+
+ "\5\7\1\76\3\7\17\0\2\7\37\0\1\77\71\0"+
+ "\1\100\5\0\1\50\2\0\50\50\1\0\1\50\14\0"+
+ "\1\101\1\0\1\102\2\0\1\103\32\0\1\104\6\0"+
+ "\3\7\1\105\22\7\17\0\2\7\7\0\11\7\1\106"+
+ "\14\7\17\0\2\7\7\0\7\7\1\107\16\7\17\0"+
+ "\2\7\7\0\11\7\1\110\14\7\17\0\2\7\7\0"+
+ "\12\7\1\111\13\7\17\0\2\7\7\0\11\7\1\112"+
+ "\14\7\17\0\2\7\7\0\14\7\1\113\11\7\17\0"+
+ "\2\7\7\0\6\7\1\114\17\7\17\0\2\7\7\0"+
+ "\7\7\1\115\16\7\17\0\2\7\7\0\6\7\1\116"+
+ "\5\7\1\117\11\7\17\0\2\7\7\0\3\7\1\120"+
+ "\22\7\17\0\2\7\7\0\24\7\1\121\1\7\17\0"+
+ "\2\7\7\0\11\7\1\122\14\7\17\0\2\7\7\0"+
+ "\6\7\1\123\17\7\17\0\2\7\7\0\3\7\1\124"+
+ "\22\7\17\0\2\7\7\0\7\7\1\125\16\7\17\0"+
+ "\2\7\7\0\22\7\1\126\3\7\17\0\2\7\7\0"+
+ "\4\7\1\127\10\7\1\130\10\7\17\0\2\7\7\0"+
+ "\3\7\1\131\11\7\1\132\10\7\17\0\2\7\7\0"+
+ "\2\7\1\133\23\7\17\0\2\7\37\0\1\31\71\0"+
+ "\1\134\11\0\4\7\1\135\21\7\17\0\2\7\7\0"+
+ "\5\7\1\136\20\7\17\0\2\7\7\0\16\7\1\137"+
+ "\7\7\17\0\2\7\7\0\5\7\1\140\20\7\17\0"+
+ "\2\7\7\0\11\7\1\141\14\7\17\0\2\7\7\0"+
+ "\15\7\1\142\10\7\17\0\2\7\7\0\3\7\1\143"+
+ "\22\7\17\0\2\7\7\0\7\7\1\144\16\7\17\0"+
+ "\2\7\7\0\17\7\1\145\6\7\17\0\2\7\7\0"+
+ "\11\7\1\146\14\7\17\0\2\7\7\0\15\7\1\147"+
+ "\10\7\17\0\2\7\7\0\14\7\1\150\11\7\17\0"+
+ "\2\7\7\0\5\7\1\151\20\7\17\0\2\7\7\0"+
+ "\14\7\1\152\11\7\17\0\2\7\7\0\6\7\1\153"+
+ "\17\7\17\0\2\7\7\0\6\7\1\154\17\7\17\0"+
+ "\2\7\7\0\2\7\1\155\23\7\17\0\2\7\7\0"+
+ "\6\7\1\156\17\7\17\0\2\7\7\0\21\7\1\157"+
+ "\4\7\17\0\2\7\7\0\11\7\1\160\14\7\17\0"+
+ "\2\7\7\0\23\7\1\161\2\7\17\0\2\7\7\0"+
+ "\4\7\1\162\21\7\17\0\2\7\7\0\5\7\1\163"+
+ "\20\7\17\0\2\7\7\0\7\7\1\164\16\7\17\0"+
+ "\2\7\7\0\14\7\1\165\11\7\17\0\2\7\7\0"+
+ "\23\7\1\166\2\7\17\0\2\7\7\0\26\7\17\0"+
+ "\1\167\1\7\7\0\12\7\1\170\13\7\17\0\2\7"+
+ "\7\0\13\7\1\171\12\7\17\0\2\7\7\0\15\7"+
+ "\1\172\10\7\17\0\2\7\7\0\17\7\1\173\6\7"+
+ "\17\0\2\7\7\0\11\7\1\174\14\7\17\0\2\7"+
+ "\7\0\14\7\1\175\11\7\17\0\2\7\7\0\11\7"+
+ "\1\176\14\7\17\0\2\7\7\0\4\7\1\177\21\7"+
+ "\17\0\2\7\7\0\4\7\1\200\21\7\17\0\2\7"+
+ "\7\0\11\7\1\201\14\7\17\0\2\7\7\0\5\7"+
+ "\1\202\20\7\17\0\2\7\7\0\6\7\1\203\17\7"+
+ "\17\0\2\7\7\0\15\7\1\204\10\7\17\0\2\7"+
+ "\7\0\6\7\1\205\17\7\17\0\2\7\7\0\21\7"+
+ "\1\206\4\7\17\0\2\7\7\0\6\7\1\207\17\7"+
+ "\17\0\2\7\7\0\5\7\1\210\20\7\17\0\2\7"+
+ "\7\0\12\7\1\211\13\7\17\0\2\7\7\0\15\7"+
+ "\1\212\10\7\17\0\2\7\7\0\14\7\1\213\11\7"+
+ "\17\0\2\7\7\0\17\7\1\214\6\7\17\0\2\7"+
+ "\7\0\11\7\1\215\14\7\17\0\2\7\7\0\5\7"+
+ "\1\216\20\7\17\0\2\7\7\0\15\7\1\217\10\7"+
+ "\17\0\2\7\7\0\17\7\1\220\6\7\17\0\2\7"+
+ "\7\0\11\7\1\221\14\7\17\0\2\7\7\0\17\7"+
+ "\1\222\6\7\17\0\2\7\7\0\7\7\1\223\16\7"+
+ "\17\0\2\7\7\0\12\7\1\224\13\7\17\0\2\7"+
+ "\7\0\17\7\1\225\6\7\17\0\2\7\7\0\5\7"+
+ "\1\226\20\7\17\0\2\7\7\0\3\7\1\227\22\7"+
+ "\17\0\2\7\7\0\20\7\1\230\5\7\17\0\2\7"+
+ "\7\0\4\7\1\231\21\7\17\0\2\7\7\0\11\7"+
+ "\1\232\14\7\17\0\2\7\7\0\5\7\1\233\20\7"+
+ "\17\0\2\7\7\0\11\7\1\234\14\7\17\0\2\7"+
+ "\7\0\7\7\1\235\16\7\17\0\2\7\7\0\7\7"+
+ "\1\236\16\7\17\0\2\7\7\0\24\7\1\237\1\7"+
+ "\17\0\2\7\7\0\5\7\1\240\20\7\17\0\2\7"+
+ "\7\0\5\7\1\241\20\7\17\0\2\7\7\0\11\7"+
+ "\1\242\14\7\17\0\2\7\7\0\15\7\1\243\10\7"+
+ "\17\0\2\7\7\0\21\7\1\244\4\7\17\0\2\7"+
+ "\7\0\25\7\1\245\17\0\2\7\7\0\5\7\1\246"+
+ "\20\7\17\0\2\7\7\0\21\7\1\247\4\7\17\0"+
+ "\2\7\3\0";
private static int [] zzUnpackTrans() {
int [] result = new int[5520];
@@ -385,9 +357,9 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) {
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
- "\3\0\1\11\1\1\1\11\1\1\2\11\15\1\2\11"+
- "\1\1\13\11\1\1\2\11\1\1\1\11\25\1\1\0"+
- "\1\1\4\11\27\1\1\11\113\1";
+ "\3\0\1\11\1\1\1\11\16\1\2\11\1\1\13\11"+
+ "\1\1\4\11\1\1\1\11\25\1\1\0\1\1\4\11"+
+ "\27\1\1\11\113\1";
private static int [] zzUnpackAttribute() {
int [] result = new int[167];
@@ -458,9 +430,7 @@ the source of the yytext() string */
private boolean zzEOFDone;
/* user code: */
- public static java.io.InputStream create(java.io.InputStream stream) {
- return (stream);
- }
+
boolean stringResult = false;
boolean characterResult = false;
@@ -490,6 +460,10 @@ private Symbol newToken(short id, Object value)
{
return new Symbol(id, yyline + 1, yycolumn + 1, yylength(), value);
}
+ public static JavaSignatureBeaverLexer create(java.io.InputStream stream) {
+ return new JavaSignatureBeaverLexer(stream);
+ }
+
@@ -841,15 +815,15 @@ else if (zzAtEOF) {
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 11:
+ case 9:
{ return newToken(Terminals.EQUAL);
}
case 55: break;
- case 12:
+ case 10:
{ return newToken(Terminals.LCURLY);
}
case 56: break;
- case 28:
+ case 27:
{ stringBuf.append('\n');
}
case 57: break;
@@ -857,11 +831,11 @@ else if (zzAtEOF) {
{ return newToken(Terminals.SYNCHRONIZED);
}
case 58: break;
- case 16:
+ case 14:
{ return newToken(Terminals.LBRACK);
}
case 59: break;
- case 14:
+ case 12:
{ return newToken(Terminals.LPAREN);
}
case 60: break;
@@ -889,15 +863,15 @@ else if (zzAtEOF) {
{ return newToken(Terminals.BOOLEAN);
}
case 66: break;
- case 4:
+ case 20:
{ yybegin(CHARACTER);
}
case 67: break;
- case 20:
+ case 18:
{ return newToken(Terminals.GT);
}
case 68: break;
- case 10:
+ case 8:
{ return newToken(Terminals.ELLIPSIS);
}
case 69: break;
@@ -905,7 +879,7 @@ else if (zzAtEOF) {
{ return newToken(Terminals.TRANSIENT);
}
case 70: break;
- case 19:
+ case 17:
{ return newToken(Terminals.LT);
}
case 71: break;
@@ -919,7 +893,7 @@ else if (zzAtEOF) {
return newToken(Terminals.STRING_LITERAL);
}
case 73: break;
- case 9:
+ case 7:
{ return newToken(Terminals.COMMA);
}
case 74: break;
@@ -939,11 +913,11 @@ else if (zzAtEOF) {
{ return newToken(Terminals.SUPER);
}
case 78: break;
- case 13:
+ case 11:
{ return newToken(Terminals.RCURLY);
}
case 79: break;
- case 29:
+ case 28:
{ stringBuf.append('\t');
}
case 80: break;
@@ -951,11 +925,11 @@ else if (zzAtEOF) {
{ return newToken(Terminals.SHORT);
}
case 81: break;
- case 17:
+ case 15:
{ return newToken(Terminals.RBRACK);
}
case 82: break;
- case 8:
+ case 6:
{ return newToken(Terminals.DOT);
}
case 83: break;
@@ -971,11 +945,11 @@ else if (zzAtEOF) {
{ return newToken(Terminals.INT);
}
case 86: break;
- case 15:
+ case 13:
{ return newToken(Terminals.RPAREN);
}
case 87: break;
- case 5:
+ case 19:
{ yybegin(STRING);
}
case 88: break;
@@ -991,7 +965,7 @@ else if (zzAtEOF) {
{ stringBuf.append('\\');
}
case 91: break;
- case 30:
+ case 29:
{ stringBuf.append('\r');
}
case 92: break;
@@ -1017,11 +991,11 @@ else if (zzAtEOF) {
{ return newToken(Terminals.IDENTIFIER);
}
case 97: break;
- case 7:
+ case 5:
{ return newToken(Terminals.AND);
}
case 98: break;
- case 6:
+ case 4:
{ return newToken(Terminals.AT);
}
case 99: break;
@@ -1029,7 +1003,7 @@ else if (zzAtEOF) {
{ return newToken(Terminals.EXTENDS);
}
case 100: break;
- case 27:
+ case 30:
{ stringBuf.append('\"');
}
case 101: break;
@@ -1053,7 +1027,7 @@ else if (zzAtEOF) {
{ return newToken(Terminals.PRIVATE);
}
case 106: break;
- case 18:
+ case 16:
{ return newToken(Terminals.QUESTION);
}
case 107: break;
View
13 src/org/jruby/parser/JavaSignatureBeaverParser.grammar
@@ -31,11 +31,14 @@
%class "JavaSignatureBeaverParser";
%embed {:
- private static JavaSignatureBeaverParser parser = new JavaSignatureBeaverParser();
- public static SignatureNode parse(InputStream in) throws IOException, ParserSyntaxException {
- return (SignatureNode) parser.parse(in);
- }
- :};
+
+
+ private static JavaSignatureBeaverParser parser = new JavaSignatureBeaverParser();
+
+ public static SignatureNode parse(InputStream in) throws IOException, ParserSyntaxException {
+ return (SignatureNode) parser.parse(JavaSignatureBeaverLexer.create(in));
+ }
+:};
%terminals BOOLEAN, BYTE, SHORT, INT, LONG, CHAR, FLOAT, DOUBLE, VOID, // primitive types
PUBLIC, PRIVATE, PROTECTED, STATIC, ABSTRACT, FINAL, NATIVE, SYNCHRONIZED, TRANSIENT, VOLATILE, STRICTFP, //modifiers
View
259 src/org/jruby/parser/JavaSignatureBeaverParser.java
@@ -123,10 +123,13 @@
"QkD#LGXSCTf460kqiNbrjShGZmLEmep5du6ag3ljIPVmVwK1fSGGna$97aZEIxwSau8nGr8" +
"p9VJrT9UdxiJvuvtmvN17ZUSZmmTPSdml2fqEp6Xh5iqDbY$4yxJF4u");
- private static JavaSignatureBeaverParser parser = new JavaSignatureBeaverParser();
- public static SignatureNode parse(InputStream in) throws IOException, ParserSyntaxException {
- return (SignatureNode) parser.parse(in);
- }
+
+
+ private static JavaSignatureBeaverParser parser = new JavaSignatureBeaverParser();
+
+ public static SignatureNode parse(InputStream in) throws IOException, ParserSyntaxException, beaver.Parser.Exception {
+ return (SignatureNode) parser.parse(JavaSignatureBeaverLexer.create(in));
+ }
private final Action[] actions;
@@ -137,7 +140,7 @@ public JavaSignatureBeaverParser() {
public Symbol reduce(Symbol[] _symbols, int offset) {
final Symbol _symbol_m = _symbols[offset + 1];
final MethodSignatureNode m = (MethodSignatureNode) _symbol_m.value;
-
+
return new Symbol((SignatureNode)(m));
//$$ = $1;
}
@@ -146,7 +149,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
public Symbol reduce(Symbol[] _symbols, int offset) {
final Symbol _symbol_c = _symbols[offset + 1];
final ConstructorSignatureNode c = (ConstructorSignatureNode) _symbol_c.value;
-
+
return new Symbol((SignatureNode)(c));
// $$ = $1;
}
@@ -156,63 +159,63 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
public Symbol reduce(Symbol[] _symbols, int offset) {
final Symbol _symbol_r = _symbols[offset + 1];
final ReferenceTypeNode r = (ReferenceTypeNode) _symbol_r.value;
-
+
return new Symbol((TypeNode)r);
//$$ = $<TypeNode>1;
}
},
new Action() { // [4] primitive_type = BYTE
public Symbol reduce(Symbol[] _symbols, int offset) {
-
+
return new Symbol(PrimitiveTypeNode.BYTE);
//$$ = PrimitiveTypeNode.BYTE;
}
},
new Action() { // [5] primitive_type = SHORT
public Symbol reduce(Symbol[] _symbols, int offset) {
-
+
return new Symbol(PrimitiveTypeNode.SHORT);
//$$ = PrimitiveTypeNode.SHORT;
}
},
new Action() { // [6] primitive_type = INT
public Symbol reduce(Symbol[] _symbols, int offset) {
-
+
return new Symbol(PrimitiveTypeNode.INT);
//$$ = PrimitiveTypeNode.INT;
}
},
new Action() { // [7] primitive_type = LONG
public Symbol reduce(Symbol[] _symbols, int offset) {
-
+
return new Symbol(PrimitiveTypeNode.LONG);
//$$ = PrimitiveTypeNode.LONG;
}
},
new Action() { // [8] primitive_type = CHAR
public Symbol reduce(Symbol[] _symbols, int offset) {
-
+
return new Symbol(PrimitiveTypeNode.CHAR);
//$$ = PrimitiveTypeNode.CHAR;
}
},
new Action() { // [9] primitive_type = BOOLEAN
public Symbol reduce(Symbol[] _symbols, int offset) {
-
+
return new Symbol(PrimitiveTypeNode.BOOLEAN);
//$$ = PrimitiveTypeNode.BOOLEAN;
}
},
new Action() { // [10] primitive_type = FLOAT
public Symbol reduce(Symbol[] _symbols, int offset) {
-
+
return new Symbol(PrimitiveTypeNode.FLOAT);
//$$ = PrimitiveTypeNode.FLOAT;
}
},
new Action() { // [11] primitive_type = DOUBLE
public Symbol reduce(Symbol[] _symbols, int offset) {
-
+
return new Symbol(PrimitiveTypeNode.DOUBLE);
//$$ = PrimitiveTypeNode.DOUBLE;
}
@@ -221,7 +224,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
public Symbol reduce(Symbol[] _symbols, int offset) {
final Symbol _symbol_c = _symbols[offset + 1];
final ReferenceTypeNode c = (ReferenceTypeNode) _symbol_c.value;
-
+
return new Symbol((ReferenceTypeNode)c);
// $$ = $1;
}
@@ -230,7 +233,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
public Symbol reduce(Symbol[] _symbols, int offset) {
final Symbol _symbol_a = _symbols[offset + 1];
final ReferenceTypeNode a = (ReferenceTypeNode) _symbol_a.value;
-
+
return new Symbol((ReferenceTypeNode)a);
//$$ = $<ReferenceTypeNode>1;
}
@@ -239,7 +242,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
public Symbol reduce(Symbol[] _symbols, int offset) {
final Symbol _symbol_id = _symbols[offset + 1];
final String id = (String) _symbol_id.value;
-
+
return new Symbol(new String(id));
// $$ = $1;
}
@@ -248,7 +251,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
public Symbol reduce(Symbol[] _symbols, int offset) {
final Symbol _symbol_n = _symbols[offset + 1];
final String n = (String) _symbol_n.value;
-
+
return new Symbol(new ReferenceTypeNode(n));
// $$ = new ReferenceTypeNode($1);
}
@@ -261,7 +264,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
final String t = (String) _symbol_t.value;
final Symbol _symbol_n = _symbols[offset + 5];
final String n = (String) _symbol_n.value;
-
+
String genericTyping = "<" + t + "." + n;
//String genericTyping = "<" + $3 + "." + $5;
ReferenceTypeNode result = c;
@@ -278,7 +281,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
final ReferenceTypeNode c = (ReferenceTypeNode) _symbol_c.value;
final Symbol _symbol_l = _symbols[offset + 3];
final String l = (String) _symbol_l.value;
-
+
String genericTyping = "<" + l;
//String genericTyping = "<" + $3;
ReferenceTypeNode result = c;
@@ -296,7 +299,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
final TypeNode t = (TypeNode) _symbol_t.value;
final Symbol _symbol_d = _symbols[offset + 2];
final ArrayTypeNode d = (ArrayTypeNode) _symbol_d.value;
-
+
d.setTypeForArray(t);
//$2.setTypeForArray($1);
return new Symbol(d);
@@ -309,7 +312,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
final String n = (String) _symbol_n.value;
final Symbol _symbol_d = _symbols[offset + 2];
final ArrayTypeNode d = (ArrayTypeNode) _symbol_d.value;
-
+
d.setTypeForArray(new ReferenceTypeNode(n));
//$2.setTypeForArray(new ReferenceTypeNode($1));
return new Symbol(d);
@@ -326,7 +329,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
final String n = (String) _symbol_n.value;
final Symbol _symbol_d = _symbols[offset + 6];
final ArrayTypeNode d = (ArrayTypeNode) _symbol_d.value;
-
+
c.setGenericsTyping("<" + t + "." + n);
//$1.setGenericsTyping("<" + $3 + "." + $5);
d.setTypeForArray(c);
@@ -343,7 +346,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
final String t = (String) _symbol_t.value;
final Symbol _symbol_d = _symbols[offset + 4];
final ArrayTypeNode d = (ArrayTypeNode) _symbol_d.value;
-
+
c.setGenericsTyping("<" + t);
//$1.setGenericsTyping("<" + $3);
d.setTypeForArray(c);
@@ -354,7 +357,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
},
new Action() { // [25] wildcard = QUESTION
public Symbol reduce(Symbol[] _symbols, int offset) {
-
+
return new Symbol("?");
//$$ = "?";
}
@@ -363,7 +366,7 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
public Symbol reduce(Symbol[] _symbols, int offset) {
final Symbol _symbol_t = _symbols[offset + 3];
final ReferenceTypeNode t = (ReferenceTypeNode) _symbol_t.value;
-
+
return new Symbol("? extends " + t.getFullyTypedName());
//$$ = "? extends " + $3.getFullyTypedName();
}
@@ -372,14 +375,14 @@ public Symbol reduce(Symbol[] _symbols, int offset) {
public Symbol reduce(Symbol[] _symbols, int offset) {
final Symbol _symbol_t = _symbols[offset + 3];
final ReferenceTypeNode t = (ReferenceTypeNode) _symbol_t.value;
-
+
return new Symbol("? super " + t.getFullyTypedName());
//$$ = "? super " + $3.getFullyTypedName();
}