|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.syntax.parser.Parser
Reads the source text and produces a Concrete Syntax Tree. Exceptions
are collected during processing, and parsing will continue for while
possible, in order to report as many problems as possible.
module()
is the primary entry point.
Field Summary | |
private SourceUnit |
controller
|
private static int[] |
EXPRESSION_REDUCE_HANDLERS
|
private static int[] |
EXPRESSION_SHIFT_HANDLERS
|
private int |
nestCount
|
private TokenStream |
tokenStream
|
Constructor Summary | |
Parser(SourceUnit controller,
TokenStream tokenStream)
Sets the Parser to process a TokenStream ,
under control of the specified SourceUnit . |
Method Summary | |
protected Reduction |
assertStatement()
Processes an assert statement. |
Reduction |
bodyStatement()
A synonym for typeBodyStatement( true, true, false ) . |
protected Reduction |
breakStatement()
Processes a break statement. |
Reduction |
classDeclaration(Reduction modifiers)
Processes a class declaration. |
protected Reduction |
closureExpression()
Processes a closure expression. |
protected Token |
consume()
A synonym for consume( Types.ANY, false ) . |
protected Token |
consume(boolean significantNewlines)
A synonym for consume( Types.ANY, significantNewlines ) . |
protected Token |
consume(int type)
A synonym for consume( type, false ) . |
protected Token |
consume(int type,
boolean significantNewlines)
Consumes (and returns) the next token if it is of the specified type. |
protected Reduction |
continueStatement()
Processes a continue statement. |
protected CSTNode |
datatype()
A synonym for datatype( true ) . |
protected CSTNode |
datatype(boolean allowVoid)
Processes a datatype specification. |
CSTNode |
dottedIdentifier()
Processes a dotted identifer. |
protected Reduction |
doWhileStatement()
Processes a do ... |
void |
endOfStatement()
A synonym for endOfStatement( true ) . |
void |
endOfStatement(boolean allowRightCurlyBrace)
Eats a required end-of-statement (semicolon or newline) from the stream. |
protected void |
error()
A synonym for error( null, true, 1, null ) . |
protected void |
error(int expectedType)
A scalar synonym of error( expectedTypes ) . |
protected void |
error(int[] expectedTypes)
A synonym for error( expectedTypes, true, 1, null ) . |
protected UnexpectedTokenException |
error(int[] expectedTypes,
boolean throwIt,
int k)
A synonym for error( expectedTypes, throwIt, k, null ) . |
protected UnexpectedTokenException |
error(int[] expectedTypes,
boolean throwIt,
int k,
java.lang.String comment)
Reports an error by generating and optionally throwing an UnexpectedTokenException . |
protected void |
error(java.lang.String comment)
A synonym for error( null, true, 1, comment ) . |
protected UnexpectedTokenException |
error(Token found,
int[] expectedTypes,
boolean throwIt,
java.lang.String comment)
Reports an error assembled from parts. |
protected void |
error(Token found,
java.lang.String comment)
A synonym for error( found, null, true, comment ) . |
protected CSTNode |
expression()
Processes a single (sub-)expression into a CSTNode. |
protected Reduction |
forStatement()
Processes a for statement. |
TokenStream |
getTokenStream()
Returns the TokenStream being parsed. |
protected Reduction |
gstring()
Processes a GString. |
protected Reduction |
ifStatement()
Processes an if statement. |
Reduction |
importStatement()
Processes an import statement. |
Reduction |
interfaceDeclaration(Reduction modifiers)
Processes a interface declaration. |
protected Token |
la()
Synonym for la( 1, false ) . |
protected Token |
la(boolean significantNewlines)
Synonym for la( 1, significantNewlines ) . |
protected Token |
la(ExpressionStack stack)
Special la() used by the expression parser. |
protected Token |
la(int k)
Synonym for la( k, false ) . |
protected Token |
la(int k,
boolean significantNewlines)
Returns (without consuming) the next kth token in the underlying token stream. |
protected Reduction |
listOrMapExpression()
Synonym for listOrMapExpression( false, false ) . |
protected Reduction |
listOrMapExpression(boolean isMap,
boolean insist)
Processes a list or map expression. |
protected int |
lt()
Returns the meaning of the la() token. |
protected int |
lt(boolean significantNewlines)
Returns the meaning of the la( significantNewlines ) token. |
protected int |
lt(int k)
Returns the meaning of the la( k ) token. |
protected int |
lt(int k,
boolean significantNewlines)
Returns the meaning of the la( k, significantNewlines ) token. |
Reduction |
methodDeclaration(Reduction modifiers,
CSTNode type,
Token identifier,
boolean emptyOnly)
Processes a class/interface method. |
Reduction |
modifierList(boolean allowStatic,
boolean allowAbstract)
Processes the modifiers list that can appear on top- and class-level method and class-level variable names (public, private, abstract, etc.). |
Reduction |
module()
The primary file-level parsing entry point. |
protected Token |
nameDeclaration(boolean significantNewlines)
Processes a name that is valid for declarations. |
protected Token |
nameReference(boolean significantNewlines)
Processes a reference to a declared name. |
protected Reduction |
newExpression()
Processes a "new" expression. |
protected CSTNode |
optionalDatatype(boolean significantNewlines,
boolean allowVoid)
Processes an optional data type marker (for a parameter, method return type, etc.). |
void |
optionalNewlines()
Eats any optional newlines. |
Reduction |
packageDeclaration()
Processes a package declaration. |
protected Reduction |
parameterDeclaration()
Processes a single parameter declaration, which can occur on methods and closures. |
protected Reduction |
parameterDeclarationList()
Processes a parameter declaration list, which can occur on methods and closures. |
protected Reduction |
parameterList()
Processes a NON-EMPTY parameter list, as supplied on either a method invokation or a closure invokation. |
Reduction |
parse()
Synonym for module(), the primary entry point. |
Reduction |
propertyDeclaration(Reduction modifiers,
CSTNode type,
Token identifier)
Processes a class/interface property, including the optional initialization clause. |
void |
recover()
A synonym for recover( Types.ANY_END_OF_STATMENT, true ) . |
void |
recover(int safe)
A synonm for the scalar recover( safe, false ) . |
void |
recover(int[] safe)
A synonym for recover( safe, false ) . |
void |
recover(int[] safe,
boolean ignoreNewlines)
Attempts to recover from an error by discarding input until a known token is found. |
void |
recover(int safe,
boolean ignoreNewlines)
A scalar version of recover( int[], boolean ) . |
protected Reduction |
returnStatement()
Processes a return statement. |
protected CSTNode |
scalarDatatype(boolean allowVoid)
Processes a scalar datatype specification. |
protected CSTNode |
statement()
Synonym for statement( false ) . |
protected CSTNode |
statement(boolean allowUnlabelledBlocks)
Processes a single statement. |
protected CSTNode |
statementBody(boolean requireBraces)
Processes the body of a complex statement (like "if", "for", etc.). |
protected Reduction |
statementsUntilRightCurly()
Reads statements until a "}" is met. |
protected Reduction |
switchStatement()
Processes a switch statement. |
protected Reduction |
synchronizedStatement()
Processes a synchronized statement. |
protected Reduction |
throwStatement()
Processes a throw statement. |
CSTNode |
topLevelStatement()
Processes a top level statement (classes, interfaces, unattached methods, and unattached code). |
protected Reduction |
tryStatement()
Processes a try statement. |
protected Reduction |
tupleExpression(int level,
int depth)
Processes a "new" array initializer expression. |
Reduction |
typeBody(boolean allowStatic,
boolean allowAbstract,
boolean requireAbstract)
Processes the body of an interface or class. |
Reduction |
typeBodyStatement(boolean allowStatic,
boolean allowAbstract,
boolean requireAbstract)
Processes a single entry in the the body of an interface or class. |
CSTNode |
typeDeclaration()
A synomym for topLevelStatement() . |
Reduction |
typeList(int declarator,
boolean optional,
int limit)
Processes a type list, like the ones that occur after "extends" or implements. |
protected Reduction |
variableDeclarationExpression(CSTNode datatype)
Processes a typed variable declaration. |
protected Reduction |
whileStatement()
Processes a while statement. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private SourceUnit controller
private TokenStream tokenStream
private int nestCount
private static final int[] EXPRESSION_SHIFT_HANDLERS
private static final int[] EXPRESSION_REDUCE_HANDLERS
Constructor Detail |
public Parser(SourceUnit controller, TokenStream tokenStream)
Parser
to process a TokenStream
,
under control of the specified SourceUnit
.
Method Detail |
public Reduction parse() throws CompilationFailedException
CompilationFailedException
public TokenStream getTokenStream()
TokenStream
being parsed.
public void optionalNewlines() throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
public void endOfStatement(boolean allowRightCurlyBrace) throws SyntaxException, CompilationFailedException
UnexpectedTokenException
if anything else is found.
SyntaxException
CompilationFailedException
public void endOfStatement() throws SyntaxException, CompilationFailedException
endOfStatement( true )
.
SyntaxException
CompilationFailedException
public CSTNode dottedIdentifier() throws SyntaxException, CompilationFailedException
Grammar:
dottedIdentifier =("." )*
CST:
dotted = { "." dotted} |
SyntaxException
CompilationFailedException
public Reduction module() throws SyntaxException, CompilationFailedException
Grammar:
module = [packageStatement] (usingStatement)* (topLevelStatement)*
CST:
module = {package imports (topLevelStatement)* } package see packageDeclaration() imports see importStatement() topLevelStatement see topLevelStatement()
SyntaxException
CompilationFailedException
public Reduction packageDeclaration() throws SyntaxException, CompilationFailedException
module()
.
Grammar:
packageDeclaration = "package" dottedIdentifier
CST:
package = { "package" dottedIdentifier } see dottedIdentifier()
SyntaxException
CompilationFailedException
public Reduction importStatement() throws SyntaxException, CompilationFailedException
module()
.
Grammar:
importStatement = "import" (all|specific)all = package "." (package ".")* "*" specific = (package "." (package ".")*)? classes classes = class ["as" alias] ("," class ["as" alias])* package = class = alias =
CST:
import = { "import" (package|{}) ({"*"} | clause+) } package = { "." package} | clause = { ? }
SyntaxException
CompilationFailedException
public CSTNode topLevelStatement() throws SyntaxException, CompilationFailedException
module()
.
Grammar:
topLevelStatement = methodDeclaration | typeDeclaration | statement typeDeclaration = classDeclaration | interfaceDeclaration
Recognition:
"def" => methodDeclaration "synchronized" "(" => synchronizedStatement modifierList "class" => classDeclaration modifierList "interface" => interfaceDeclaration modifierList =>* => statement
CST:
see methodDeclaration() see classDeclaration() see interfaceDeclaration() see statement() see synchronizedStatement()
SyntaxException
CompilationFailedException
public CSTNode typeDeclaration() throws SyntaxException, CompilationFailedException
topLevelStatement()
.
SyntaxException
CompilationFailedException
public Reduction modifierList(boolean allowStatic, boolean allowAbstract) throws CompilationFailedException, SyntaxException
Grammar:
modifierList =*
CST:
modifiers = {* }
CompilationFailedException
SyntaxException
public Reduction classDeclaration(Reduction modifiers) throws SyntaxException, CompilationFailedException
Grammar:
classDeclaration =* "class" ["extends" datatype] ["implements" datatype (, datatype)*] typeBody
CST:
class = {:SYNTH_CLASS modifiers extends implements body } extends = { "extends" datatype } | {} implements = { "implements" datatype* } | {} modifiers see modifierList() datatype see datatype() body see typeBody()
SyntaxException
CompilationFailedException
public Reduction interfaceDeclaration(Reduction modifiers) throws SyntaxException, CompilationFailedException
Grammar:
interfaceDeclaration =* "interface" ["extends" typeList] typeBody
CST:
interface = {:SYNTH_INTERFACE modifiers {} extends body } extends = { "extends" datatype* } | {} modifiers see modifierList() datatype see datatype() body see typeBody()
SyntaxException
CompilationFailedException
public Reduction typeList(int declarator, boolean optional, int limit) throws SyntaxException, CompilationFailedException
Grammar:
typeList =datatype (, datatype)*
CST:
typeList = {datatype+ } | {} datatype see datatype()
SyntaxException
CompilationFailedException
public Reduction typeBody(boolean allowStatic, boolean allowAbstract, boolean requireAbstract) throws SyntaxException, CompilationFailedException
Grammar:
typeBody = "{" typeBodyStatement* "}"
CST:
body = {typeBodyStatement* } typeBodyStatement see typeBodyStatement()
SyntaxException
CompilationFailedException
public Reduction typeBodyStatement(boolean allowStatic, boolean allowAbstract, boolean requireAbstract) throws SyntaxException, CompilationFailedException
Grammar:
typeBodyStatement = staticInitializer | classDeclaration | interfaceDeclaration | propertyDeclaration | methodDeclaration staticInitializer = ("static" "{" statement* "}")
Recognition:
"static" "{" => staticInitializer modifierList "class" => classDeclaration modifierList "interface" => interfaceDeclaration modifierList ["property"] optionalDatatype identifier "(" => methodDeclaration modifierList ["property"] optionalDatatype identifier ("="|";"|"\n"|"}" => propertyDeclaration * =>
CST:
see classDeclaration() see interfaceDeclaration() see methodDeclaration() see propertyDeclaration()
SyntaxException
CompilationFailedException
public Reduction bodyStatement() throws SyntaxException, CompilationFailedException
typeBodyStatement( true, true, false )
.
SyntaxException
CompilationFailedException
protected Token nameDeclaration(boolean significantNewlines) throws SyntaxException, CompilationFailedException
Grammar:
nameDeclaration =
CST:
name =
SyntaxException
CompilationFailedException
protected Token nameReference(boolean significantNewlines) throws SyntaxException, CompilationFailedException
Grammar:
nameReference =|
CST:
name =
SyntaxException
CompilationFailedException
protected CSTNode optionalDatatype(boolean significantNewlines, boolean allowVoid) throws SyntaxException, CompilationFailedException
Grammar:
optionalDatatype = datatype? (?=h)
CST:
result = datatype | {} see datatype()
SyntaxException
CompilationFailedException
public Reduction propertyDeclaration(Reduction modifiers, CSTNode type, Token identifier) throws SyntaxException, CompilationFailedException
Grammar:
propertyDeclaration = (modifierList optionalDatatype nameDeclaration ["=" expression])
CST:
property = {:SYNTH_PROPERTY modifierList optionalDatatype expression? } see modifierList() see optionalDatatype() see expression()
SyntaxException
CompilationFailedException
public Reduction methodDeclaration(Reduction modifiers, CSTNode type, Token identifier, boolean emptyOnly) throws SyntaxException, CompilationFailedException
emptyOnly
is set, no method body will be allowed.
Grammar:
methodDeclaration = modifierList optionalDatatype identifier "(" parameterDeclarationList ")" [ "throws" typeList ] ( statementBody |)
CST:
method = {:SYNTH_METHOD modifierList optionalDatatype parameterDeclarationList throwsClause statementBody } throwsClause = { "throws" datatype+ } | {} see modifierList() see optionalDatatype() see parameterDeclarationList() see statementBody()
SyntaxException
CompilationFailedException
protected Reduction parameterDeclarationList() throws SyntaxException, CompilationFailedException
Grammar:
parameterDeclarationList = (parameterDeclaration ("," parameterDeclaration)* ("," parameterDeclaration "=" expression)* )? | (parameterDeclaration "=" expression ("," parameterDeclaration "=" expression)* )?
CST:
parameters = {parameter* } parameter = { :SYNTH_PARAMETER_DECLARATION optionalDatatype default? } default = expression
SyntaxException
CompilationFailedException
protected Reduction parameterDeclaration() throws SyntaxException, CompilationFailedException
Grammar:
parameterDeclaration = optionalDatatype nameDeclaration
CST:
parameter = {:SYNTH_PARAMETER_DECLARATION optionalDatatype } see optionalDatatype()
SyntaxException
CompilationFailedException
protected CSTNode datatype(boolean allowVoid) throws SyntaxException, CompilationFailedException
Grammar:
datatype = scalarDatatype ( "[" "]" )* scalarDatatype = dottedIdentifier | "void" | "int" | ...
CST:
datatype = { "[" datatype } | scalar scalar = dottedIdentifier | primitive primitive = "void" | "int" | ... see dottedIdentifier()
SyntaxException
CompilationFailedException
protected CSTNode datatype() throws SyntaxException, CompilationFailedException
datatype( true )
.
SyntaxException
CompilationFailedException
protected CSTNode scalarDatatype(boolean allowVoid) throws SyntaxException, CompilationFailedException
Grammar:
scalarDatatype = dottedIdentifier | "void" | "int" | ...
CST:
scalar = dottedIdentifier | primitive primitive = "void" | "int" | ... see dottedIdentifier()
SyntaxException
CompilationFailedException
protected CSTNode statementBody(boolean requireBraces) throws SyntaxException, CompilationFailedException
requireBraces
if the body must not be just a single
statement.
Grammar:
statementBody = ("{" statement* "}") | statement
CST:
complex = { "{" statement* } simple = statement see statement()
SyntaxException
CompilationFailedException
protected Reduction statementsUntilRightCurly() throws SyntaxException, CompilationFailedException
Grammar:
statementsUntilRightCurly = statement* (?= "}")
CST:
statements = {statement* }
SyntaxException
CompilationFailedException
protected CSTNode statement(boolean allowUnlabelledBlocks) throws SyntaxException, CompilationFailedException
Grammar:
statement = (label ":")? bareStatement bareStatement = (emptyStatement|basicStatement|blockStatement) basicStatement = forStatement | whileStatement | doStatement | continueStatement | breakStatement | ifStatement | tryStatement | throwStatement | synchronizedStatement | switchStatement | returnStatement | assertStatement | expressionlabel = blockStatement = "{" statement* "}" emptyStatement = ";"
Recognition:
";" => emptyStatement=> Statement "{" => expression, then: if it is a closureExpression and has no parameters => blockStatement * => expression
CST:
labelled = {:SYNTH_LABEL bareStatement } bareStatement = emptyStatement | blockStatement | basicStatement emptyStatement = { "{" } blockStatement = { "{" statement* } see forStatement() see whileStatement() see doStatement() see continueStatement() see breakStatement() see ifStatement() see tryStatement() see throwStatement() see synchronizedStatement() see switchStatement() see returnStatement() see assertStatement() see expression()
SyntaxException
CompilationFailedException
protected CSTNode statement() throws SyntaxException, CompilationFailedException
statement( false )
.
SyntaxException
CompilationFailedException
protected Reduction assertStatement() throws SyntaxException, CompilationFailedException
Grammar:
assertStatement = "assert" expression (":" expression)
CST:
assert = { "assert" expression expression? } see expression()
SyntaxException
CompilationFailedException
protected Reduction breakStatement() throws SyntaxException, CompilationFailedException
Grammar:
breakStatement = "break" label?label =
CST:
statement = { "break" label? } label =
SyntaxException
CompilationFailedException
protected Reduction continueStatement() throws SyntaxException, CompilationFailedException
Grammar:
continueStatement = "continue" label?label =
CST:
statement = { "continue" label? } label =
SyntaxException
CompilationFailedException
protected Reduction throwStatement() throws SyntaxException, CompilationFailedException
Grammar:
throwStatement = "throw" expression
CST:
statement = { "throw" expression } see expression()
SyntaxException
CompilationFailedException
protected Reduction ifStatement() throws SyntaxException, CompilationFailedException
Grammar:
ifStatement = ifClause elseIfClause* elseClause? ifClause = "if" "(" expression ")" statementBody elseIfClause = "else" "if" "(" expression ")" statementBody elseClause = "else" statementBody
CST:
if = { "if" expression statementBody else? } else = if | { "else" statementBody } see expression() see statementBody()
SyntaxException
CompilationFailedException
protected Reduction returnStatement() throws SyntaxException, CompilationFailedException
Grammar:
returnStatement = "return" expression?
CST:
statement = { "return" expression? } see expression()
SyntaxException
CompilationFailedException
protected Reduction switchStatement() throws SyntaxException, CompilationFailedException
Grammar:
switchStatment = "switch" "(" expression ")" "{" switchBody "}" switchBody = caseSet* caseSet = (("case" expression ":")+ | ("default" ":")) statement+
CST:
switch = { "switch" expression case* } case = { "case" expression statement* } | { "default" statement* } see expression() see statement()
SyntaxException
CompilationFailedException
protected Reduction synchronizedStatement() throws SyntaxException, CompilationFailedException
Grammar:
synchronizedStatement = "synchronized" "(" expression ")" statementBody
CST:
statement = { "synchronized" expression statementBody } see expression() see statementBody()
SyntaxException
CompilationFailedException
protected Reduction tryStatement() throws SyntaxException, CompilationFailedException
Grammar:
tryStatement = "try" statementBody catchClause* finallyClause? catchClause = "catch" "(" datatype identifier ")" statementBody finallyClause = "finally" statementBody
CST:
try = { "try" statementBody catches finally } catches = {catch* } catch = { "catch" datatype statementBody } finally = {} | statementBody see datatype() see identifier() see statementBody()
SyntaxException
CompilationFailedException
protected Reduction forStatement() throws SyntaxException, CompilationFailedException
Grammar:
forStatement = "for" "(" normal | each ")" statementBody normal = multi ";" expression ";" multi multi = (expression ["," expression]*) each = optionalDatatype nameDeclaration ("in"|":") expression
CST:
for = { "for" header statementBody } header = normal | each each = { ("in"|":") optionalDatatype nameDeclaration expression } normal = {init test incr } init = { expression* } test = expression incr = { expression* } see expression() see nameDeclaration() see statementBody()
SyntaxException
CompilationFailedException
protected Reduction doWhileStatement() throws SyntaxException, CompilationFailedException
Grammar:
doWhileStatement = "do" statementBody "while" "(" expression ")"
CST:
do = { "do" statementBody expression } see expression() see statementBody()
SyntaxException
CompilationFailedException
protected Reduction whileStatement() throws SyntaxException, CompilationFailedException
Grammar:
whileStatement = "while" "(" expression ")" statementBody
CST:
while = { "while" expression statementBody } see expression() see statementBody()
SyntaxException
CompilationFailedException
protected CSTNode expression() throws SyntaxException, CompilationFailedException
Note that the expression parser is rather stupid, in that it cannot
resolve names. Therefore it is little more than a pre-filter, removing
statements that can't possibly be right, but leaving everything that
might be right for semantic analysis by the Analyzer
(which
has access to the symbol table. There was some thought given to eliminating
the CSTs and going right to ASTs, but that option was rejected because
inner classes mean that class name resolution won't work before parsing
is complete.
SyntaxException
CompilationFailedException
protected Reduction variableDeclarationExpression(CSTNode datatype) throws SyntaxException, CompilationFailedException
Grammar:
variableDeclarationExpression = datatype (nameDeclaration "=" expression) ("," nameDeclaration "=" expression)*
CST:
statement = { :datatype declaration+ } declaration = { expression } see expression()
SyntaxException
CompilationFailedException
protected Reduction gstring() throws SyntaxException, CompilationFailedException
Grammar:
gstring = (? "$" "{" expression "}" ?)*
CST:
gstring = {:SYNTH_GSTRING (segment|expression)* } see expression()
SyntaxException
CompilationFailedException
protected Reduction parameterList() throws SyntaxException, CompilationFailedException
Grammar:
parameterList = (regular "," named) | named regular = parameter ("," parameter)* named = nameReference ":" parameter ("," nameReference ":" parameter)* parameter = expression
CST:
parameterList = {regular* named* } regular = expression named = { ":" expression } see expression()
SyntaxException
CompilationFailedException
protected Reduction newExpression() throws SyntaxException, CompilationFailedException
Grammar:
newExpression = "new" scalarDatatype (array|init)? array = ( "[" expression "]" )+ | ( ("[" "]")+ newArrayInitializer ) init = "(" parameterList? ")" (typeBody | closureExpression)?
CST:
new = { "new" arrayType dimensions newArrayInitializer? } | { "new" scalarDataype (parameterList|{}) typeBody? } arrayType = { "{" (arrayType | scalarDatatype) } dimensions = { expression+ } | {} see expression() see scalarDatatype() see typeBody()
SyntaxException
CompilationFailedException
protected Reduction tupleExpression(int level, int depth) throws SyntaxException, CompilationFailedException
Grammar:
tupleExpression = "{" (tupleExpression | (expression ("," expression))? "}"
CST:
initializer = { "{":SYNTH_TUPLE (initializer*|expression*) } see expression()
SyntaxException
CompilationFailedException
protected Reduction closureExpression() throws SyntaxException, CompilationFailedException
Grammar:
closureExpression = "{" parameters statement* "}" parameters = ("|" parameterDeclarationList "|")?
CST:
initializer = { "{":SYNTH_CLOSURE parameters statements } parameters = parameterDeclarationList | {} statements = { statement* } see parameterDeclarationList() see statement()
SyntaxException
CompilationFailedException
protected Reduction listOrMapExpression(boolean isMap, boolean insist) throws SyntaxException, CompilationFailedException
Grammar:
listOrMapExpression = list | map list = "[" (expression ("," expression)*)? "]" map = "[" (":" | mapping+) "]" mapping = expression ":" expression
CST:
list = { "[":SYNTH_LIST expression* } map = { "[":SYNTH_MAP mapping* } mapping = { ":" expression expression } see expression()
SyntaxException
CompilationFailedException
protected Reduction listOrMapExpression() throws SyntaxException, CompilationFailedException
listOrMapExpression( false, false )
.
SyntaxException
CompilationFailedException
protected UnexpectedTokenException error(Token found, int[] expectedTypes, boolean throwIt, java.lang.String comment) throws SyntaxException
SyntaxException
protected UnexpectedTokenException error(int[] expectedTypes, boolean throwIt, int k, java.lang.String comment) throws SyntaxException, CompilationFailedException
UnexpectedTokenException
.
SyntaxException
CompilationFailedException
protected UnexpectedTokenException error(int[] expectedTypes, boolean throwIt, int k) throws SyntaxException, CompilationFailedException
error( expectedTypes, throwIt, k, null )
.
SyntaxException
CompilationFailedException
protected void error(int[] expectedTypes) throws SyntaxException, CompilationFailedException
error( expectedTypes, true, 1, null )
.
SyntaxException
CompilationFailedException
protected void error() throws SyntaxException, CompilationFailedException
error( null, true, 1, null )
.
SyntaxException
CompilationFailedException
protected void error(java.lang.String comment) throws SyntaxException, CompilationFailedException
error( null, true, 1, comment )
.
SyntaxException
CompilationFailedException
protected void error(Token found, java.lang.String comment) throws SyntaxException
error( found, null, true, comment )
.
SyntaxException
protected void error(int expectedType) throws SyntaxException, CompilationFailedException
error( expectedTypes )
.
SyntaxException
CompilationFailedException
public void recover(int[] safe, boolean ignoreNewlines) throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
public void recover(int safe, boolean ignoreNewlines) throws SyntaxException, CompilationFailedException
recover( int[], boolean )
.
SyntaxException
CompilationFailedException
public void recover(int[] safe) throws SyntaxException, CompilationFailedException
recover( safe, false )
.
SyntaxException
CompilationFailedException
public void recover(int safe) throws SyntaxException, CompilationFailedException
recover( safe, false )
.
SyntaxException
CompilationFailedException
public void recover() throws SyntaxException, CompilationFailedException
recover( Types.ANY_END_OF_STATMENT, true )
.
SyntaxException
CompilationFailedException
protected Token la(int k, boolean significantNewlines) throws SyntaxException, CompilationFailedException
SyntaxException
CompilationFailedException
protected Token la(int k) throws SyntaxException, CompilationFailedException
la( k, false )
.
SyntaxException
CompilationFailedException
protected Token la(boolean significantNewlines) throws SyntaxException, CompilationFailedException
la( 1, significantNewlines )
.
SyntaxException
CompilationFailedException
protected Token la() throws SyntaxException, CompilationFailedException
la( 1, false )
.
SyntaxException
CompilationFailedException
protected Token la(ExpressionStack stack) throws SyntaxException, CompilationFailedException
la()
used by the expression parser. It will get the next token
in the current statement. If the next token is past a line boundary and might be
the start of the next statement, it won't cross the line to get it.
SyntaxException
CompilationFailedException
protected int lt(int k, boolean significantNewlines) throws SyntaxException, CompilationFailedException
la( k, significantNewlines )
token.
SyntaxException
CompilationFailedException
protected int lt(int k) throws SyntaxException, CompilationFailedException
la( k )
token.
SyntaxException
CompilationFailedException
protected int lt(boolean significantNewlines) throws SyntaxException, CompilationFailedException
la( significantNewlines )
token.
SyntaxException
CompilationFailedException
protected int lt() throws SyntaxException, CompilationFailedException
la()
token.
SyntaxException
CompilationFailedException
protected Token consume(int type, boolean significantNewlines) throws SyntaxException, CompilationFailedException
significantNewlines
is set, newlines will not automatically
be consumed; otherwise they will. Throws UnexpectedTokenException
if the type doesn't match.
SyntaxException
CompilationFailedException
protected Token consume(int type) throws SyntaxException, CompilationFailedException
consume( type, false )
. If type is Types.NEWLINE,
equivalent to consume( Types.NEWLINE, true )
.
SyntaxException
CompilationFailedException
protected Token consume() throws SyntaxException, CompilationFailedException
consume( Types.ANY, false )
.
SyntaxException
CompilationFailedException
protected Token consume(boolean significantNewlines) throws SyntaxException, CompilationFailedException
consume( Types.ANY, significantNewlines )
.
If you pass true, it will consume exactly the next token from the
stream.
SyntaxException
CompilationFailedException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |