/** * Parse an integer literal. * @param string string to parse * @return <code>Long.valueOf(string)</code> */ protected Number parseInteger(String string) throws ParseException { try { return Long.valueOf(string); } catch (NumberFormatException e) { fail(INTEGER); return null; } }
/** * Parse a floating point literal. * @param string string to parse * @return <code>Double.valueOf(string)</code> */ protected Number parseFloat(String string) throws ParseException { try { return Double.valueOf(string); } catch (NumberFormatException e) { fail(FLOAT); return null; } }
/** * Parse an integer literal. * @param string string to parse * @return <code>Long.valueOf(string)</code> */ protected Number parseInteger(String string) throws ParseException { try { return Long.valueOf(string); } catch (NumberFormatException e) { fail(INTEGER); return null; } }
/** * Parse a floating point literal. * @param string string to parse * @return <code>Double.valueOf(string)</code> */ protected Number parseFloat(String string) throws ParseException { try { return Double.valueOf(string); } catch (NumberFormatException e) { fail(FLOAT); return null; } }
/** * throw exception */ protected void fail(Symbol expected) throws ParseException { fail(expected.toString()); }
/** * throw exception */ protected void fail(Symbol expected) throws ParseException { fail(expected.toString()); }
/** * consume current token (get next token); throw exception if the current token doesn't * match the expected symbol. */ protected final Token consumeToken(Symbol expected) throws ScanException, ParseException { if (token.getSymbol() != expected) { fail(expected); } return consumeToken(); }
/** * consume current token (get next token); throw exception if the current token doesn't * match the expected symbol. */ protected final Token consumeToken(Symbol expected) throws ScanException, ParseException { if (token.getSymbol() != expected) { fail(expected); } return consumeToken(); }
/** * eval := dynamic | deferred */ protected AstEval eval() throws ScanException, ParseException { AstEval e = eval(false, false); if (e == null) { e = eval(false, true); if (e == null) { fail(START_EVAL_DEFERRED + "|" + START_EVAL_DYNAMIC); } } return e; }
/** * eval := dynamic | deferred */ protected AstEval eval() throws ScanException, ParseException { AstEval e = eval(false, false); if (e == null) { e = eval(false, true); if (e == null) { fail(START_EVAL_DEFERRED + "|" + START_EVAL_DYNAMIC); } } return e; }
/** * dynmamic := <START_EVAL_DYNAMIC> expr <END_EVAL> * deferred := <START_EVAL_DEFERRED> expr <END_EVAL> */ protected AstEval eval(boolean required, boolean deferred) throws ScanException, ParseException { AstEval v = null; Symbol start_eval = deferred ? START_EVAL_DEFERRED : START_EVAL_DYNAMIC; if (token.getSymbol() == start_eval) { consumeToken(); v = new AstEval(expr(true), deferred); consumeToken(END_EVAL); } else if (required) { fail(start_eval); } return v; }
/** * dynmamic := <START_EVAL_DYNAMIC> expr <END_EVAL> * deferred := <START_EVAL_DEFERRED> expr <END_EVAL> */ protected AstEval eval(boolean required, boolean deferred) throws ScanException, ParseException { AstEval v = null; Symbol start_eval = deferred ? START_EVAL_DEFERRED : START_EVAL_DYNAMIC; if (token.getSymbol() == start_eval) { consumeToken(); v = new AstEval(expr(true), deferred); consumeToken(END_EVAL); } else if (required) { fail(start_eval); } return v; }
/** * Parse a floating point literal. * @param string string to parse * @return <code>Double.valueOf(string)</code> */ protected Number parseFloat(String string) throws ParseException { try { return Double.valueOf(string); } catch (NumberFormatException e) { fail(FLOAT); return null; } }
/** * Parse an integer literal. * @param string string to parse * @return <code>Long.valueOf(string)</code> */ protected Number parseInteger(String string) throws ParseException { try { return Long.valueOf(string); } catch (NumberFormatException e) { fail(INTEGER); return null; } }
/** * throw exception */ protected void fail(Symbol expected) throws ParseException { fail(expected.toString()); }
fail(EXPR_FIRST);
fail(EXPR_FIRST);
/** * consume current token (get next token); throw exception if the current token doesn't * match the expected symbol. */ protected final Token consumeToken(Symbol expected) throws ScanException, ParseException { if (token.getSymbol() != expected) { fail(expected); } return consumeToken(); }
/** * eval := dynamic | deferred */ protected AstEval eval() throws ScanException, ParseException { AstEval e = eval(false, false); if (e == null) { e = eval(false, true); if (e == null) { fail(START_EVAL_DEFERRED + "|" + START_EVAL_DYNAMIC); } } return e; }
/** * dynmamic := <START_EVAL_DYNAMIC> expr <END_EVAL> * deferred := <START_EVAL_DEFERRED> expr <END_EVAL> */ protected AstEval eval(boolean required, boolean deferred) throws ScanException, ParseException { AstEval v = null; Symbol start_eval = deferred ? START_EVAL_DEFERRED : START_EVAL_DYNAMIC; if (token.getSymbol() == start_eval) { consumeToken(); v = new AstEval(expr(true), deferred); consumeToken(END_EVAL); } else if (required) { fail(start_eval); } return v; }