Package org.codehaus.groovy.antlr
Class AntlrParserPlugin
java.lang.Object
org.codehaus.groovy.syntax.ASTHelper
org.codehaus.groovy.antlr.AntlrParserPlugin
- All Implemented Interfaces:
GroovyTokenTypes,ParserPlugin
A parser plugin which adapts the JSR Antlr Parser to the Groovy runtime
- Author:
- James Strachan
-
Field Summary
FieldsFields inherited from class org.codehaus.groovy.syntax.ASTHelper
output, resolutionsFields inherited from interface org.codehaus.groovy.antlr.parser.GroovyTokenTypes
ABSTRACT, ANNOTATION, ANNOTATION_ARRAY_INIT, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, ANNOTATION_MEMBER_VALUE_PAIR, ANNOTATIONS, ARRAY_DECLARATOR, ASSIGN, AT, BAND, BAND_ASSIGN, BIG_SUFFIX, BLOCK, BNOT, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, CASE_GROUP, CLASS_DEF, CLOSABLE_BLOCK, CLOSABLE_BLOCK_OP, CLOSURE_LIST, COLON, COMMA, COMPARE_TO, CTOR_CALL, CTOR_IDENT, DEC, DIGIT, DIV, DIV_ASSIGN, DOLLAR, DOLLAR_REGEXP_CTOR_END, DOLLAR_REGEXP_LITERAL, DOLLAR_REGEXP_SYMBOL, DOT, DYNAMIC_MEMBER, ELIST, ELVIS_OPERATOR, EMPTY_STAT, ENUM_CONSTANT_DEF, ENUM_DEF, EOF, EQUAL, ESC, ESCAPED_DOLLAR, ESCAPED_SLASH, EXPONENT, EXPR, EXTENDS_CLAUSE, FINAL, FLOAT_SUFFIX, FOR_CONDITION, FOR_EACH_CLAUSE, FOR_IN_ITERABLE, FOR_INIT, FOR_ITERATOR, GE, GT, HEX_DIGIT, IDENT, IDENTICAL, IMPLEMENTS_CLAUSE, IMPLICIT_PARAMETERS, IMPORT, INC, INDEX_OP, INSTANCE_INIT, INTERFACE_DEF, LABELED_ARG, LABELED_STAT, LAND, LBRACK, LCURLY, LE, LETTER, LIST_CONSTRUCTOR, LITERAL_as, LITERAL_assert, LITERAL_boolean, LITERAL_break, LITERAL_byte, LITERAL_case, LITERAL_catch, LITERAL_char, LITERAL_class, LITERAL_continue, LITERAL_def, LITERAL_default, LITERAL_double, LITERAL_else, LITERAL_enum, LITERAL_extends, LITERAL_false, LITERAL_finally, LITERAL_float, LITERAL_for, LITERAL_if, LITERAL_implements, LITERAL_import, LITERAL_in, LITERAL_instanceof, LITERAL_int, LITERAL_interface, LITERAL_long, LITERAL_native, LITERAL_new, LITERAL_null, LITERAL_package, LITERAL_private, LITERAL_protected, LITERAL_public, LITERAL_return, LITERAL_short, LITERAL_static, LITERAL_super, LITERAL_switch, LITERAL_synchronized, LITERAL_this, LITERAL_threadsafe, LITERAL_throw, LITERAL_throws, LITERAL_transient, LITERAL_true, LITERAL_try, LITERAL_void, LITERAL_volatile, LITERAL_while, LNOT, LOR, LPAREN, LT, MAP_CONSTRUCTOR, MEMBER_POINTER, METHOD_CALL, METHOD_DEF, MINUS, MINUS_ASSIGN, ML_COMMENT, MOD, MOD_ASSIGN, MODIFIERS, NLS, NOT_EQUAL, NOT_IDENTICAL, NULL_TREE_LOOKAHEAD, NUM_BIG_DECIMAL, NUM_BIG_INT, NUM_DOUBLE, NUM_FLOAT, NUM_INT, NUM_LONG, OBJBLOCK, ONE_NL, OPTIONAL_DOT, PACKAGE_DEF, PARAMETER_DEF, PARAMETERS, PLUS, PLUS_ASSIGN, POST_DEC, POST_INC, QUESTION, RANGE_EXCLUSIVE, RANGE_INCLUSIVE, RBRACK, RCURLY, REGEX_FIND, REGEX_MATCH, REGEXP_CTOR_END, REGEXP_LITERAL, REGEXP_SYMBOL, RPAREN, SELECT_SLOT, SEMI, SH_COMMENT, SL, SL_ASSIGN, SL_COMMENT, SLIST, SPREAD_ARG, SPREAD_DOT, SPREAD_MAP_ARG, SR, SR_ASSIGN, STAR, STAR_ASSIGN, STAR_STAR, STAR_STAR_ASSIGN, STATIC_IMPORT, STATIC_INIT, STRICTFP, STRING_CH, STRING_CONSTRUCTOR, STRING_CTOR_END, STRING_CTOR_MIDDLE, STRING_CTOR_START, STRING_LITERAL, STRING_NL, SUPER_CTOR_CALL, TRIPLE_DOT, TYPE, TYPE_ARGUMENT, TYPE_ARGUMENTS, TYPE_LOWER_BOUNDS, TYPE_PARAMETER, TYPE_PARAMETERS, TYPE_UPPER_BOUNDS, TYPECAST, UNARY_MINUS, UNARY_PLUS, UNUSED_CONST, UNUSED_DO, UNUSED_GOTO, VARIABLE_DEF, VARIABLE_PARAMETER_DEF, VOCAB, WILDCARD_TYPE, WS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanaddArgumentExpression(antlr.collections.AST node, List<Expression> expressionList) protected AnnotationNodeannotation(antlr.collections.AST annotationNode) protected voidannotationDef(antlr.collections.AST classDef) protected ExpressionanonymousInnerClassDef(antlr.collections.AST node) protected Expressionarguments(antlr.collections.AST elist) protected ListarraySizeExpression(antlr.collections.AST node) protected ExpressionasExpression(antlr.collections.AST node) protected voidassertNodeType(int type, antlr.collections.AST node) protected StatementassertStatement(antlr.collections.AST assertNode) protected voidassertTypeNotNull(ClassNode type, antlr.collections.AST rightNode) protected ExpressionbinaryExpression(int type, antlr.collections.AST node) protected ExpressionblockExpression(antlr.collections.AST node) protected BooleanExpressionbooleanExpression(antlr.collections.AST node) protected StatementbreakStatement(antlr.collections.AST node) buildAST(SourceUnit sourceUnit, ClassLoader classLoader, Reduction cst) protected ClassNodebuildName(antlr.collections.AST node) Extracts an identifier from the Antlr AST and then performs a name resolution to see if the given name is a type from imports, aliases or newly created classesprotected StatementcaseStatements(antlr.collections.AST node, List cases) protected ExpressioncastExpression(antlr.collections.AST castNode) protected CatchStatementcatchStatement(antlr.collections.AST catchNode) protected voidclassDef(antlr.collections.AST classDef) protected ClosureExpressionclosureExpression(antlr.collections.AST node) protected voidconfigureAST(ASTNode node, antlr.collections.AST ast) protected ExpressionconstructorCallExpression(antlr.collections.AST node) protected voidconstructorDef(antlr.collections.AST constructorDef) protected StatementcontinueStatement(antlr.collections.AST node) protected voidconvertGroovy(antlr.collections.AST node) Converts the Antlr AST to the Groovy ASTprotected ConstantExpressiondecimalExpression(antlr.collections.AST node) protected ExpressiondeclarationExpression(antlr.collections.AST variableDef) protected ExpressiondotExpression(antlr.collections.AST node) protected voiddump(antlr.collections.AST node) protected voiddumpTree(antlr.collections.AST ast) protected ExpressiondynamicMemberExpression(antlr.collections.AST dynamicMemberNode) protected voidenumConstantDef(antlr.collections.AST node) protected voidenumDef(antlr.collections.AST enumNode) protected Expressionexpression(antlr.collections.AST node) protected Expressionexpression(antlr.collections.AST node, boolean convertToConstant) protected ExpressionexpressionList(antlr.collections.AST node) protected ExpressionexpressionSwitch(antlr.collections.AST node) protected voidfieldDef(antlr.collections.AST fieldDef) protected StatementforStatement(antlr.collections.AST forNode) protected StringgetFirstChildText(antlr.collections.AST node) protected Expressiongstring(antlr.collections.AST gstringNode) protected booleanhasVisibility(int modifiers) Returns true if the modifiers flags contain a visibility modifierprotected Stringidentifier(antlr.collections.AST node) Extracts an identifier from the Antlr ASTprotected StatementifStatement(antlr.collections.AST ifNode) protected voidimportDef(antlr.collections.AST importNode) protected ExpressionindexExpression(antlr.collections.AST indexNode) protected voidinnerClassDef(antlr.collections.AST classDef) protected voidinnerInterfaceDef(antlr.collections.AST classDef) protected ExpressioninstanceofExpression(antlr.collections.AST node) protected ConstantExpressionintegerExpression(antlr.collections.AST node) protected voidinterfaceDef(antlr.collections.AST classDef) protected ClassNode[]interfaces(antlr.collections.AST node) protected booleanisPrimitiveTypeLiteral(antlr.collections.AST node) static booleanisType(int typeCode, antlr.collections.AST node) protected Stringlabel(antlr.collections.AST labelNode) protected StatementlabelledStatement(antlr.collections.AST labelNode) protected ExpressionlistExpression(antlr.collections.AST listNode) protected ExpressionliteralExpression(antlr.collections.AST node, Object value) protected GenericsType[]makeGenericsType(antlr.collections.AST rootNode) protected static TokenmakeToken(int typeCode, antlr.collections.AST node) protected ClassNodemakeType(antlr.collections.AST typeNode) protected ClassNodemakeTypeWithArguments(antlr.collections.AST rootNode) protected MapEntryExpressionmapEntryExpression(antlr.collections.AST node) protected ExpressionmapExpression(antlr.collections.AST mapNode) Typically only used for map constructors I think?protected StatementmethodCall(antlr.collections.AST code) protected ExpressionmethodCallExpression(antlr.collections.AST methodCallNode) protected voidmethodDef(antlr.collections.AST methodDef) protected ExpressionmethodPointerExpression(antlr.collections.AST node) protected intmodifiers(antlr.collections.AST modifierNode, List<AnnotationNode> annotations, int defaultModifiers) protected voidnotImplementedYet(antlr.collections.AST node) protected voidobjectBlock(antlr.collections.AST objectBlock) protected voidobjectInit(antlr.collections.AST init) outputAST(SourceUnit sourceUnit, SourceBuffer sourceBuffer) protected voidpackageDef(antlr.collections.AST packageDef) protected Parameterparameter(antlr.collections.AST paramNode) protected Parameter[]parameters(antlr.collections.AST parametersNode) parseCST(SourceUnit sourceUnit, Reader reader) protected ExpressionpostfixExpression(antlr.collections.AST node, int token) protected ExpressionprefixExpression(antlr.collections.AST node, int token) protected voidstatic StringqualifiedName(antlr.collections.AST qualifiedNameNode) protected ExpressionrangeExpression(antlr.collections.AST rangeNode, boolean inclusive) protected StatementreturnStatement(antlr.collections.AST node) protected booleansetAccessTrue(antlr.collections.AST node, boolean access) protected intsetModifierBit(antlr.collections.AST node, int answer, int bit) protected ExpressionspecialConstructorCallExpression(antlr.collections.AST methodCallNode, ClassNode special) protected ExpressionspreadExpression(antlr.collections.AST node) protected ExpressionspreadMapExpression(antlr.collections.AST node) protected Statementstatement(antlr.collections.AST node) protected StatementstatementList(antlr.collections.AST code) protected StatementstatementListNoChild(antlr.collections.AST node, antlr.collections.AST alternativeConfigureNode) protected voidstaticInit(antlr.collections.AST staticInit) protected StatementswitchStatement(antlr.collections.AST switchNode) protected StatementsynchronizedStatement(antlr.collections.AST syncNode) protected ExpressionternaryExpression(antlr.collections.AST ternaryNode) protected voidthrowsList(antlr.collections.AST node, List<ClassNode> list) protected StatementthrowStatement(antlr.collections.AST node) protected voidtransformCSTIntoAST(SourceUnit sourceUnit, Reader reader, SourceBuffer sourceBuffer) protected StatementtryStatement(antlr.collections.AST tryStatementNode) protected ClassNodetype(antlr.collections.AST typeNode) protected ExpressionunaryMinusExpression(antlr.collections.AST unaryMinusExpr) protected ExpressionunaryPlusExpression(antlr.collections.AST unaryPlusExpr) protected voidunknownAST(antlr.collections.AST node) protected StatementvariableDef(antlr.collections.AST variableDef) protected ExpressionvariableExpression(antlr.collections.AST node) protected StatementwhileStatement(antlr.collections.AST whileNode) Methods inherited from class org.codehaus.groovy.syntax.ASTHelper
addImport, addImport, addStarImport, addStarImport, addStaticImport, addStaticImport, addStaticStarImport, addStaticStarImport, dot, dot, getClassLoader, getController, getPackageName, makeModule, setClassLoader, setController, setPackage, setPackageName
-
Field Details
-
ast
protected antlr.collections.AST ast
-
-
Constructor Details
-
AntlrParserPlugin
public AntlrParserPlugin()
-
-
Method Details
-
parseCST
- Specified by:
parseCSTin interfaceParserPlugin- Throws:
CompilationFailedException
-
transformCSTIntoAST
protected void transformCSTIntoAST(SourceUnit sourceUnit, Reader reader, SourceBuffer sourceBuffer) throws CompilationFailedException - Throws:
CompilationFailedException
-
processAST
protected void processAST() -
outputAST
-
buildAST
public ModuleNode buildAST(SourceUnit sourceUnit, ClassLoader classLoader, Reduction cst) throws ParserException - Specified by:
buildASTin interfaceParserPlugin- Throws:
ParserException
-
convertGroovy
protected void convertGroovy(antlr.collections.AST node) Converts the Antlr AST to the Groovy AST -
packageDef
protected void packageDef(antlr.collections.AST packageDef) -
importDef
protected void importDef(antlr.collections.AST importNode) -
annotationDef
protected void annotationDef(antlr.collections.AST classDef) -
interfaceDef
protected void interfaceDef(antlr.collections.AST classDef) -
innerInterfaceDef
protected void innerInterfaceDef(antlr.collections.AST classDef) -
classDef
protected void classDef(antlr.collections.AST classDef) -
anonymousInnerClassDef
-
innerClassDef
protected void innerClassDef(antlr.collections.AST classDef) -
objectBlock
protected void objectBlock(antlr.collections.AST objectBlock) -
enumDef
protected void enumDef(antlr.collections.AST enumNode) -
enumConstantDef
protected void enumConstantDef(antlr.collections.AST node) -
throwsList
-
methodDef
protected void methodDef(antlr.collections.AST methodDef) -
staticInit
protected void staticInit(antlr.collections.AST staticInit) -
objectInit
protected void objectInit(antlr.collections.AST init) -
constructorDef
protected void constructorDef(antlr.collections.AST constructorDef) -
fieldDef
protected void fieldDef(antlr.collections.AST fieldDef) -
interfaces
-
parameters
-
parameter
-
modifiers
protected int modifiers(antlr.collections.AST modifierNode, List<AnnotationNode> annotations, int defaultModifiers) -
setAccessTrue
protected boolean setAccessTrue(antlr.collections.AST node, boolean access) -
setModifierBit
protected int setModifierBit(antlr.collections.AST node, int answer, int bit) -
annotation
-
statement
-
statementList
-
statementListNoChild
protected Statement statementListNoChild(antlr.collections.AST node, antlr.collections.AST alternativeConfigureNode) -
assertStatement
-
breakStatement
-
continueStatement
-
forStatement
-
ifStatement
-
labelledStatement
-
methodCall
-
declarationExpression
-
variableDef
-
returnStatement
-
switchStatement
-
caseStatements
-
synchronizedStatement
-
throwStatement
-
tryStatement
-
catchStatement
-
whileStatement
-
expression
-
expression
-
expressionSwitch
-
dynamicMemberExpression
-
ternaryExpression
-
variableExpression
-
literalExpression
-
rangeExpression
-
spreadExpression
-
spreadMapExpression
-
methodPointerExpression
-
listExpression
-
mapExpression
Typically only used for map constructors I think? -
mapEntryExpression
-
instanceofExpression
-
assertTypeNotNull
-
asExpression
-
castExpression
-
indexExpression
-
binaryExpression
-
prefixExpression
-
postfixExpression
-
booleanExpression
-
dotExpression
-
specialConstructorCallExpression
protected Expression specialConstructorCallExpression(antlr.collections.AST methodCallNode, ClassNode special) -
methodCallExpression
-
constructorCallExpression
-
arraySizeExpression
-
arguments
-
addArgumentExpression
protected boolean addArgumentExpression(antlr.collections.AST node, List<Expression> expressionList) -
expressionList
-
closureExpression
-
blockExpression
-
unaryMinusExpression
-
unaryPlusExpression
-
decimalExpression
-
integerExpression
-
gstring
-
type
-
qualifiedName
-
makeTypeWithArguments
-
makeGenericsType
-
makeType
-
buildName
Extracts an identifier from the Antlr AST and then performs a name resolution to see if the given name is a type from imports, aliases or newly created classes -
isPrimitiveTypeLiteral
protected boolean isPrimitiveTypeLiteral(antlr.collections.AST node) -
identifier
Extracts an identifier from the Antlr AST -
label
-
hasVisibility
protected boolean hasVisibility(int modifiers) Returns true if the modifiers flags contain a visibility modifier -
configureAST
-
makeToken
-
getFirstChildText
-
isType
public static boolean isType(int typeCode, antlr.collections.AST node) -
assertNodeType
protected void assertNodeType(int type, antlr.collections.AST node) -
notImplementedYet
protected void notImplementedYet(antlr.collections.AST node) -
unknownAST
protected void unknownAST(antlr.collections.AST node) -
dumpTree
protected void dumpTree(antlr.collections.AST ast) -
dump
protected void dump(antlr.collections.AST node)
-