public class ASParser extends antlr.LLkParser implements ASTokenTypes
Modifier and Type | Class and Description |
---|---|
protected static class |
BaseASParser.ExpressionMode |
Modifier and Type | Field and Description |
---|---|
static String[] |
_tokenNames |
static antlr.collections.impl.BitSet |
_tokenSet_0 |
static antlr.collections.impl.BitSet |
_tokenSet_1 |
static antlr.collections.impl.BitSet |
_tokenSet_10 |
static antlr.collections.impl.BitSet |
_tokenSet_11 |
static antlr.collections.impl.BitSet |
_tokenSet_12 |
static antlr.collections.impl.BitSet |
_tokenSet_13 |
static antlr.collections.impl.BitSet |
_tokenSet_14 |
static antlr.collections.impl.BitSet |
_tokenSet_15 |
static antlr.collections.impl.BitSet |
_tokenSet_16 |
static antlr.collections.impl.BitSet |
_tokenSet_17 |
static antlr.collections.impl.BitSet |
_tokenSet_18 |
static antlr.collections.impl.BitSet |
_tokenSet_19 |
static antlr.collections.impl.BitSet |
_tokenSet_2 |
static antlr.collections.impl.BitSet |
_tokenSet_3 |
static antlr.collections.impl.BitSet |
_tokenSet_4 |
static antlr.collections.impl.BitSet |
_tokenSet_5 |
static antlr.collections.impl.BitSet |
_tokenSet_6 |
static antlr.collections.impl.BitSet |
_tokenSet_7 |
static antlr.collections.impl.BitSet |
_tokenSet_8 |
static antlr.collections.impl.BitSet |
_tokenSet_9 |
protected boolean |
allowEmbeds
Flag to determine if we should create EmbedNodes or ignore embed metadata
|
protected IASParserASDocDelegate |
asDocDelegate
IASParserASDocDelegate used to track ASDoc information. |
protected IRepairingTokenBuffer |
buffer
Our version of a token buffer that allows us to handle optional
semicolons, etc
|
protected MetaTagsNode |
currentAttributes
Current metadata attributes.
|
protected DeferFunctionBody |
deferFunctionBody
True if the current input source is an ActionScript file, as opposed to
AS3 scripts in MXML or other synthesized source fragments.
|
static IProjectConfigVariables |
EMPTY_CONFIGURATION
Variable to use as an empty project configuration
|
protected Set<ICompilerProblem> |
errors
Errors we've collected as we're moving forward
|
protected antlr.Token |
errorToken
Last token that produced an error
|
protected BaseASParser.ExpressionMode |
expressionMode
Expression mode of the current parsing state.
|
protected boolean |
insideClass
flag that tracks whether the parser is currently inside of a class
definition this is "borrowed" from the old parser to deal with some ASDoc
functionality
|
protected static int |
NO_END_TOKEN
Used to specify "directive" rule's end token as "no end token" - the
parser will consume till the end of the input stream when recover from
errors.
|
astFactory, inputState, returnAST, tokenNames, tokenTypeToASTClassMap, traceDepth
EOF, HIDDEN_TOKEN_BUILTIN_NS, HIDDEN_TOKEN_COMMENT, HIDDEN_TOKEN_E4X, HIDDEN_TOKEN_MULTI_LINE_COMMENT, HIDDEN_TOKEN_SINGLE_LINE_COMMENT, HIDDEN_TOKEN_STAR_ASSIGNMENT, NULL_TREE_LOOKAHEAD, TOKEN_ASDOC_COMMENT, TOKEN_ASDOC_TAG, TOKEN_ASDOC_TEXT, TOKEN_ATTRIBUTE, TOKEN_BLOCK_CLOSE, TOKEN_BLOCK_OPEN, TOKEN_COLON, TOKEN_COMMA, TOKEN_DIRECTIVE_DEFAULT_XML, TOKEN_E4X_BINDING_CLOSE, TOKEN_E4X_BINDING_OPEN, TOKEN_E4X_CDATA, TOKEN_E4X_CLOSE_TAG_START, TOKEN_E4X_COMMENT, TOKEN_E4X_DECIMAL_ENTITY, TOKEN_E4X_DOTTED_NAME_PART, TOKEN_E4X_EMPTY_TAG_END, TOKEN_E4X_ENTITY, TOKEN_E4X_EQUALS, TOKEN_E4X_HEX_ENTITY, TOKEN_E4X_NAME, TOKEN_E4X_NAME_DOT, TOKEN_E4X_OPEN_TAG_START, TOKEN_E4X_PROCESSING_INSTRUCTION, TOKEN_E4X_STRING, TOKEN_E4X_TAG_END, TOKEN_E4X_TEXT, TOKEN_E4X_WHITESPACE, TOKEN_E4X_XMLLIST_CLOSE, TOKEN_E4X_XMLNS, TOKEN_ELLIPSIS, TOKEN_IDENTIFIER, TOKEN_KEYWORD_AS, TOKEN_KEYWORD_BREAK, TOKEN_KEYWORD_CASE, TOKEN_KEYWORD_CATCH, TOKEN_KEYWORD_CLASS, TOKEN_KEYWORD_CONST, TOKEN_KEYWORD_CONTINUE, TOKEN_KEYWORD_DEFAULT, TOKEN_KEYWORD_DELETE, TOKEN_KEYWORD_DO, TOKEN_KEYWORD_ELSE, TOKEN_KEYWORD_FALSE, TOKEN_KEYWORD_FINALLY, TOKEN_KEYWORD_FOR, TOKEN_KEYWORD_FUNCTION, TOKEN_KEYWORD_IF, TOKEN_KEYWORD_IMPORT, TOKEN_KEYWORD_IN, TOKEN_KEYWORD_INCLUDE, TOKEN_KEYWORD_INSTANCEOF, TOKEN_KEYWORD_INTERFACE, TOKEN_KEYWORD_IS, TOKEN_KEYWORD_NEW, TOKEN_KEYWORD_NULL, TOKEN_KEYWORD_PACKAGE, TOKEN_KEYWORD_RETURN, TOKEN_KEYWORD_SUPER, TOKEN_KEYWORD_SWITCH, TOKEN_KEYWORD_THIS, TOKEN_KEYWORD_THROW, TOKEN_KEYWORD_TRUE, TOKEN_KEYWORD_TRY, TOKEN_KEYWORD_TYPEOF, TOKEN_KEYWORD_USE, TOKEN_KEYWORD_VAR, TOKEN_KEYWORD_VOID, TOKEN_KEYWORD_WHILE, TOKEN_KEYWORD_WITH, TOKEN_LITERAL_HEX_NUMBER, TOKEN_LITERAL_NUMBER, TOKEN_LITERAL_REGEXP, TOKEN_LITERAL_STRING, TOKEN_LITERAL_XMLLIST, TOKEN_MODIFIER_DYNAMIC, TOKEN_MODIFIER_FINAL, TOKEN_MODIFIER_NATIVE, TOKEN_MODIFIER_OVERRIDE, TOKEN_MODIFIER_STATIC, TOKEN_MODIFIER_VIRTUAL, TOKEN_NAMESPACE_ANNOTATION, TOKEN_NAMESPACE_NAME, TOKEN_OPERATOR_ASSIGNMENT, TOKEN_OPERATOR_ATSIGN, TOKEN_OPERATOR_BITWISE_AND, TOKEN_OPERATOR_BITWISE_AND_ASSIGNMENT, TOKEN_OPERATOR_BITWISE_LEFT_SHIFT, TOKEN_OPERATOR_BITWISE_LEFT_SHIFT_ASSIGNMENT, TOKEN_OPERATOR_BITWISE_NOT, TOKEN_OPERATOR_BITWISE_OR, TOKEN_OPERATOR_BITWISE_OR_ASSIGNMENT, TOKEN_OPERATOR_BITWISE_RIGHT_SHIFT, TOKEN_OPERATOR_BITWISE_RIGHT_SHIFT_ASSIGNMENT, TOKEN_OPERATOR_BITWISE_UNSIGNED_RIGHT_SHIFT, TOKEN_OPERATOR_BITWISE_UNSIGNED_RIGHT_SHIFT_ASSIGNMENT, TOKEN_OPERATOR_BITWISE_XOR, TOKEN_OPERATOR_BITWISE_XOR_ASSIGNMENT, TOKEN_OPERATOR_DECREMENT, TOKEN_OPERATOR_DESCENDANT_ACCESS, TOKEN_OPERATOR_DIVISION, TOKEN_OPERATOR_DIVISION_ASSIGNMENT, TOKEN_OPERATOR_EQUAL, TOKEN_OPERATOR_GREATER_THAN, TOKEN_OPERATOR_GREATER_THAN_EQUALS, TOKEN_OPERATOR_INCREMENT, TOKEN_OPERATOR_LESS_THAN, TOKEN_OPERATOR_LESS_THAN_EQUALS, TOKEN_OPERATOR_LOGICAL_AND, TOKEN_OPERATOR_LOGICAL_AND_ASSIGNMENT, TOKEN_OPERATOR_LOGICAL_NOT, TOKEN_OPERATOR_LOGICAL_OR, TOKEN_OPERATOR_LOGICAL_OR_ASSIGNMENT, TOKEN_OPERATOR_MEMBER_ACCESS, TOKEN_OPERATOR_MINUS, TOKEN_OPERATOR_MINUS_ASSIGNMENT, TOKEN_OPERATOR_MODULO, TOKEN_OPERATOR_MODULO_ASSIGNMENT, TOKEN_OPERATOR_MULTIPLICATION_ASSIGNMENT, TOKEN_OPERATOR_NOT_EQUAL, TOKEN_OPERATOR_NS_QUALIFIER, TOKEN_OPERATOR_PLUS, TOKEN_OPERATOR_PLUS_ASSIGNMENT, TOKEN_OPERATOR_STAR, TOKEN_OPERATOR_STRICT_EQUAL, TOKEN_OPERATOR_STRICT_NOT_EQUAL, TOKEN_OPERATOR_TERNARY, TOKEN_PAREN_CLOSE, TOKEN_PAREN_OPEN, TOKEN_RESERVED_WORD_CONFIG, TOKEN_RESERVED_WORD_EACH, TOKEN_RESERVED_WORD_EXTENDS, TOKEN_RESERVED_WORD_GET, TOKEN_RESERVED_WORD_GOTO, TOKEN_RESERVED_WORD_IMPLEMENTS, TOKEN_RESERVED_WORD_NAMESPACE, TOKEN_RESERVED_WORD_SET, TOKEN_SEMICOLON, TOKEN_SQUARE_CLOSE, TOKEN_SQUARE_OPEN, TOKEN_TYPED_COLLECTION_CLOSE, TOKEN_TYPED_COLLECTION_OPEN, TOKEN_TYPED_LITERAL_CLOSE, TOKEN_TYPED_LITERAL_OPEN, TOKEN_VOID_0
Modifier | Constructor and Description |
---|---|
|
ASParser(IWorkspace workspace,
IRepairingTokenBuffer buffer)
Construct an AS3 parser from a token buffer.
|
|
ASParser(IWorkspace workspace,
IRepairingTokenBuffer buffer,
boolean parsingProjectConfigVariables)
Construct an AS3 parser for parsing command line config args
|
|
ASParser(antlr.ParserSharedInputState state) |
|
ASParser(antlr.TokenBuffer tokenBuf) |
protected |
ASParser(antlr.TokenBuffer tokenBuf,
int k) |
|
ASParser(antlr.TokenStream lexer) |
protected |
ASParser(antlr.TokenStream lexer,
int k) |
Modifier and Type | Method and Description |
---|---|
ExpressionNodeBase |
accessPart()
Matches parts after the dot in a property access expression.
|
protected void |
addConditionalCompilationNamespace(NamespaceNode node) |
void |
addProblem(ICompilerProblem problem)
Adds an
ICompilerProblem to this reporter |
protected void |
afterInnerSubstatement()
Ignore missing semicolons in the following two cases:
do x++ while (x<10); // after x++
if (x<10) x++ else x--; // after x++
|
protected boolean |
afterRestrictedToken(ASToken current)
Call this method in the grammar once a "restricted token" is matched.
|
void |
argumentList(ContainerNode args)
Matches an argument list in a function call arguments.
|
ExpressionNodeBase |
arguments(ExpressionNodeBase root)
Matches the arguments of a function call: allcharacters between (...)
|
ExpressionNodeBase |
arrayElement()
Matches an "array element" in an "array literal".
|
void |
arrayElements(ContainerNode b)
Matches all the elements in an "arrayInitializer".
|
void |
arrayInitializer(ArrayLiteralNode node)
Matches array literal.
|
void |
asDocComment()
Matches an ASDoc block.
|
ExpressionNodeBase |
assignmentExpression()
Matches an "assignment expression".
|
ExpressionNodeBase |
assignmentRightValue()
Matches the right-hand side of an assignment expression.
|
ASToken |
assignOp() |
void |
attribute(List<ModifierNode> modifiers,
List<INamespaceDecorationNode> namespaceAttributes)
Matches an attribute such as:
- Modifiers: dynamic, final, native, override, static, virtual
|
void |
attributedDefinition(ContainerNode c)
Matches an attributed definition.
|
protected boolean |
beforeRestrictedToken(ASToken nextToken)
See Javadoc for
afterRestrictedToken(ASToken) for details about
"restricted token" and semicolon insertion. |
ExpressionNodeBase |
binaryExpr()
Binary expression uses operator precedence parser in BaseASParser.
|
void |
binaryOperators()
Declares all the binary operators.
|
void |
block(ContainerNode b)
Matches a block.
|
DynamicAccessNode |
bracketExpression(ExpressionNodeBase root)
Matches a bracket expression.
|
void |
breakOrContinueStatement(ContainerNode c)
Matches a "break statement" or a "continue statement".
|
void |
caseClause(ContainerNode swb)
Matches a single "case" clause in a "switch" statement.
|
void |
caseClauses(ContainerNode swb)
Matches the "case" clauses in a "switch" statement.
|
void |
cases(SwitchNode sw)
Matches the "case" block in a "switch" statement.
|
void |
caseStatementList(ContainerNode b)
Matches the statements in a "case" clause.
|
void |
catchBlock(TryNode tryNode)
Matches the "catch" block in a "try" statement.
|
ParameterNode |
catchBlockArgument()
Matches the argument in the "try...catch(arg)" statement.
|
ChainedVariableNode |
chainedVariable(ContainerNode c)
Matches a chained variable/constant definition.
|
protected void |
checkForChainedNamespaceQualifierProblem(ASToken nsAccessOp,
ExpressionNodeBase right)
Check for syntax error of chained namespace qualifiers:
ns1::ns2::ns3::foo = 10;
|
protected void |
checkNamespaceDefinition(NamespaceNode ns)
Check if the namespace conflicts with a config namespace
|
void |
classDefinition(ContainerNode c,
INamespaceDecorationNode namespace,
List<ModifierNode> modList)
Matches a class definition.
|
void |
classOrInterfaceBlock(BlockNode b)
Matches the content block of a class definition or an interface definition.
|
void |
colon()
Matches a colon token ":" or recover from a missing colon.
|
ExpressionNodeBase |
condExpr()
Matches a ternary expression such as:
(x > 2) ?
|
boolean |
configCondition()
Matches a config condition such as "CONFIG::debug".
|
boolean |
configConditionOfDefinition()
Similar to "configCondition", only that the token type after "::" is
"TOKEN_NAMESPACE_ANNOTATION".
|
void |
configNamespace(ContainerNode c)
Matches a "config namespace foo" directive.
|
void |
consume() |
protected void |
consumeParsingError(antlr.RecognitionException ex) |
protected void |
consumeParsingError(antlr.RecognitionException ex,
int endToken)
Create a syntax error or warning based on the
RecognitionException . |
protected void |
consumeUntilKeywordOr(Integer... types)
Consume until a keyword, EOF or specified token types.
|
protected void |
consumeUntilKeywordOrIdentifier(int exitCondition)
Consume until one of the following tokens:
keyword
identifier
EOF
metadata tag
ASDoc comment
token type of the given exit condition
|
void |
defaultXMLNamespaceStatement(ContainerNode c)
Matches a default XML namespace statement.
|
void |
definition(ContainerNode c,
INamespaceDecorationNode ns,
List<ModifierNode> modList)
Matches a definition of variable, function, namespace, class or interface.
|
void |
directive(ContainerNode c,
int endToken)
Matches a "directive" level input.
|
protected void |
disableSemicolonInsertion() |
protected void |
disconnect()
Close the parser and release resources.
|
void |
doStatement(ContainerNode c)
Matches a "do...while" statement.
|
boolean |
elsePart(IfNode i)
Matches the optional "else" block of an "if" statement.
|
void |
emptyStatement()
Matches an empty statement which is an explicit semicolon.
|
protected void |
enableSemicolonInsertion() |
protected void |
encounteredImport(ImportNode importNode) |
protected void |
endContainerAtError(antlr.RecognitionException ex,
NodeBase node) |
protected void |
enterClassDefinition(ASToken keywordClass)
Check if class definition is allowed.
|
protected void |
enterGroup()
Enter a "group" and increment the depth counter.
|
protected void |
enterInterfaceDefinition(ASToken keywordInterface)
Check if interface definition is allowed.
|
protected void |
enterPackage(ASToken keywordPackage)
Increment package depth counter and check for
NestedPackageProblem . |
protected void |
enterTypeApplication(ExpressionNodeBase collectionExpression)
Called when the parser enters a type application expression.
|
protected void |
enterXMLLiteral()
Called when start parsing an XML literal.
|
protected boolean |
evaluateConfigurationVariable(IdentifierNode configNamespace,
ASToken opToken,
IdentifierNode configVar)
Evaluate configuration variable result.
|
protected LiteralNode |
evaluateConstNodeExpression(ConfigExpressionNode node) |
protected IdentifierNode |
expectingIdentifier(antlr.NoViableAltException ex)
Force the parser to report a
MismatchedTokenException when failed
to parse an identifier. |
ExpressionNodeBase |
expression()
Matches an expression or a comma-separated expression list.
|
void |
expressionStatement(ContainerNode c)
Matches an "expression statement".
|
void |
fakeExpr()
fakeExpr simulates the set of allowable follow tokens in an expression context, which allows antlr to function.
|
void |
file(ContainerNode c)
Parses an ActionScript3 file and populate the FileNode.
|
void |
fileLevelDirectives(ContainerNode c)
Matches multiple directives.
|
void |
forCondition(ContainerNode c)
Matches the "condition" part in a for loop.
|
NodeBase |
forInitializer()
Matches the "initializer" part in a for loop.
|
void |
formal(ContainerNode c)
Matches a single parameter in a function definition.
|
void |
formalParameters(ContainerNode c)
Matches the parameters of a function definition signature (excluding the parenthesis).
|
void |
forStatement(ContainerNode c)
Matches a "for loop" statement.
|
void |
forStep(ContainerNode c)
Matches the "step" part in a for loop.
|
protected void |
foundExtraCharacterAfterEndOfProgram(ASToken token)
Call this method when extra characters were found after the end of the
program.
|
void |
functionBlock(FunctionNode f,
ASToken openT)
Matches a function block, excluding the open "{" but including the closing "}".
|
void |
functionDefinition(ContainerNode c,
INamespaceDecorationNode namespace,
List<ModifierNode> modList)
Matches a function definition.
|
FunctionObjectNode |
functionExpression()
Matches an anonymous function (function closure).
|
String |
getSourceFilePath()
Gets the source file that we are reporting for
|
Collection<ICompilerProblem> |
getSyntaxProblems() |
void |
gotoStatement(ContainerNode c)
Matches a "goto" statement.
|
void |
groupDirective(ContainerNode c,
int endToken)
Matches a "group" in a "group directive".
|
void |
groupDirectiveWithConfigVariable(ContainerNode c,
int endToken)
Matches a group of directives gated with configuration variable.
|
protected IdentifierNode |
handleMissingIdentifier(antlr.RecognitionException ex)
handles a case where we expected an identifier but our production
produced an error, while we were trying to produce a short name.
|
protected ExpressionNodeBase |
handleMissingIdentifier(antlr.RecognitionException ex,
ExpressionNodeBase n)
handles a case where we expected an identifier but our production
produced an error, while we were trying to produce a dotted name.
|
protected boolean |
handleParsingError(antlr.RecognitionException ex) |
protected boolean |
handleParsingError(antlr.RecognitionException ex,
int endToken)
Called by the parser to handle specific error cases we come across.
|
IdentifierNode |
identifier()
Matches an identifier token.
|
void |
ifStatement(ContainerNode c)
Matches an "if" statement.
|
void |
importDirective(ContainerNode c)
Matches an import directive.
|
ExpressionNodeBase |
importName()
Matches an "import-able" name.
|
void |
includeDirective()
Include processing is usually done in the lexer.
|
void |
initializer(IInitializableDefinitionNode v)
Matches an initializer in a variable/constant definition.
|
void |
innerSubstatement(ContainerNode c)
From ASL syntax spec:
InnerSubstatement is defined in the grammar for the sole purpose of specifying side conditions that disambiguate various syntactic ambiguities in a context-sensitive manner specified in Section 5. |
void |
interfaceDefinition(ContainerNode c,
INamespaceDecorationNode namespace,
List<ModifierNode> modList)
Matches an interface definition.
|
protected boolean |
isConfigCondition()
Check if the look-ahead can be matched as a "ConfigCondition".
|
protected boolean |
isConfigNamespace(NamespaceIdentifierNode id) |
protected boolean |
isDefinitionEnabled(ContainerNode containerNode)
Check if the next attribute definition is gated with a configuration
condition variable.
|
protected boolean |
isFunctionClosure()
Disambiguate between a function definition and a function closure.
|
protected boolean |
isGlobalContext()
A syntax tree is in a global context if it is nested by a program
without crossing a block, or nested by the block of a
package directive without crossing another block.
|
protected boolean |
isIncompleteMetadataTagOnDefinition()
Determine if the parser should deploy an error trap for a
typing-in-progress metadata tag on a definition item.
|
protected boolean |
isNextTokenPublicNamespace()
Syntactic predicate for CMP-335.
|
boolean |
isParsingProjectConfigVariables() |
protected boolean |
isXMLAttribute()
Check if the look-ahead can be matched as a "XMLAttribute".
|
int |
LA(int i) |
void |
labeledStatement(ContainerNode c,
int exitCondition)
Matches a "labeled statement".
|
protected void |
leaveGroup()
Leave a "group" and decrement the depth counter.
|
protected void |
leavePackage()
Decrement package depth counter.
|
protected void |
leaveXMLLiteral()
Called when finish parsing an XML literal.
|
ExpressionNodeBase |
lhsExpr()
Matches a left-hand side (of asssignment) expression.
|
protected void |
logMultipleConfigNamespaceDecorationsError(NodeBase source) |
protected void |
logSyntaxError(ASToken badToken)
Logs a syntax error against the given token
|
ASToken |
LT(int i) |
int |
mark() |
void |
match(int t) |
protected boolean |
matchOptionalSemicolon()
Match optional semicolon.
|
ExpressionNodeBase |
memberExpression()
Matches a member expression.
|
void |
meta(ContainerNode c)
Matches a "metadata statement".
|
ModifierNode |
modifierAttribute()
Matches a "modifier attribute" such as "final", "dynamic", "override",
"static" or "native".
|
ExpressionNodeBase |
nameExpression()
This is a non-greedy and non-aggregating version of "restricted name".
|
void |
namespaceDefinition(ContainerNode c,
INamespaceDecorationNode namespace,
List<ModifierNode> modList)
Matches a namespace definition.
|
protected boolean |
namespaceIsConfigNamespace(INamespaceDecorationNode node) |
ExpressionNodeBase |
namespaceModifier()
Matches a namespace modifier on an "attributed definition".
|
ExpressionNodeBase |
newExpression()
Matches a new expression.
|
ExpressionNodeBase |
nsAccessPart()
Matches parts after "::" in a property access expression.
|
ASToken |
numericLiteral()
Matches a numeric literal token.
|
ExpressionNodeBase |
objectLiteralExpression()
Matches an "object literal".
|
ExpressionNodeBase |
objectLiteralValuePair()
Matches a "field" in an "object literal".
|
ExpressionNodeBase |
optExpression()
Matches an optional expression.
|
void |
optionalFunctionBody(FunctionNode f)
Matches an optional function body.
|
void |
packageContents(ContainerNode b)
Matches contents in a package block.
|
void |
packageDirective(ContainerNode c)
Matches a "package" block.
|
ExpressionNodeBase |
packageName()
Matches a package name such as:
org.apache.flex
A Whitespace or LineTerminator is allowed around a . in a PackageName.
|
ParameterNode |
parameter()
Matches a parameter in a function definition.
|
ExpressionNodeBase |
parenExpression()
Matches an expression with parenthesis.
|
static MetaTagsNode |
parseAtFunction(IWorkspace workspace,
String metadataTagText,
String sourcePath,
int start,
int line,
int column,
Collection<ICompilerProblem> problems)
Parse a String of meta data from an @function, by changing a string such
as:
@Embed(source='a.png') to:
[Embed(source='a.png')] and then running it through the meta
data parser |
static IExpressionNode |
parseDataBinding(IWorkspace workspace,
Reader reader,
Collection<ICompilerProblem> problems)
Parses a databinding expression.
|
static ExpressionNodeBase |
parseExpression(IWorkspace workspace,
Reader scriptReader,
Collection<ICompilerProblem> problems,
IProjectConfigVariables variables,
ISourceLocation location)
Parse an expression from the passed in Reader.
|
void |
parseFile(FileNode fileNode,
EnumSet<PostProcessStep> features)
Assemble the tokens into a parse tree with a root FileNode.
|
static FileNode |
parseFile(IFileSpecification spec,
IFileSpecificationGetter fileSpecGetter)
Produces an AST from the given file input.
|
static FileNode |
parseFile(IFileSpecification spec,
IFileSpecificationGetter fileSpecGetter,
EnumSet<PostProcessStep> postProcess,
IProjectConfigVariables variables,
boolean followIncludes)
Produces an AST from the given file input.
|
static FileNode |
parseFile(IFileSpecification spec,
IFileSpecificationGetter fileSpecGetter,
EnumSet<PostProcessStep> postProcess,
IProjectConfigVariables variables,
boolean followIncludes,
boolean allowEmbeds,
List<String> includedFiles,
DeferFunctionBody deferFunctionBody,
IASProject flashProject,
ICompilationUnit compilationUnit)
Produces an AST from the given file input.
|
static ScopedBlockNode |
parseFragment2(String fragment,
String path,
int offset,
int line,
int column,
Collection<ICompilerProblem> problems,
IWorkspace workspace,
IFileNodeAccumulator fileNodeAccumulator,
ASScope containingScope,
IProjectConfigVariables variables,
EnumSet<PostProcessStep> postProcess,
boolean followIncludes,
IncludeHandler includeHandler)
Parse a fragment of ActionScript.
|
static void |
parseFunctionBody(ScopedBlockNode container,
Reader reader,
String path,
ASToken blockOpenToken,
Collection<ICompilerProblem> problems,
IWorkspace workspace,
FileNode fileNode,
ConfigProcessor configProcessor)
Parser entry-point for rebuild function body nodes.
|
static ScopedBlockNode |
parseInlineScript(IFileNodeAccumulator fileNodeAccumulator,
IMXMLTextData mxmlTextData,
Collection<ICompilerProblem> problems,
ASScope containingScope,
IProjectConfigVariables variables,
IncludeHandler includeHandler,
EnumSet<PostProcessStep> postProcess)
Parse a script tag with inline ActionScript.
|
static MetaTagsNode |
parseMetadata(IWorkspace workspace,
String metadataContent,
String sourcePath,
int start,
int line,
int column,
Collection<ICompilerProblem> problems)
Parse metadata tags from a string.
|
protected void |
parseMetadata(antlr.Token attributeToken,
Collection<ICompilerProblem> problems)
Parse metadata tags with a forked sub-parser.
|
static IASNode[] |
parseProjectConfigVariables(IWorkspace workspace,
String fragment,
Collection<ICompilerProblem> problems)
Parses a string into a name valid in ActionScript.
|
ExpressionNodeBase |
postfixExpr()
Matches "Postfix Expression" such as: i++, i--
Since ECMA semicolon insertion rule requires that if a "++" or "--" is not
on the same line as its left-hand side expression, a semicolon is inserted
before the "--" or "++" token.
|
UnaryOperatorNodeBase |
postfixOp(ExpressionNodeBase n)
Matches a "postfix" operator such as: ++, --
The parameter "n" is the expression the postfix operator acts on.
|
protected ExpressionNodeBase |
precedenceParseExpression(int prec)
Operator precedence parser.
|
protected void |
preCheckMetadata(antlr.Token attributeToken,
ContainerNode container)
Determines if the current metadata is found within a pure statement
context, or if it is going to be bound to a definition.
|
ExpressionNodeBase |
prefixExpression()
Matches a "prefix expression".
|
ExpressionNodeBase |
primaryExpression()
Matches a primary expression.
|
ExpressionNodeBase |
propertyAccessExpression(ExpressionNodeBase l)
Matches a property access expression:
For example: (assuming 'foo' is already matched)
foo.bar
foo..bar
foo::bar
foo[bar]
foo.
|
ExpressionNodeBase |
propertyName()
Matches a property name in a member expression.
|
protected void |
recoverFromExpressionStatementMissingSemicolon(ExpressionNodeBase e)
Recover from
CanNotInsertSemicolonProblem after an expression
statement. |
protected void |
recoverFromMetadataTag(ContainerNode container,
ArrayLiteralNode arrayLiteralNode)
Recover from metadata parsing failure.
|
protected void |
reportFunctionBodyMissingLeftBraceProblem()
An optional function body can either be a function block or a semicolon
(virtual semicolon).
|
protected void |
reportUnexpectedTokenProblem(ASToken token)
Report unexpected token problem.
|
ParameterNode |
restParameter()
Matches the "rest parameters" in a function definition.
...args
|
ExpressionNodeBase |
restrictedName()
Matches a restricted name.
|
IdentifierNode |
restrictedNamePart()
Matches the identifier part of a restricted name.
|
void |
resultType(BaseTypedDefinitionNode result)
Matches a result type: either a "void" keyword or a restricted name.
|
void |
returnStatement(ContainerNode c)
Matches a "return" statement.
|
void |
rewind(int pos) |
ExpressionNodeBase |
runtimeName()
Matches a runtime attribute name.
|
void |
setAllowEmbeds(boolean allowEmbeds) |
protected void |
setAllowErrorsInContext(boolean allow) |
protected void |
setConfigProcessor(ConfigProcessor configProcessor)
Bind the current parser to the given
ConfigProcessor . |
protected void |
setOffsetsOfEmptyBlock(IASToken blockToken,
BlockNode block)
Set the offsets of an empty BlockNode generated from a {} token.
|
void |
setProjectConfigVariables(IProjectConfigVariables variables)
Sets the
IProjectConfigVariables to be used to support
conditional compilation |
VariableNode |
singleVariable(IASToken keyword,
INamespaceDecorationNode namespace)
Matches a single variable/constant definition.
|
ExpressionNodeBase |
singleVariableDefExpression(ASToken varToken,
boolean isConst)
Matches a single variable definition in a for loop.
|
protected void |
skipFunctionBody(FunctionNode functionNode,
ASToken openT)
Consume all the tokens in a function body, excluding the open curly and
close curly braces.
|
IdentifierNode |
starLiteral()
Matches a "star" literal token, and create an IdentifierNode for "*".
|
void |
statement(ContainerNode c,
int exitCondition)
Matches a statement.
|
ExpressionNodeBase |
statementParenExpression()
Matches an expression in a pair of parenthesis.
|
protected void |
storeDecorations(BaseDefinitionNode decoratedNode,
ContainerNode node,
INamespaceDecorationNode namespace,
List<ModifierNode> modList)
Stores decorations on the given definition.
|
protected void |
storeEmbedDecoration(VariableNode variable,
IMetaTagsNode metaTags) |
protected void |
storeVariableDecorations(VariableNode decoratedNode,
ContainerNode node,
INamespaceDecorationNode namespace,
List<ModifierNode> modList)
Stores decorations on the given variable definition.
|
void |
substatement(ContainerNode c)
Matches a sub-statement.
|
void |
switchStatement(ContainerNode c)
Matches a "switch" statement.
|
void |
throwsStatement(ContainerNode c)
Matches a "throw" statement.
|
protected ExpressionNodeBase |
transformToNSAccessExpression(ExpressionNodeBase left,
ASToken op,
ExpressionNodeBase right)
Create AST for various types of namespace access expressions.
|
protected void |
trapInvalidNamespaceAttribute(ASToken offendingNSToken)
Traps erroneous syntax like:
package foo
{
ns1 private class T {}
}
|
protected void |
trapInvalidSubstatement(ASToken offendingNSToken)
Traps erroneous syntax like:
innerLabel: namespace ns1;
Although the
InvalidAttributeProblem doesn't make much sense in
this context, we are just being compatible with the old ASC's behavior. |
void |
tryStatement(ContainerNode c)
Matches a "try...catch...finally" statement.
|
ExpressionNodeBase |
type()
Matches a type reference.
|
TypedExpressionNode |
typeApplication(ExpressionNodeBase root)
Matches a "type application" part>
.
|
ExpressionNodeBase |
typedNameOrStar()
Keep legacy rule for Falcon-JS.
|
ExpressionNodeBase |
unaryExpr()
Matches a "unary expression".
|
ASToken |
unaryOp()
Matches a unary operator.
|
protected ICompilerProblem |
unexpectedTokenProblem(ASToken site,
IASToken.ASTokenKind expectedKind)
Log an "unexpected token" problem.
|
void |
useNamespaceDirective(ContainerNode c)
Matches "use namespace ns" directive.
|
NodeBase |
variableDefExpression()
Matches variable definitions in a for loop.
|
void |
variableDefinition(ContainerNode c,
INamespaceDecorationNode namespace,
List<ModifierNode> modList)
Matches a variable/constant definition.
|
ASToken |
varOrConst()
Matches keyword "var" or keyword "const".
|
void |
vectorLiteralContents(ContainerNode b)
Matches a "vector element" in a vector initializer.
|
VectorLiteralNode |
vectorLiteralExpression()
Matches a "vector initializer".
|
protected void |
verifyNamespaceAttributes(List<INamespaceDecorationNode> namespaceAttributes)
Make sure there's at most one namespace attribute found.
|
IdentifierNode |
voidLiteral()
Matches a "void" keyword token, and create an IdentifierNode for "void".
|
void |
whileStatement(ContainerNode c)
Matches a "while" loop statement.
|
void |
withStatement(ContainerNode c)
Matches a "with" statement.
|
void |
xmlAttribute(BaseLiteralContainerNode n)
Matches an XML attribute.
|
void |
xmlAttributeBlock(BaseLiteralContainerNode n)
Matches a binding expression in an XML literal attribute name.
|
ExpressionNodeBase |
xmlAttributeName()
Matches an E4X attribute name.
|
void |
xmlContentBlock(BaseLiteralContainerNode n)
Matches a binding expression in an XML literal.
|
void |
xmlElementContent(BaseLiteralContainerNode n)
Matches an expression block in XML literals.
|
protected void |
xmlEmptyTagEnd(ASToken token)
Called when a
/> token is encountered. |
XMLLiteralNode |
xmlInitializer()
Matches "XML literal expression".
|
XMLListLiteralNode |
xmlListInitializer()
Matches an E4X XML list expression.
|
void |
xmlMarkup()
Matches an XML comment, XML CDATA or XML PI token.
|
void |
xmlTag(BaseLiteralContainerNode n)
Matches an XML tag.
|
protected void |
xmlTagClose(ASToken token)
Called when a
</foo token is encountered. |
protected void |
xmlTagOpen(ASToken token)
Called when a
<foo token is encountered. |
protected void |
xmlTagOpenBinding(ASToken token)
Called when a
< token is encountered. |
void |
xmlToken(BaseLiteralContainerNode n)
Matches an E4X token that can be aggregated in "xmlTokenAggregated".
|
void |
xmlWhitespace(BaseLiteralContainerNode n)
Match XML whitespace tokens.
|
addMessageListener, addParserListener, addParserMatchListener, addParserTokenListener, addSemanticPredicateListener, addSyntacticPredicateListener, addTraceListener, consumeUntil, consumeUntil, defaultDebuggingSetup, getAST, getASTFactory, getFilename, getInputState, getTokenName, getTokenNames, getTokenTypeToASTClassMap, isDebugMode, match, matchNot, panic, recover, removeMessageListener, removeParserListener, removeParserMatchListener, removeParserTokenListener, removeSemanticPredicateListener, removeSyntacticPredicateListener, removeTraceListener, reportError, reportError, reportWarning, setASTFactory, setASTNodeClass, setASTNodeType, setDebugMode, setFilename, setIgnoreInvalidDebugCalls, setInputState, setTokenBuffer, traceIndent
public static final String[] _tokenNames
public static final antlr.collections.impl.BitSet _tokenSet_0
public static final antlr.collections.impl.BitSet _tokenSet_1
public static final antlr.collections.impl.BitSet _tokenSet_2
public static final antlr.collections.impl.BitSet _tokenSet_3
public static final antlr.collections.impl.BitSet _tokenSet_4
public static final antlr.collections.impl.BitSet _tokenSet_5
public static final antlr.collections.impl.BitSet _tokenSet_6
public static final antlr.collections.impl.BitSet _tokenSet_7
public static final antlr.collections.impl.BitSet _tokenSet_8
public static final antlr.collections.impl.BitSet _tokenSet_9
public static final antlr.collections.impl.BitSet _tokenSet_10
public static final antlr.collections.impl.BitSet _tokenSet_11
public static final antlr.collections.impl.BitSet _tokenSet_12
public static final antlr.collections.impl.BitSet _tokenSet_13
public static final antlr.collections.impl.BitSet _tokenSet_14
public static final antlr.collections.impl.BitSet _tokenSet_15
public static final antlr.collections.impl.BitSet _tokenSet_16
public static final antlr.collections.impl.BitSet _tokenSet_17
public static final antlr.collections.impl.BitSet _tokenSet_18
public static final antlr.collections.impl.BitSet _tokenSet_19
public static final IProjectConfigVariables EMPTY_CONFIGURATION
protected static final int NO_END_TOKEN
protected IRepairingTokenBuffer buffer
protected MetaTagsNode currentAttributes
protected final IASParserASDocDelegate asDocDelegate
IASParserASDocDelegate
used to track ASDoc information.protected antlr.Token errorToken
protected boolean allowEmbeds
protected boolean insideClass
protected final Set<ICompilerProblem> errors
protected DeferFunctionBody deferFunctionBody
protected BaseASParser.ExpressionMode expressionMode
ASParser
updates
this field according to its context.public ASParser(IWorkspace workspace, IRepairingTokenBuffer buffer)
public ASParser(IWorkspace workspace, IRepairingTokenBuffer buffer, boolean parsingProjectConfigVariables)
protected ASParser(antlr.TokenBuffer tokenBuf, int k)
public ASParser(antlr.TokenBuffer tokenBuf)
protected ASParser(antlr.TokenStream lexer, int k)
public ASParser(antlr.TokenStream lexer)
public ASParser(antlr.ParserSharedInputState state)
public final void fileLevelDirectives(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void directive(ContainerNode c, int endToken) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void groupDirective(ContainerNode c, int endToken) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void statement(ContainerNode c, int exitCondition) throws antlr.RecognitionException, antlr.TokenStreamException
super(args);
are matched as regular
"call" expressions.antlr.RecognitionException
antlr.TokenStreamException
public final void attributedDefinition(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void asDocComment() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void importDirective(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void useNamespaceDirective(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void groupDirectiveWithConfigVariable(ContainerNode c, int endToken) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void packageDirective(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void configNamespace(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void includeDirective() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final boolean configConditionOfDefinition() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void attribute(List<ModifierNode> modifiers, List<INamespaceDecorationNode> namespaceAttributes) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void definition(ContainerNode c, INamespaceDecorationNode ns, List<ModifierNode> modList) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ModifierNode modifierAttribute() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase namespaceModifier() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void variableDefinition(ContainerNode c, INamespaceDecorationNode namespace, List<ModifierNode> modList) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void functionDefinition(ContainerNode c, INamespaceDecorationNode namespace, List<ModifierNode> modList) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void namespaceDefinition(ContainerNode c, INamespaceDecorationNode namespace, List<ModifierNode> modList) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void classDefinition(ContainerNode c, INamespaceDecorationNode namespace, List<ModifierNode> modList) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void interfaceDefinition(ContainerNode c, INamespaceDecorationNode namespace, List<ModifierNode> modList) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final boolean configCondition() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void breakOrContinueStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void defaultXMLNamespaceStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void gotoStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void emptyStatement() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void labeledStatement(ContainerNode c, int exitCondition) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void expressionStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void forStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void ifStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void meta(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void returnStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void switchStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void throwsStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void tryStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void whileStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void doStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void withStatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase expression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void innerSubstatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
InnerSubstatement is defined in the grammar for the sole purpose of specifying side conditions that disambiguate various syntactic ambiguities in a context-sensitive manner specified in Section 5.It is only used in "do statement" and "if statement" to loosen the following two cases allowed by AS3 but not by ECMA5.
do x++ while (x < 10); // ES5 would require a ; after x++
if (x > 10) x++ else y++; // ES5 would require a ; after x++
antlr.RecognitionException
antlr.TokenStreamException
public final void substatement(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void block(ContainerNode b) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase importName() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase restrictedName() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void arrayInitializer(ArrayLiteralNode node) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase packageName() throws antlr.RecognitionException, antlr.TokenStreamException
package a . b { }The resulting PackageName value is equivalent to a PackageName without any intervening Whitespace and LineTerminators.
antlr.RecognitionException
antlr.TokenStreamException
public final void packageContents(ContainerNode b) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final IdentifierNode identifier() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void initializer(IInitializableDefinitionNode v) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void classOrInterfaceBlock(BlockNode b) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase type() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final FunctionObjectNode functionExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void formalParameters(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void resultType(BaseTypedDefinitionNode result) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void functionBlock(FunctionNode f, ASToken openT) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void optionalFunctionBody(FunctionNode f) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void formal(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParameterNode restParameter() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParameterNode parameter() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ASToken varOrConst() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final IdentifierNode voidLiteral() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase assignmentRightValue() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final VariableNode singleVariable(IASToken keyword, INamespaceDecorationNode namespace) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ChainedVariableNode chainedVariable(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final NodeBase variableDefExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase singleVariableDefExpression(ASToken varToken, boolean isConst) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase assignmentExpression() throws antlr.RecognitionException, antlr.TokenStreamException
100 = "hello";
This statement will be parsed without syntax error, generating tree like:
= / \ 100 "hello"A possible solution to this is to find out the difference between "conditional expression" and "left-hand side expression", then insert a semantic predicate before matching a "assignment operator".
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase statementParenExpression() throws antlr.RecognitionException, antlr.TokenStreamException
if (...)
, while (...)
, etc.
(....)antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase optExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final NodeBase forInitializer() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void forCondition(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void forStep(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void catchBlock(TryNode tryNode) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ParameterNode catchBlockArgument() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final boolean elsePart(IfNode i) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void cases(SwitchNode sw) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void caseClauses(ContainerNode swb) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void caseClause(ContainerNode swb) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void colon() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void caseStatementList(ContainerNode b) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final IdentifierNode starLiteral() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final IdentifierNode restrictedNamePart() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final DynamicAccessNode bracketExpression(ExpressionNodeBase root) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase typedNameOrStar() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final TypedExpressionNode typeApplication(ExpressionNodeBase root) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase condExpr() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ASToken assignOp() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase binaryExpr() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void fakeExpr() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase unaryExpr() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void binaryOperators() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase prefixExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase postfixExpr() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase lhsExpr() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ASToken unaryOp() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase propertyAccessExpression(ExpressionNodeBase l) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase arguments(ExpressionNodeBase root) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final UnaryOperatorNodeBase postfixOp(ExpressionNodeBase n) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase primaryExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ASToken numericLiteral() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase objectLiteralExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final XMLLiteralNode xmlInitializer() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final XMLListLiteralNode xmlListInitializer() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase objectLiteralValuePair() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void arrayElements(ContainerNode b) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase arrayElement() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final VectorLiteralNode vectorLiteralExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void vectorLiteralContents(ContainerNode b) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void xmlMarkup() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void xmlWhitespace(BaseLiteralContainerNode n) throws antlr.RecognitionException, antlr.TokenStreamException
ContainerNode
is null, drop the
whitespace tokens.antlr.RecognitionException
antlr.TokenStreamException
public final void xmlElementContent(BaseLiteralContainerNode n) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void xmlToken(BaseLiteralContainerNode n) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void xmlTag(BaseLiteralContainerNode n) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void xmlContentBlock(BaseLiteralContainerNode n) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void xmlAttribute(BaseLiteralContainerNode n) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void xmlAttributeBlock(BaseLiteralContainerNode n) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase newExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase parenExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase nameExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase xmlAttributeName() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase memberExpression() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase propertyName() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase accessPart() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase nsAccessPart() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final ExpressionNodeBase runtimeName() throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public final void argumentList(ContainerNode args) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public static FileNode parseFile(IFileSpecification spec, IFileSpecificationGetter fileSpecGetter)
parseFile(spec, workspace, EnumSet.of(PostProcessStep.CALCULATE_OFFSETS), true, true)
meaning we follow includes, fix the tree and calculate offsets.spec
- the IFileSpecification
that points to the file that
will be parsedfileSpecGetter
- the IFileSpecificationGetter
that should be
used to open files.FileNode
built from the given inputpublic static FileNode parseFile(IFileSpecification spec, IFileSpecificationGetter fileSpecGetter, EnumSet<PostProcessStep> postProcess, IProjectConfigVariables variables, boolean followIncludes)
spec
- the IFileSpecification
that points to the file that
will be parsedfileSpecGetter
- the IFileSpecificationGetter
that should be
used to open files.postProcess
- the set of operations we want to perform on this tree
before it is returned. See PostProcessStep
variables
- the IProjectConfigVariables
containing
project-level conditional compilation variablesfollowIncludes
- flag to determine if include statements should be
followedFileNode
built from the given inputpublic static FileNode parseFile(IFileSpecification spec, IFileSpecificationGetter fileSpecGetter, EnumSet<PostProcessStep> postProcess, IProjectConfigVariables variables, boolean followIncludes, boolean allowEmbeds, List<String> includedFiles, DeferFunctionBody deferFunctionBody, IASProject flashProject, ICompilationUnit compilationUnit)
spec
- the IFileSpecification
that points to the file that
will be parsedpostProcess
- the set of operations we want to perform on this tree
before it is returned. See PostProcessStep
variables
- the IProjectConfigVariables
containing
project-level conditional compilation variablesfollowIncludes
- flag to determine if include statements should be
followedallowEmbeds
- flag to indicate if we should ignore embed meta data
or create EmbedNodesincludedFiles
- Files included by asc -in
option.flashProject
- Used to resolve included files in all the source
folders. Use null
if the project is not a IASProject
.compilationUnit
- used to manage missing include files. both project
and compilation unit must be passed if you wish to have compilation units
re-built when their missing referenced files are added to the project.FileNode
built from the given inputpublic static ScopedBlockNode parseFragment2(String fragment, String path, int offset, int line, int column, Collection<ICompilerProblem> problems, IWorkspace workspace, IFileNodeAccumulator fileNodeAccumulator, ASScope containingScope, IProjectConfigVariables variables, EnumSet<PostProcessStep> postProcess, boolean followIncludes, IncludeHandler includeHandler)
containingScope
. This is used by MXML script tags.fragment
- ActionScript block.path
- Containing source path of the ActionScript fragment.offset
- Start offset of the script.line
- Line offset of the script.column
- Column offset of the script.problems
- Problems parsing the script.workspace
- Owner workspace.fileNodeAccumulator
- Collect data that needs to be stored on
FileNode
.containingScope
- The resulting definitions and scopes from the
script will be attached to this scope.variables
- Project config variables.postProcess
- Post process steps.followIncludes
- True if includes are followed.includeHandler
- The include handler to use.public static void parseFunctionBody(ScopedBlockNode container, Reader reader, String path, ASToken blockOpenToken, Collection<ICompilerProblem> problems, IWorkspace workspace, FileNode fileNode, ConfigProcessor configProcessor)
container
- Function body container node.reader
- Function body reader.path
- Source path.blockOpenToken
- "{" of the function body.problems
- Compiler problems.workspace
- Current workspace.fileNode
- AS file node.configProcessor
- Configuration variables.public static ScopedBlockNode parseInlineScript(IFileNodeAccumulator fileNodeAccumulator, IMXMLTextData mxmlTextData, Collection<ICompilerProblem> problems, ASScope containingScope, IProjectConfigVariables variables, IncludeHandler includeHandler, EnumSet<PostProcessStep> postProcess)
Both MXMLScopeBuilder
and MXMLScriptNode
use
this parser entry point. Different post-process tasks are requested.
public static ExpressionNodeBase parseExpression(IWorkspace workspace, Reader scriptReader, Collection<ICompilerProblem> problems, IProjectConfigVariables variables, ISourceLocation location)
public static final IASNode[] parseProjectConfigVariables(IWorkspace workspace, String fragment, Collection<ICompilerProblem> problems)
fragment
- the string that contains a nameIIdentifierNode
, or nullpublic static final IExpressionNode parseDataBinding(IWorkspace workspace, Reader reader, Collection<ICompilerProblem> problems)
protected final void addConditionalCompilationNamespace(NamespaceNode node)
public void setProjectConfigVariables(IProjectConfigVariables variables)
IProjectConfigVariables
to be used to support
conditional compilationvariables
- IProjectConfigVariables
for the given contextprotected final void setConfigProcessor(ConfigProcessor configProcessor)
ConfigProcessor
.configProcessor
- Resolve configuration variables at parse-time.protected final LiteralNode evaluateConstNodeExpression(ConfigExpressionNode node)
protected final boolean isConfigNamespace(NamespaceIdentifierNode id)
public Collection<ICompilerProblem> getSyntaxProblems()
protected final void disconnect()
public String getSourceFilePath()
IProblemReporter
getSourceFilePath
in interface IProblemReporter
protected void setAllowErrorsInContext(boolean allow)
public void addProblem(ICompilerProblem problem)
IProblemReporter
ICompilerProblem
to this reporteraddProblem
in interface IProblemReporter
problem
- an ICompilerProblem
public void setAllowEmbeds(boolean allowEmbeds)
public void parseFile(FileNode fileNode, EnumSet<PostProcessStep> features)
fileNode
- The parser builds AST into this root FileNode
.features
- Post-process steps to be performed.protected void encounteredImport(ImportNode importNode)
public static MetaTagsNode parseAtFunction(IWorkspace workspace, String metadataTagText, String sourcePath, int start, int line, int column, Collection<ICompilerProblem> problems)
@Embed(source='a.png')
to:
[Embed(source='a.png')]
and then running it through the meta
data parsermetadataTagText
- The @function text.problems
- The collection of compiler problems to which this method will add problems.public static MetaTagsNode parseMetadata(IWorkspace workspace, String metadataContent, String sourcePath, int start, int line, int column, Collection<ICompilerProblem> problems)
workspace
- Current workspace.metadataContent
- Source text.sourcePath
- Source path.start
- Start offset.line
- Line offset.column
- Column offset.problems
- Problem collection.MetaTagsNode
containing all the parsed metadata tags.protected final void parseMetadata(antlr.Token attributeToken, Collection<ICompilerProblem> problems)
attributeToken
- Metadata token.problems
- Problem collection.protected final void preCheckMetadata(antlr.Token attributeToken, ContainerNode container)
attributeToken
- the token that contains the metadatacontainer
- the ContainerNode
we will potentially add our
metadata to as a childprotected final boolean isConfigCondition()
protected final boolean isXMLAttribute()
protected void storeVariableDecorations(VariableNode decoratedNode, ContainerNode node, INamespaceDecorationNode namespace, List<ModifierNode> modList)
decoratedNode
- node
- protected void storeEmbedDecoration(VariableNode variable, IMetaTagsNode metaTags)
protected void storeDecorations(BaseDefinitionNode decoratedNode, ContainerNode node, INamespaceDecorationNode namespace, List<ModifierNode> modList)
decoratedNode
- node
- protected final boolean namespaceIsConfigNamespace(INamespaceDecorationNode node)
protected void logMultipleConfigNamespaceDecorationsError(NodeBase source)
protected void checkNamespaceDefinition(NamespaceNode ns)
ns
- the NamespaceNode to checkprotected final ExpressionNodeBase transformToNSAccessExpression(ExpressionNodeBase left, ASToken op, ExpressionNodeBase right)
left
- left-hand side of ::
is the namespace expressionop
- ::
tokenright
- right-hand side of ::
is the variableprotected final void checkForChainedNamespaceQualifierProblem(ASToken nsAccessOp, ExpressionNodeBase right)
ns1::ns2::ns3::foo = 10;
protected void setOffsetsOfEmptyBlock(IASToken blockToken, BlockNode block)
blockToken
- {} tokenblock
- BlockNode corresponding to that tokenprotected final void disableSemicolonInsertion()
protected final void enableSemicolonInsertion()
protected final void consumeParsingError(antlr.RecognitionException ex, int endToken)
RecognitionException
.ex
- ANTLR-generated parsing exception.endToken
- The expected end token for the currently parsing
fragment. It is used to determine the compiler problem type to create.protected final void consumeParsingError(antlr.RecognitionException ex)
protected IdentifierNode expectingIdentifier(antlr.NoViableAltException ex)
MismatchedTokenException
when failed
to parse an identifier. The reason is that an identifier can either be an
IDENTIFIER
token or one of the "contextual reserved words" like
namespace
. Since we always want the error message to be
"Expected ... but got ....", we convert the exception here.ex
- NoViableAltException
thrown in
identifier()
.protected IdentifierNode handleMissingIdentifier(antlr.RecognitionException ex)
ex
- the exception that was thrownIdentifierNode
or null if tree fixing is not turned onprotected ExpressionNodeBase handleMissingIdentifier(antlr.RecognitionException ex, ExpressionNodeBase n)
ex
- the exception that was thrownIdentifierNode
or null if tree fixing is not turned onprotected final void logSyntaxError(ASToken badToken)
badToken
- the token that caused the syntax errorprotected boolean handleParsingError(antlr.RecognitionException ex, int endToken)
ex
- the exception thrown by the parserendToken
- expected end tokenprotected boolean handleParsingError(antlr.RecognitionException ex)
protected void endContainerAtError(antlr.RecognitionException ex, NodeBase node)
public final void consume()
consume
in class antlr.LLkParser
protected boolean matchOptionalSemicolon()
This method will report a CanNotInsertSemicolonProblem
if a
"virtual semicolon" is expected but failed to be inserted, except when
there's already a syntax error on the same line, because the preceding
syntax error might early-terminate a statement, making the parser to
expect a optional semicolon.
It's not "wrong" to always report the semicolon problem. However, it would make too much "noise" on the console, and it would break almost all negative ASC tests.
IRepairingTokenBuffer.matchOptionalSemicolon()
protected void reportFunctionBodyMissingLeftBraceProblem()
MissingLeftBraceBeforeFunctionBodyProblem
occurs. However, we
only report the problem if the function definition parsing doesn't have
other syntax issues so far.protected void consumeUntilKeywordOrIdentifier(int exitCondition)
exitCondition
- Stop if the next token type matches the exit
condition.protected void consumeUntilKeywordOr(Integer... types)
types
- Stop if the next token's type is one of these.public final void match(int t) throws antlr.MismatchedTokenException, antlr.TokenStreamException
match
in class antlr.Parser
antlr.MismatchedTokenException
antlr.TokenStreamException
public final int LA(int i)
LA
in class antlr.LLkParser
public final ASToken LT(int i)
LT
in class antlr.LLkParser
public final int mark()
mark
in class antlr.Parser
public final void rewind(int pos)
rewind
in class antlr.Parser
protected final ExpressionNodeBase precedenceParseExpression(int prec) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
protected void foundExtraCharacterAfterEndOfProgram(ASToken token)
ExtraCharactersAfterEndOfProgramProblem
is only
logged when it's the first error in the current file. Even though this
method might be called multiple times because of the parser recovery
logic, such problem can only be reported once.token
- Token recognized as "extra characters".protected boolean afterRestrictedToken(ASToken current)
When, as the program is parsed from left to right, a token is encountered that is allowed by some production of the grammar, but the production is a restricted production and the token would be the first token for a terminal or nonterminal immediately following the annotation [no LineTerminator here] within the restricted production (and therefore such a token is called a restricted token), and the restricted token is separated from the previous token by at least one LineTerminator, then a semicolon is automatically inserted before the restricted token.
These are the only restricted productions in ECMA grammar:
Expression [no LineTerminator] ++ Expression [no LineTerminator] -- continue [no LineTerminator] Identifier break [no LineTerminator] Identifier return [no LineTerminator] Expression throw [no LineTerminator] ExpressionAs a result, this method should be called after these tokens are matched:
continue, break, return, throw
.current
- The current token should be the restricted token.protected boolean beforeRestrictedToken(ASToken nextToken)
afterRestrictedToken(ASToken)
for details about
"restricted token" and semicolon insertion.nextToken
- The next token should be the restricted token.afterRestrictedToken(ASToken)
protected final ICompilerProblem unexpectedTokenProblem(ASToken site, IASToken.ASTokenKind expectedKind)
site
- offending tokenexpectedKind
- expected token kindUnexpectedTokenProblem
instance.protected void verifyNamespaceAttributes(List<INamespaceDecorationNode> namespaceAttributes)
namespaceAttributes
- A list of namespace attributes.protected final void recoverFromExpressionStatementMissingSemicolon(ExpressionNodeBase e)
CanNotInsertSemicolonProblem
after an expression
statement. Such error pattern is usually a sign of invalid code being
parsed as expressions.
StreamingASTokenizer
might fail.
For example, a contextual reserved keyword like "static" is labeled as
"identifier" instead of "modifier" when the token following "static"
doesn't start a definition. As a result "static" is parsed as a single
variable "expressionStatement", and the following content will be
reported with a CanNotInsertSemicolonProblem
.
Since we want the error reporting to be user-friendly, we need to detect
such cases and override the compiler problems. The pattern is simple: an
ExpressionNodeBase
of type IdentifierNode
and it's
identifier name is one of the contextual reserved keywords:
dynamic
, final
, native
, static
and
override
.
e
- The AST created for the parsed expression.protected void trapInvalidSubstatement(ASToken offendingNSToken)
innerLabel: namespace ns1;Although the
InvalidAttributeProblem
doesn't make much sense in
this context, we are just being compatible with the old ASC's behavior.offendingNSToken
- The offending "namespace" token after the label
and colon.protected void trapInvalidNamespaceAttribute(ASToken offendingNSToken)
package foo { ns1 private class T {} }
offendingNSToken
- The unexpected namespace name token.protected boolean evaluateConfigurationVariable(IdentifierNode configNamespace, ASToken opToken, IdentifierNode configVar)
configNamespace
- The configuration namespace.opToken
- The operator token. Always "::".configVar
- The unqualified configuration variable name.protected final void reportUnexpectedTokenProblem(ASToken token)
token
- Offending token.protected final void skipFunctionBody(FunctionNode functionNode, ASToken openT)
In order to allow lazy-parsing of the skipped function bodies, the contents need to be cached. We can't cache all the tokens because they take up huge amount of memory.
On the other hand, we can't cache the text of the function body by
accessing the underlying Reader
directly, because it isn't
guaranteed to point to the start of the function block when then the
parser sees the function body due to the possible "look-ahead" operations
triggered by the tokenizer.
As a result, it leaves us the only option which is to capture the start and end character offsets of the function body.
Since Reader.skip(long)
is slow, the parser keeps a secondary
Reader
(secondaryReader
) in order to cache the text of
the function body on-the-fly. The text is stored on the corresponding
FunctionNode
.
This feature is turn on only all of the following conditions are true:
IInvisibleCompilationUnit
) unit in the editor.functionNode
- Function node.openT
- The open curly token of the function body.protected final void enterPackage(ASToken keywordPackage)
NestedPackageProblem
.keywordPackage
- "package" keyword token.protected final void enterTypeApplication(ExpressionNodeBase collectionExpression)
MemberAccessExpressionNode
or an
IdentifierNode
.collectionExpression
- The expression node on the left-hand side of
.< >
.protected final void enterGroup()
protected final void leaveGroup()
protected final void enterClassDefinition(ASToken keywordClass)
keywordClass
- class
keyword token.protected final void enterInterfaceDefinition(ASToken keywordInterface)
keywordInterface
- interface
keyword token.protected final void leavePackage()
protected final boolean isGlobalContext()
Note that directive-level blocks are called "groups". Entering a group doesn't cause the parser to leave global context.
protected final boolean isFunctionClosure()
protected final void afterInnerSubstatement()
do x++ while (x<10); // after x++ if (x<10) x++ else x--; // after x++
protected final void recoverFromMetadataTag(ContainerNode container, ArrayLiteralNode arrayLiteralNode)
[ function hello():void {}The incomplete square bracket is expected to be matched as part of a metadata tag, and the following function definition is properly built. However, function objects in array literals are valid:
var fs = [ function f1():void{}, function f2():void{} ];In order to appease code hinting, the recovery logic will hoist the elements in the failed array literal into the parent node of the array literal node.
container
- Parent node of array literal node.arrayLiteralNode
- Array literal node, whose contents will be
hoisted.protected final boolean isIncompleteMetadataTagOnDefinition()
class T { [ public var name:String; [ public override function hello():void {} [ function process(); }The error trap is enabled when the "[" token is the only token on the current line, and the next token can start a definition item.
protected final void xmlTagOpen(ASToken token)
<foo
token is encountered.token
- TOKEN_E4X_OPEN_TAG_START
token.protected final void xmlTagOpenBinding(ASToken token)
<
token is encountered.token
- HIDDEN_TOKEN_E4X
token.protected final void xmlTagClose(ASToken token)
</foo
token is encountered.token
- TOKEN_E4X_CLOSE_TAG_START
token.protected final void xmlEmptyTagEnd(ASToken token)
/>
token is encountered.token
- TOKEN_E4X_EMPTY_TAG_END
token.protected final void enterXMLLiteral()
protected final void leaveXMLLiteral()
protected final boolean isNextTokenPublicNamespace()
protected final boolean isDefinitionEnabled(ContainerNode containerNode)
containerNode
- parent nodepublic final void file(ContainerNode c) throws antlr.RecognitionException, antlr.TokenStreamException
fileLevelDirectives(ContainerNode)
fails. Before retrying, the
parser makes sure one and only one
ExtraCharactersAfterEndOfProgramProblem
is logged. Then, it
discards the offending token and continue matching at "directive" level.
I didn't write this as a regular ANTLR rule because the ANTLR-generated
code wouldn't enter fileLevelDirectives(ContainerNode)
if the
lookahead is not one of the tokens in the "start set".
antlr.RecognitionException
antlr.TokenStreamException
public final boolean isParsingProjectConfigVariables()
Copyright © 2016 The Apache Software Foundation. All rights reserved.