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
public class AntlrParserPlugin extends ASTHelper implements ParserPlugin, GroovyTokenTypes
A parser plugin which adapts the JSR Antlr Parser to the Groovy runtime.
-
-
Field Summary
Fields Modifier and Type Field Description protected ASTastprotected java.lang.String[]tokenNames-
Fields inherited from class org.codehaus.groovy.syntax.ASTHelper
output, resolutions
-
Fields 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, DIGITS_WITH_UNDERSCORE, DIGITS_WITH_UNDERSCORE_OPT, 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_trait, 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, MULTICATCH, MULTICATCH_TYPES, 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, TRAIT_DEF, 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 Constructor Description AntlrParserPlugin()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanaddArgumentExpression(AST node, java.util.List<Expression> expressionList)protected AnnotationNodeannotation(AST annotationNode)protected voidannotationDef(AST classDef)protected ExpressionanonymousInnerClassDef(AST node)protected Expressionarguments(AST elist)protected java.util.List<Expression>arraySizeExpression(AST node)protected ExpressionasExpression(AST node)protected voidassertNodeType(int type, AST node)protected StatementassertStatement(AST assertNode)protected voidassertTypeNotNull(ClassNode type, AST rightNode)protected ExpressionbinaryExpression(int type, AST node)protected ExpressionblockExpression(AST node)protected BooleanExpressionbooleanExpression(AST node)protected StatementbreakStatement(AST node)ModuleNodebuildAST(SourceUnit sourceUnit, java.lang.ClassLoader classLoader, Reduction cst)protected ClassNodebuildName(AST node)protected StatementcaseStatements(AST node, java.util.List<CaseStatement> cases)protected ExpressioncastExpression(AST castNode)protected java.util.List<CatchStatement>catchStatement(AST catchNode)protected voidclassDef(AST classDef)protected ClosureExpressionclosureExpression(AST node)protected voidconfigureAST(ASTNode node, AST ast)protected ExpressionconstructorCallExpression(AST node)protected voidconstructorDef(AST constructorDef)protected StatementcontinueStatement(AST node)protected voidconvertGroovy(AST node)Converts the Antlr AST to the Groovy AST.protected ConstantExpressiondecimalExpression(AST node)protected ExpressiondeclarationExpression(AST variableDef)protected ExpressiondotExpression(AST node)protected voiddump(AST node)protected voiddumpTree(AST ast)protected ExpressiondynamicMemberExpression(AST dynamicMemberNode)protected ExpressionenumArguments(AST elist)protected voidenumConstantDef(AST node)protected voidenumDef(AST enumNode)protected Expressionexpression(AST node)protected Expressionexpression(AST node, boolean convertToConstant)protected ExpressionexpressionList(AST node)protected ExpressionexpressionSwitch(AST node)protected voidfieldDef(AST fieldDef)protected StatementforStatement(AST forNode)static ExpressiongetDefaultValueForPrimitive(ClassNode type)protected java.lang.StringgetFirstChildText(AST node)protected Expressiongstring(AST gstringNode)protected booleanhasVisibility(int modifiers)Returns true if the modifiers flags contain a visibility modifierprotected java.lang.Stringidentifier(AST node)Extracts an identifier from the Antlr ASTprotected StatementifStatement(AST ifNode)protected voidimportDef(AST importNode)protected ExpressionindexExpression(AST indexNode)protected voidinnerClassDef(AST classDef)protected voidinnerInterfaceDef(AST classDef)protected ExpressioninstanceofExpression(AST node)protected ConstantExpressionintegerExpression(AST node)protected voidinterfaceDef(AST classDef)protected ClassNode[]interfaces(AST node)protected booleanisPrimitiveTypeLiteral(AST node)static booleanisType(int typeCode, AST node)protected java.lang.Stringlabel(AST labelNode)protected StatementlabelledStatement(AST labelNode)protected ExpressionlistExpression(AST listNode)protected ConstantExpressionliteralExpression(AST node, java.lang.Object value)protected GenericsType[]makeGenericsType(AST rootNode)protected static TokenmakeToken(int typeCode, AST node)protected ClassNodemakeType(AST typeNode)protected ClassNodemakeTypeWithArguments(AST rootNode)protected MapEntryExpressionmapEntryExpression(AST node)protected ExpressionmapExpression(AST mapNode)protected StatementmethodCall(AST code)protected ExpressionmethodCallExpression(AST methodCallNode)protected voidmethodDef(AST methodDef)protected ExpressionmethodPointerExpression(AST node)protected intmodifiers(AST modifierNode, java.util.List<AnnotationNode> annotations, int defaultModifiers)protected voidnotImplementedYet(AST node)protected voidobjectBlock(AST objectBlock)protected voidobjectInit(AST init)ReductionoutputAST(SourceUnit sourceUnit, SourceBuffer sourceBuffer)protected voidpackageDef(AST packageDef)protected Parameterparameter(AST paramNode)protected Parameter[]parameters(AST parametersNode)ReductionparseCST(SourceUnit sourceUnit, java.io.Reader reader)protected ExpressionpostfixExpression(AST node, int token)protected ExpressionprefixExpression(AST node, int token)protected voidprocessAST()static java.lang.StringqualifiedName(AST qualifiedNameNode)protected ExpressionrangeExpression(AST rangeNode, boolean inclusive)protected StatementreturnStatement(AST node)protected booleansetAccessTrue(AST node, boolean access)protected intsetModifierBit(AST node, int answer, int bit)protected ExpressionspecialConstructorCallExpression(AST methodCallNode, ClassNode special)protected ExpressionspreadExpression(AST node)protected ExpressionspreadMapExpression(AST node)protected Statementstatement(AST node)protected StatementstatementList(AST code)protected StatementstatementListNoChild(AST node, AST alternativeConfigureNode)protected voidstaticInit(AST staticInit)protected StatementswitchStatement(AST switchNode)protected StatementsynchronizedStatement(AST syncNode)protected ExpressionternaryExpression(AST ternaryNode)protected voidthrowsList(AST node, java.util.List<ClassNode> list)protected StatementthrowStatement(AST node)protected voidtransformCSTIntoAST(SourceUnit sourceUnit, java.io.Reader reader, SourceBuffer sourceBuffer)protected StatementtryStatement(AST tryStatementNode)protected ExpressionunaryMinusExpression(AST unaryMinusExpr)protected ExpressionunaryPlusExpression(AST unaryPlusExpr)protected voidunknownAST(AST node)protected StatementvariableDef(AST variableDef)protected ExpressionvariableExpression(AST node)protected StatementwhileStatement(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 Detail
-
ast
protected AST ast
-
tokenNames
protected java.lang.String[] tokenNames
-
-
Method Detail
-
parseCST
public Reduction parseCST(SourceUnit sourceUnit, java.io.Reader reader) throws CompilationFailedException
- Specified by:
parseCSTin interfaceParserPlugin- Throws:
CompilationFailedException
-
transformCSTIntoAST
protected void transformCSTIntoAST(SourceUnit sourceUnit, java.io.Reader reader, SourceBuffer sourceBuffer) throws CompilationFailedException
- Throws:
CompilationFailedException
-
processAST
protected void processAST()
-
outputAST
public Reduction outputAST(SourceUnit sourceUnit, SourceBuffer sourceBuffer)
-
buildAST
public ModuleNode buildAST(SourceUnit sourceUnit, java.lang.ClassLoader classLoader, Reduction cst) throws ParserException
- Specified by:
buildASTin interfaceParserPlugin- Throws:
ParserException
-
convertGroovy
protected void convertGroovy(AST node)
Converts the Antlr AST to the Groovy AST.
-
packageDef
protected void packageDef(AST packageDef)
-
importDef
protected void importDef(AST importNode)
-
annotationDef
protected void annotationDef(AST classDef)
-
interfaceDef
protected void interfaceDef(AST classDef)
-
innerInterfaceDef
protected void innerInterfaceDef(AST classDef)
-
classDef
protected void classDef(AST classDef)
-
anonymousInnerClassDef
protected Expression anonymousInnerClassDef(AST node)
-
innerClassDef
protected void innerClassDef(AST classDef)
-
objectBlock
protected void objectBlock(AST objectBlock)
-
enumDef
protected void enumDef(AST enumNode)
-
enumConstantDef
protected void enumConstantDef(AST node)
-
methodDef
protected void methodDef(AST methodDef)
-
staticInit
protected void staticInit(AST staticInit)
-
objectInit
protected void objectInit(AST init)
-
constructorDef
protected void constructorDef(AST constructorDef)
-
fieldDef
protected void fieldDef(AST fieldDef)
-
getDefaultValueForPrimitive
public static Expression getDefaultValueForPrimitive(ClassNode type)
-
modifiers
protected int modifiers(AST modifierNode, java.util.List<AnnotationNode> annotations, int defaultModifiers)
-
setAccessTrue
protected boolean setAccessTrue(AST node, boolean access)
-
setModifierBit
protected int setModifierBit(AST node, int answer, int bit)
-
annotation
protected AnnotationNode annotation(AST annotationNode)
-
statementListNoChild
protected Statement statementListNoChild(AST node, AST alternativeConfigureNode)
-
declarationExpression
protected Expression declarationExpression(AST variableDef)
-
caseStatements
protected Statement caseStatements(AST node, java.util.List<CaseStatement> cases)
-
catchStatement
protected java.util.List<CatchStatement> catchStatement(AST catchNode)
-
expression
protected Expression expression(AST node)
-
expression
protected Expression expression(AST node, boolean convertToConstant)
-
expressionSwitch
protected Expression expressionSwitch(AST node)
-
dynamicMemberExpression
protected Expression dynamicMemberExpression(AST dynamicMemberNode)
-
ternaryExpression
protected Expression ternaryExpression(AST ternaryNode)
-
variableExpression
protected Expression variableExpression(AST node)
-
literalExpression
protected ConstantExpression literalExpression(AST node, java.lang.Object value)
-
rangeExpression
protected Expression rangeExpression(AST rangeNode, boolean inclusive)
-
spreadExpression
protected Expression spreadExpression(AST node)
-
spreadMapExpression
protected Expression spreadMapExpression(AST node)
-
methodPointerExpression
protected Expression methodPointerExpression(AST node)
-
listExpression
protected Expression listExpression(AST listNode)
-
mapExpression
protected Expression mapExpression(AST mapNode)
-
mapEntryExpression
protected MapEntryExpression mapEntryExpression(AST node)
-
instanceofExpression
protected Expression instanceofExpression(AST node)
-
asExpression
protected Expression asExpression(AST node)
-
castExpression
protected Expression castExpression(AST castNode)
-
indexExpression
protected Expression indexExpression(AST indexNode)
-
binaryExpression
protected Expression binaryExpression(int type, AST node)
-
prefixExpression
protected Expression prefixExpression(AST node, int token)
-
postfixExpression
protected Expression postfixExpression(AST node, int token)
-
booleanExpression
protected BooleanExpression booleanExpression(AST node)
-
dotExpression
protected Expression dotExpression(AST node)
-
specialConstructorCallExpression
protected Expression specialConstructorCallExpression(AST methodCallNode, ClassNode special)
-
methodCallExpression
protected Expression methodCallExpression(AST methodCallNode)
-
constructorCallExpression
protected Expression constructorCallExpression(AST node)
-
arraySizeExpression
protected java.util.List<Expression> arraySizeExpression(AST node)
-
enumArguments
protected Expression enumArguments(AST elist)
-
arguments
protected Expression arguments(AST elist)
-
addArgumentExpression
protected boolean addArgumentExpression(AST node, java.util.List<Expression> expressionList)
-
expressionList
protected Expression expressionList(AST node)
-
closureExpression
protected ClosureExpression closureExpression(AST node)
-
blockExpression
protected Expression blockExpression(AST node)
-
unaryMinusExpression
protected Expression unaryMinusExpression(AST unaryMinusExpr)
-
unaryPlusExpression
protected Expression unaryPlusExpression(AST unaryPlusExpr)
-
decimalExpression
protected ConstantExpression decimalExpression(AST node)
-
integerExpression
protected ConstantExpression integerExpression(AST node)
-
gstring
protected Expression gstring(AST gstringNode)
-
qualifiedName
public static java.lang.String qualifiedName(AST qualifiedNameNode)
-
makeGenericsType
protected GenericsType[] makeGenericsType(AST rootNode)
-
isPrimitiveTypeLiteral
protected boolean isPrimitiveTypeLiteral(AST node)
-
identifier
protected java.lang.String identifier(AST node)
Extracts an identifier from the Antlr AST
-
label
protected java.lang.String label(AST labelNode)
-
hasVisibility
protected boolean hasVisibility(int modifiers)
Returns true if the modifiers flags contain a visibility modifier
-
getFirstChildText
protected java.lang.String getFirstChildText(AST node)
-
isType
public static boolean isType(int typeCode, AST node)
-
assertNodeType
protected void assertNodeType(int type, AST node)
-
notImplementedYet
protected void notImplementedYet(AST node)
-
unknownAST
protected void unknownAST(AST node)
-
dumpTree
protected void dumpTree(AST ast)
-
dump
protected void dump(AST node)
-
-