@param lineNo Line the token appears on. @param token First token on line. @return Parser associated with the token. @throws ASTParseException When the token is not valid.
(int lineNo, String token)
| 110 | * When the token is not valid. |
| 111 | */ |
| 112 | public static AbstractParser<?> getParser(int lineNo, String token) throws ASTParseException { |
| 113 | if (token.startsWith("//")) |
| 114 | return new CommentParser(); |
| 115 | if(token.endsWith(":")) |
| 116 | return new LabelParser(); |
| 117 | if (token.equals("DEFINE")) |
| 118 | return new DefinitionParser(); |
| 119 | if (token.equals("VALUE")) |
| 120 | return new DefaultValueParser(); |
| 121 | if(token.equals("THROWS")) |
| 122 | return new ThrowsParser(); |
| 123 | if(token.equals("TRY")) |
| 124 | return new TryCatchParser(); |
| 125 | if(token.equals("ALIAS")) |
| 126 | return new AliasDeclarationParser(); |
| 127 | if(token.equals("SIGNATURE")) |
| 128 | return new SignatureParser(); |
| 129 | if(token.equals("EXPR")) |
| 130 | return new ExpressionParser(); |
| 131 | // Get opcode from token (opcode?) then get the opcode's group |
| 132 | // Lookup group's parser |
| 133 | try { |
| 134 | int opcode = OpcodeUtil.nameToOpcode(token); |
| 135 | int type = OpcodeUtil.opcodeToType(opcode); |
| 136 | return getInsnParser(type); |
| 137 | } catch(NullPointerException ex) { |
| 138 | // Thrown when the opcode name isn't a real opcode |
| 139 | throw new ASTParseException(lineNo, "Not a real opcode: " + token); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * @param type |