com.sun.tools.javac.parser
Class JavacParser

java.lang.Object
  extended by com.sun.tools.javac.parser.JavacParser
All Implemented Interfaces:
Parser
Direct Known Subclasses:
EndPosParser

public class JavacParser
extends java.lang.Object
implements Parser

The parser maps a token sequence into an abstract syntax tree. It operates by recursive descent, with code derived systematically from an LL(1) grammar. For efficiency reasons, an operator precedence scheme is used for parsing binary operation expressions.

This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.


Field Summary
(package private)  boolean allowAnnotations
          Switch: should we recognize annotations?
(package private)  boolean allowAsserts
          Switch: should we recognize assert statements, or just give a warning?
(package private)  boolean allowEnums
          Switch: should we recognize enums, or just give a warning?
(package private)  boolean allowForeach
          Switch: should we recognize foreach?
(package private)  boolean allowGenerics
          Switch: Should generics be recognized?
(package private)  boolean allowStaticImport
          Switch: should we recognize foreach?
(package private)  boolean allowVarargs
          Switch: Should varargs be recognized?
(package private)  java.util.Map<JCTree,java.lang.String> docComments
          A hashtable to store all documentation comments indexed by the tree nodes they refer to.
private  int errorEndPos
           
private  int errorPos
           
private  JCTree.JCErroneous errorTree
           
(package private) static int EXPR
          When terms are parsed, the mode determines which is expected: mode = EXPR : an expression mode = TYPE : a type mode = NOPARAMS : no parameters allowed for type mode = TYPEARG : type argument
protected  TreeMaker F
          The factory to be used for abstract syntax tree construction.
private static int infixPrecedenceLevels
          The number of precedence levels of infix operators.
(package private)  boolean keepDocComments
          Switch: should we keep docComments?
(package private)  boolean keepLineMap
          Switch: should we keep line table?
private  Keywords keywords
          The keyword table.
private  int lastmode
          The mode of the term that was parsed last.
private  Log log
          The log to be used for error diagnostics.
private  int mode
          The current mode.
private  Names names
          The name table.
(package private) static int NOPARAMS
           
(package private)  ListBuffer<JCTree.JCExpression[]> odStackSupply
          optimization: To save allocating a new operand/operator stack for every binary operation, we use supplys.
(package private)  ListBuffer<Token[]> opStackSupply
           
private  Lexer S
          The scanner used for lexical analysis.
private  Source source
          The Source language setting.
(package private) static int TYPE
           
(package private) static int TYPEARG
           
 
Constructor Summary
protected JavacParser(ParserFactory fac, Lexer S, boolean keepDocComments, boolean keepLineMap)
          Construct a parser from a given scanner, tree factory and log.
 
Method Summary
 void accept(Token token)
          If next input token matches given token, skip it, otherwise report an error.
(package private)  JCTree.JCAnnotation annotation(int pos)
          Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ]
(package private)  JCTree.JCExpression annotationFieldValue()
          AnnotationFieldValue = AnnotationValue | Identifier "=" AnnotationValue
(package private)  List<JCTree.JCExpression> annotationFieldValues()
          AnnotationFieldValues = "(" [ AnnotationFieldValue { "," AnnotationFieldValue } ] ")"
(package private)  List<JCTree.JCExpression> annotationFieldValuesOpt()
           
(package private)  List<JCTree.JCAnnotation> annotationsOpt()
          AnnotationsOpt = { '@' Annotation }
(package private)  JCTree.JCExpression annotationValue()
           
(package private)  List<JCTree.JCExpression> arguments()
          Arguments = "(" [Expression { COMMA Expression }] ")"
(package private)  JCTree.JCMethodInvocation arguments(List<JCTree.JCExpression> typeArgs, JCTree.JCExpression t)
           
(package private)  JCTree.JCExpression argumentsOpt(List<JCTree.JCExpression> typeArgs, JCTree.JCExpression t)
          ArgumentsOpt = [ Arguments ]
(package private)  JCTree.JCExpression arrayCreatorRest(int newpos, JCTree.JCExpression elemtype)
          ArrayCreatorRest = "[" ( "]" BracketsOpt ArrayInitializer | Expression "]" {"[" Expression "]"} BracketsOpt )
(package private)  JCTree.JCExpression arrayInitializer(int newpos, JCTree.JCExpression t)
          ArrayInitializer = "{" [VariableInitializer {"," VariableInitializer}] [","] "}"
(package private)  void attach(JCTree tree, java.lang.String dc)
          Make an entry into docComments hashtable, provided flag keepDocComments is set and given doc comment is non-null.
(package private)  JCTree.JCPrimitiveTypeTree basicType()
          BasicType = BYTE | SHORT | CHAR | INT | LONG | FLOAT | DOUBLE | BOOLEAN
 JCTree.JCBlock block()
           
(package private)  JCTree.JCBlock block(int pos, long flags)
          Block = "{" BlockStatements "}"
(package private)  List<JCTree.JCStatement> blockStatements()
          BlockStatements = { BlockStatement } BlockStatement = LocalVariableDeclarationStatement | ClassOrInterfaceOrEnumDeclaration | [Ident ":"] Statement LocalVariableDeclarationStatement = { FINAL | '@' Annotation } Type VariableDeclarators ";"
private  JCTree.JCExpression bracketsOpt(JCTree.JCExpression t)
          BracketsOpt = {"[" "]"}
private  JCTree.JCArrayTypeTree bracketsOptCont(JCTree.JCExpression t, int pos)
           
(package private)  JCTree.JCExpression bracketsSuffix(JCTree.JCExpression t)
          BracketsSuffixExpr = "." CLASS BracketsSuffixType =
(package private)  JCTree.JCCatch catchClause()
          CatchClause = CATCH "(" FormalParameter ")" Block
(package private)  void checkAnnotations()
           
protected  JCTree.JCExpression checkExprStat(JCTree.JCExpression t)
          Check that given tree is a legal expression statement.
(package private)  void checkForeach()
           
(package private)  void checkGenerics()
           
(package private)  void checkNoMods(long mods)
          Diagnose a modifier flag from the set, if any.
(package private)  void checkStaticImports()
           
(package private)  void checkVarargs()
           
(package private)  JCTree.JCExpression classCreatorRest(int newpos, JCTree.JCExpression encl, List<JCTree.JCExpression> typeArgs, JCTree.JCExpression t)
          ClassCreatorRest = Arguments [ClassBody]
(package private)  JCTree.JCClassDecl classDeclaration(JCTree.JCModifiers mods, java.lang.String dc)
          ClassDeclaration = CLASS Ident TypeParametersOpt [EXTENDS Type] [IMPLEMENTS TypeList] ClassBody
(package private)  List<JCTree> classOrInterfaceBody(Name className, boolean isInterface)
          ClassBody = "{" {ClassBodyDeclaration} "}" InterfaceBody = "{" {InterfaceBodyDeclaration} "}"
(package private)  List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface)
          ClassBodyDeclaration = ";" | [STATIC] Block | ModifiersOpt ( Type Ident ( VariableDeclaratorsRest ";" | MethodDeclaratorRest ) | VOID Ident MethodDeclaratorRest | TypeParameters (Type | VOID) Ident MethodDeclaratorRest | Ident ConstructorDeclaratorRest | TypeParameters Ident ConstructorDeclaratorRest | ClassOrInterfaceOrEnumDeclaration ) InterfaceBodyDeclaration = ";" | ModifiersOpt Type Ident ( ConstantDeclaratorsRest | InterfaceMethodDeclaratorRest ";" )
(package private)  JCTree.JCStatement classOrInterfaceOrEnumDeclaration(JCTree.JCModifiers mods, java.lang.String dc)
          ClassOrInterfaceOrEnumDeclaration = ModifiersOpt (ClassDeclaration | InterfaceDeclaration | EnumDeclaration)
(package private)  JCTree.JCExpression creator(int newpos, List<JCTree.JCExpression> typeArgs)
          Creator = Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
(package private)  List<JCTree> enumBody(Name enumName)
          EnumBody = "{" { EnumeratorDeclarationList } [","] [ ";" {ClassBodyDeclaration} ] "}"
(package private)  JCTree.JCClassDecl enumDeclaration(JCTree.JCModifiers mods, java.lang.String dc)
          EnumDeclaration = ENUM Ident [IMPLEMENTS TypeList] EnumBody
(package private)  JCTree enumeratorDeclaration(Name enumName)
          EnumeratorDeclaration = AnnotationsOpt [TypeArguments] IDENTIFIER [ Arguments ] [ "{" ClassBody "}" ]
protected  java.lang.StringBuffer foldStrings(JCTree tree)
          If tree is a concatenation of string literals, replace it by a single literal representing the concatenated string.
(package private)  List<JCTree.JCStatement> forInit()
          ForInit = StatementExpression MoreStatementExpressions | { FINAL | '@' Annotation } Type VariableDeclarators
(package private)  JCTree.JCVariableDecl formalParameter()
          FormalParameter = { FINAL | '@' Annotation } Type VariableDeclaratorId LastFormalParameter = { FINAL | '@' Annotation } Type '...' Ident | FormalParameter
(package private)  List<JCTree.JCVariableDecl> formalParameters()
          FormalParameters = "(" [ FormalParameterList ] ")" FormalParameterList = [ FormalParameterListNovarargs , ] LastFormalParameter FormalParameterListNovarargs = [ FormalParameterListNovarargs , ] FormalParameter
(package private)  List<JCTree.JCExpressionStatement> forUpdate()
          ForUpdate = StatementExpression MoreStatementExpressions
 int getEndPos(JCTree tree)
          Get the end position for a tree node.
protected  int getErrorEndPos()
           
 int getStartPos(JCTree tree)
          Get the start position for a tree node.
(package private)  Name ident()
          Ident = IDENTIFIER
(package private)  JCTree.JCExpression illegal()
          Report an illegal start of expression/type error at current position.
(package private)  JCTree.JCExpression illegal(int pos)
          Report an illegal start of expression/type error at given position.
(package private)  JCTree importDeclaration()
          ImportDeclaration = IMPORT [ STATIC ] Ident { "." Ident } [ "." "*" ] ";"
(package private)  JCTree.JCExpression innerCreator(int newpos, List<JCTree.JCExpression> typeArgs, JCTree.JCExpression encl)
          InnerCreator = Ident [TypeArguments] ClassCreatorRest
(package private)  JCTree.JCClassDecl interfaceDeclaration(JCTree.JCModifiers mods, java.lang.String dc)
          InterfaceDeclaration = INTERFACE Ident TypeParametersOpt [EXTENDS TypeList] InterfaceBody
(package private)  boolean isZero(java.lang.String s)
           
(package private)  JCTree.JCExpression literal(Name prefix)
          Literal = INTLITERAL | LONGLITERAL | FLOATLITERAL | DOUBLELITERAL | CHARLITERAL | STRINGLITERAL | TRUE | FALSE | NULL
private  JCTree.JCExpression makeOp(int pos, Token topOp, JCTree.JCExpression od1, JCTree.JCExpression od2)
          Construct a binary or type test node.
(package private)  JCTree methodDeclaratorRest(int pos, JCTree.JCModifiers mods, JCTree.JCExpression type, Name name, List<JCTree.JCTypeParameter> typarams, boolean isInterface, boolean isVoid, java.lang.String dc)
          MethodDeclaratorRest = FormalParameters BracketsOpt [Throws TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";") VoidMethodDeclaratorRest = FormalParameters [Throws TypeList] ( MethodBody | ";") InterfaceMethodDeclaratorRest = FormalParameters BracketsOpt [THROWS TypeList] ";" VoidInterfaceMethodDeclaratorRest = FormalParameters [THROWS TypeList] ";" ConstructorDeclaratorRest = "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody
(package private)  JCTree.JCModifiers modifiersOpt()
          ModifiersOpt = { Modifier } Modifier = PUBLIC | PROTECTED | PRIVATE | STATIC | ABSTRACT | FINAL | NATIVE | SYNCHRONIZED | TRANSIENT | VOLATILE | "@" | "@" Annotation
(package private)  JCTree.JCModifiers modifiersOpt(JCTree.JCModifiers partial)
           
(package private)
<T extends ListBuffer<? super JCTree.JCExpressionStatement>>
T
moreStatementExpressions(int pos, JCTree.JCExpression first, T stats)
          MoreStatementExpressions = { COMMA StatementExpression }
private  JCTree.JCExpression[] newOdStack()
           
private  Token[] newOpStack()
           
(package private) static int optag(Token token)
          Return operation tag of binary operator represented by token, -1 if token is not a binary operator.
(package private)  JCTree.JCModifiers optFinal(long flags)
           
(package private)  JCTree.JCExpression parExpression()
          ParExpression = "(" Expression ")"
 JCTree.JCCompilationUnit parseCompilationUnit()
          CompilationUnit = [ { "@" Annotation } PACKAGE Qualident ";"] {ImportDeclaration} {TypeDeclaration}
 JCTree.JCExpression parseExpression()
          terms can be either expressions or types.
 JCTree.JCStatement parseStatement()
          Statement = Block | IF ParExpression Statement [ELSE Statement] | FOR "(" ForInitOpt ";" [Expression] ";" ForUpdateOpt ")" Statement | FOR "(" FormalParameter : Expression ")" Statement | WHILE ParExpression Statement | DO Statement WHILE ParExpression ";" | TRY Block ( Catches | [Catches] FinallyPart ) | SWITCH ParExpression "{" SwitchBlockStatementGroups "}" | SYNCHRONIZED ParExpression Block | RETURN [Expression] ";" | THROW Expression ";" | BREAK [Ident] ";" | CONTINUE [Ident] ";" | ASSERT Expression [ ":" Expression ] ";" | ";" | ExpressionStatement | Ident ":" Statement emw4: staging additions | "`" Expression
 JCTree.JCExpression parseType()
          Parse a type.
(package private) static int prec(Token token)
          Return precedence of operator represented by token, -1 if token is not a binary operator.
 JCTree.JCExpression qualident()
          Qualident = Ident { DOT Ident }
(package private)  List<JCTree.JCExpression> qualidentList()
          QualidentList = Qualident {"," Qualident}
private  void reportSyntaxError(int pos, java.lang.String key, java.lang.Object... args)
          Report a syntax error at given position using the given argument unless one was already reported at the same position.
private  void setErrorEndPos(int errPos)
           
private  void skip(boolean stopAtImport, boolean stopAtMemberDecl, boolean stopAtIdentifier, boolean stopAtStatement)
          Skip forward until a suitable stop token is found.
protected  void storeEnd(JCTree tree, int endpos)
          Store ending position for a tree.
(package private)  java.lang.String strval(Name prefix)
           
(package private)  JCTree.JCExpression superSuffix(List<JCTree.JCExpression> typeArgs, JCTree.JCExpression t)
          SuperSuffix = Arguments | "." [TypeArguments] Ident [Arguments]
(package private)  List<JCTree.JCCase> switchBlockStatementGroups()
          SwitchBlockStatementGroups = { SwitchBlockStatementGroup } SwitchBlockStatementGroup = SwitchLabel BlockStatements SwitchLabel = CASE ConstantExpression ":" | DEFAULT ":"
private  JCTree.JCErroneous syntaxError(int pos, List<JCTree> errs, java.lang.String key, Token... args)
           
private  JCTree.JCErroneous syntaxError(int pos, java.lang.String key, Token... args)
           
private  JCTree.JCErroneous syntaxError(java.lang.String key)
          Generate a syntax error at current position unless one was already reported at the same position.
private  JCTree.JCErroneous syntaxError(java.lang.String key, Token arg)
          Generate a syntax error at current position unless one was already reported at the same position.
(package private)  JCTree.JCExpression term()
          Expression = Expression1 [ExpressionRest] ExpressionRest = [AssignmentOperator Expression1] AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "&=" | "|=" | "^=" | "%=" | "<<=" | ">>=" | ">>>=" Type = Type1 TypeNoParams = TypeNoParams1 StatementExpression = Expression ConstantExpression = Expression
(package private)  JCTree.JCExpression term(int newmode)
           
(package private)  JCTree.JCExpression term1()
          Expression1 = Expression2 [Expression1Rest] Type1 = Type2 TypeNoParams1 = TypeNoParams2
(package private)  JCTree.JCExpression term1Rest(JCTree.JCExpression t)
          Expression1Rest = ["?" Expression ":" Expression1]
(package private)  JCTree.JCExpression term2()
          Expression2 = Expression3 [Expression2Rest] Type2 = Type3 TypeNoParams2 = TypeNoParams3
(package private)  JCTree.JCExpression term2Rest(JCTree.JCExpression t, int minprec)
           
protected  JCTree.JCExpression term3()
          Expression3 = PrefixOp Expression3 | "(" Expr | TypeNoParams ")" Expression3 | Primary {Selector} {PostfixOp} mgr: added let expression | LET VarDecls IN Expression emw4: staging additions // * | "<|" Statement | Expression "|>" | "<|" { BlockStatements } | Expression "|>" | "`" Expression Primary = "(" Expression ")" | Literal | [TypeArguments] THIS [Arguments] | [TypeArguments] SUPER SuperSuffix | NEW [TypeArguments] Creator | Ident { "." Ident } [ "[" ( "]" BracketsOpt "." CLASS | Expression "]" ) | Arguments | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator ) ] | BasicType BracketsOpt "." CLASS PrefixOp = "++" | "--" | "!" | "~" | "+" | "-" PostfixOp = "++" | "--" Type3 = Ident { "." Ident } [TypeArguments] {TypeSelector} BracketsOpt | BasicType TypeNoParams3 = Ident { "." Ident } BracketsOpt Selector = "." [TypeArguments] Ident [Arguments] | "." THIS | "." [TypeArguments] SUPER SuperSuffix | "." NEW [TypeArguments] InnerCreator | "[" Expression "]" TypeSelector = "." Ident [TypeArguments] SuperSuffix = Arguments | "." Ident [Arguments]
(package private)  JCTree.JCExpression termRest(JCTree.JCExpression t)
           
protected
<T extends JCTree>
T
to(T t)
          Store ending position for a tree.
protected
<T extends JCTree>
T
toP(T t)
          Store ending position for a tree.
(package private)  JCTree.JCExpression typeArgument()
          TypeArgument = Type | "?" | "?" EXTENDS Type {"&" Type} | "?" SUPER Type
(package private)  List<JCTree.JCExpression> typeArguments()
          TypeArguments = "<" TypeArgument {"," TypeArgument} ">"
(package private)  JCTree.JCTypeApply typeArguments(JCTree.JCExpression t)
           
(package private)  List<JCTree.JCExpression> typeArgumentsOpt()
           
(package private)  List<JCTree.JCExpression> typeArgumentsOpt(int useMode)
           
(package private)  JCTree.JCExpression typeArgumentsOpt(JCTree.JCExpression t)
          TypeArgumentsOpt = [ TypeArguments ]
(package private)  JCTree typeDeclaration(JCTree.JCModifiers mods)
          TypeDeclaration = ClassOrInterfaceOrEnumDeclaration | ";"
(package private)  List<JCTree.JCExpression> typeList()
          TypeList = Type {"," Type}
(package private)  JCTree.JCTypeParameter typeParameter()
          TypeParameter = TypeVariable [TypeParameterBound] TypeParameterBound = EXTENDS Type {"&" Type} TypeVariable = Ident
(package private)  List<JCTree.JCTypeParameter> typeParametersOpt()
          TypeParametersOpt = ["<" TypeParameter {"," TypeParameter} ">"]
(package private) static int typetag(Token token)
          Return type tag of basic type represented by token, -1 if token is not a basic type identifier.
(package private) static int unoptag(Token token)
          Return operation tag of unary operator represented by token, -1 if token is not a binary operator.
(package private)  JCTree.JCVariableDecl variableDeclarator(JCTree.JCModifiers mods, JCTree.JCExpression type, boolean reqInit, java.lang.String dc)
          VariableDeclarator = Ident VariableDeclaratorRest ConstantDeclarator = Ident ConstantDeclaratorRest
(package private)  JCTree.JCVariableDecl variableDeclaratorId(JCTree.JCModifiers mods, JCTree.JCExpression type)
          VariableDeclaratorId = Ident BracketsOpt
(package private)  JCTree.JCVariableDecl variableDeclaratorRest(int pos, JCTree.JCModifiers mods, JCTree.JCExpression type, Name name, boolean reqInit, java.lang.String dc)
          VariableDeclaratorRest = BracketsOpt ["=" VariableInitializer] ConstantDeclaratorRest = BracketsOpt "=" VariableInitializer
<T extends ListBuffer<? super JCTree.JCVariableDecl>>
T
variableDeclarators(JCTree.JCModifiers mods, JCTree.JCExpression type, T vdefs)
          VariableDeclarators = VariableDeclarator { "," VariableDeclarator }
(package private)
<T extends ListBuffer<? super JCTree.JCVariableDecl>>
T
variableDeclaratorsRest(int pos, JCTree.JCModifiers mods, JCTree.JCExpression type, Name name, boolean reqInit, java.lang.String dc, T vdefs)
          VariableDeclaratorsRest = VariableDeclaratorRest { "," VariableDeclarator } ConstantDeclaratorsRest = ConstantDeclaratorRest { "," ConstantDeclarator }
 JCTree.JCExpression variableInitializer()
          VariableInitializer = ArrayInitializer | Expression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

infixPrecedenceLevels

private static final int infixPrecedenceLevels
The number of precedence levels of infix operators.

See Also:
Constant Field Values

S

private Lexer S
The scanner used for lexical analysis.


F

protected TreeMaker F
The factory to be used for abstract syntax tree construction.


log

private Log log
The log to be used for error diagnostics.


keywords

private Keywords keywords
The keyword table.


source

private Source source
The Source language setting.


names

private Names names
The name table.


allowGenerics

boolean allowGenerics
Switch: Should generics be recognized?


allowVarargs

boolean allowVarargs
Switch: Should varargs be recognized?


allowAsserts

boolean allowAsserts
Switch: should we recognize assert statements, or just give a warning?


allowEnums

boolean allowEnums
Switch: should we recognize enums, or just give a warning?


allowForeach

boolean allowForeach
Switch: should we recognize foreach?


allowStaticImport

boolean allowStaticImport
Switch: should we recognize foreach?


allowAnnotations

boolean allowAnnotations
Switch: should we recognize annotations?


keepDocComments

boolean keepDocComments
Switch: should we keep docComments?


keepLineMap

boolean keepLineMap
Switch: should we keep line table?


EXPR

static final int EXPR
When terms are parsed, the mode determines which is expected: mode = EXPR : an expression mode = TYPE : a type mode = NOPARAMS : no parameters allowed for type mode = TYPEARG : type argument

See Also:
Constant Field Values

TYPE

static final int TYPE
See Also:
Constant Field Values

NOPARAMS

static final int NOPARAMS
See Also:
Constant Field Values

TYPEARG

static final int TYPEARG
See Also:
Constant Field Values

mode

private int mode
The current mode.


lastmode

private int lastmode
The mode of the term that was parsed last.


errorTree

private JCTree.JCErroneous errorTree

errorPos

private int errorPos

docComments

java.util.Map<JCTree,java.lang.String> docComments
A hashtable to store all documentation comments indexed by the tree nodes they refer to. defined only if option flag keepDocComment is set.


errorEndPos

private int errorEndPos

odStackSupply

ListBuffer<JCTree.JCExpression[]> odStackSupply
optimization: To save allocating a new operand/operator stack for every binary operation, we use supplys.


opStackSupply

ListBuffer<Token[]> opStackSupply
Constructor Detail

JavacParser

protected JavacParser(ParserFactory fac,
                      Lexer S,
                      boolean keepDocComments,
                      boolean keepLineMap)
Construct a parser from a given scanner, tree factory and log.

Method Detail

skip

private void skip(boolean stopAtImport,
                  boolean stopAtMemberDecl,
                  boolean stopAtIdentifier,
                  boolean stopAtStatement)
Skip forward until a suitable stop token is found.


syntaxError

private JCTree.JCErroneous syntaxError(int pos,
                                       java.lang.String key,
                                       Token... args)

syntaxError

private JCTree.JCErroneous syntaxError(int pos,
                                       List<JCTree> errs,
                                       java.lang.String key,
                                       Token... args)

reportSyntaxError

private void reportSyntaxError(int pos,
                               java.lang.String key,
                               java.lang.Object... args)
Report a syntax error at given position using the given argument unless one was already reported at the same position.


syntaxError

private JCTree.JCErroneous syntaxError(java.lang.String key)
Generate a syntax error at current position unless one was already reported at the same position.


syntaxError

private JCTree.JCErroneous syntaxError(java.lang.String key,
                                       Token arg)
Generate a syntax error at current position unless one was already reported at the same position.


accept

public void accept(Token token)
If next input token matches given token, skip it, otherwise report an error.


illegal

JCTree.JCExpression illegal(int pos)
Report an illegal start of expression/type error at given position.


illegal

JCTree.JCExpression illegal()
Report an illegal start of expression/type error at current position.


checkNoMods

void checkNoMods(long mods)
Diagnose a modifier flag from the set, if any.


attach

void attach(JCTree tree,
            java.lang.String dc)
Make an entry into docComments hashtable, provided flag keepDocComments is set and given doc comment is non-null.

Parameters:
tree - The tree to be used as index in the hashtable
dc - The doc comment to associate with the tree, or null.

setErrorEndPos

private void setErrorEndPos(int errPos)

getErrorEndPos

protected int getErrorEndPos()

storeEnd

protected void storeEnd(JCTree tree,
                        int endpos)
Store ending position for a tree.

Parameters:
tree - The tree.
endpos - The ending position to associate with the tree.

to

protected <T extends JCTree> T to(T t)
Store ending position for a tree. The ending position should be the ending position of the current token.

Parameters:
t - The tree.

toP

protected <T extends JCTree> T toP(T t)
Store ending position for a tree. The ending position should be greater of the ending position of the previous token and errorEndPos.

Parameters:
t - The tree.

getStartPos

public int getStartPos(JCTree tree)
Get the start position for a tree node. The start position is defined to be the position of the first character of the first token of the node's source text.

Parameters:
tree - The tree node

getEndPos

public int getEndPos(JCTree tree)
Get the end position for a tree node. The end position is defined to be the position of the last character of the last token of the node's source text. Returns Position.NOPOS if end positions are not generated or the position is otherwise not found.

Parameters:
tree - The tree node

ident

Name ident()
Ident = IDENTIFIER


qualident

public JCTree.JCExpression qualident()
Qualident = Ident { DOT Ident }


literal

JCTree.JCExpression literal(Name prefix)
Literal = INTLITERAL | LONGLITERAL | FLOATLITERAL | DOUBLELITERAL | CHARLITERAL | STRINGLITERAL | TRUE | FALSE | NULL


isZero

boolean isZero(java.lang.String s)

strval

java.lang.String strval(Name prefix)

parseExpression

public JCTree.JCExpression parseExpression()
terms can be either expressions or types.

Specified by:
parseExpression in interface Parser
Returns:
an expression

parseType

public JCTree.JCExpression parseType()
Description copied from interface: Parser
Parse a type.

Specified by:
parseType in interface Parser
Returns:
an expression for a type

term

JCTree.JCExpression term(int newmode)

term

JCTree.JCExpression term()
Expression = Expression1 [ExpressionRest] ExpressionRest = [AssignmentOperator Expression1] AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "&=" | "|=" | "^=" | "%=" | "<<=" | ">>=" | ">>>=" Type = Type1 TypeNoParams = TypeNoParams1 StatementExpression = Expression ConstantExpression = Expression


termRest

JCTree.JCExpression termRest(JCTree.JCExpression t)

term1

JCTree.JCExpression term1()
Expression1 = Expression2 [Expression1Rest] Type1 = Type2 TypeNoParams1 = TypeNoParams2


term1Rest

JCTree.JCExpression term1Rest(JCTree.JCExpression t)
Expression1Rest = ["?" Expression ":" Expression1]


term2

JCTree.JCExpression term2()
Expression2 = Expression3 [Expression2Rest] Type2 = Type3 TypeNoParams2 = TypeNoParams3


term2Rest

JCTree.JCExpression term2Rest(JCTree.JCExpression t,
                              int minprec)

makeOp

private JCTree.JCExpression makeOp(int pos,
                                   Token topOp,
                                   JCTree.JCExpression od1,
                                   JCTree.JCExpression od2)
Construct a binary or type test node.


foldStrings

protected java.lang.StringBuffer foldStrings(JCTree tree)
If tree is a concatenation of string literals, replace it by a single literal representing the concatenated string.


newOdStack

private JCTree.JCExpression[] newOdStack()

newOpStack

private Token[] newOpStack()

term3

protected JCTree.JCExpression term3()
Expression3 = PrefixOp Expression3 | "(" Expr | TypeNoParams ")" Expression3 | Primary {Selector} {PostfixOp} mgr: added let expression | LET VarDecls IN Expression emw4: staging additions // * | "<|" Statement | Expression "|>" | "<|" { BlockStatements } | Expression "|>" | "`" Expression Primary = "(" Expression ")" | Literal | [TypeArguments] THIS [Arguments] | [TypeArguments] SUPER SuperSuffix | NEW [TypeArguments] Creator | Ident { "." Ident } [ "[" ( "]" BracketsOpt "." CLASS | Expression "]" ) | Arguments | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator ) ] | BasicType BracketsOpt "." CLASS PrefixOp = "++" | "--" | "!" | "~" | "+" | "-" PostfixOp = "++" | "--" Type3 = Ident { "." Ident } [TypeArguments] {TypeSelector} BracketsOpt | BasicType TypeNoParams3 = Ident { "." Ident } BracketsOpt Selector = "." [TypeArguments] Ident [Arguments] | "." THIS | "." [TypeArguments] SUPER SuperSuffix | "." NEW [TypeArguments] InnerCreator | "[" Expression "]" TypeSelector = "." Ident [TypeArguments] SuperSuffix = Arguments | "." Ident [Arguments]


superSuffix

JCTree.JCExpression superSuffix(List<JCTree.JCExpression> typeArgs,
                                JCTree.JCExpression t)
SuperSuffix = Arguments | "." [TypeArguments] Ident [Arguments]


basicType

JCTree.JCPrimitiveTypeTree basicType()
BasicType = BYTE | SHORT | CHAR | INT | LONG | FLOAT | DOUBLE | BOOLEAN


argumentsOpt

JCTree.JCExpression argumentsOpt(List<JCTree.JCExpression> typeArgs,
                                 JCTree.JCExpression t)
ArgumentsOpt = [ Arguments ]


arguments

List<JCTree.JCExpression> arguments()
Arguments = "(" [Expression { COMMA Expression }] ")"


arguments

JCTree.JCMethodInvocation arguments(List<JCTree.JCExpression> typeArgs,
                                    JCTree.JCExpression t)

typeArgumentsOpt

JCTree.JCExpression typeArgumentsOpt(JCTree.JCExpression t)
TypeArgumentsOpt = [ TypeArguments ]


typeArgumentsOpt

List<JCTree.JCExpression> typeArgumentsOpt()

typeArgumentsOpt

List<JCTree.JCExpression> typeArgumentsOpt(int useMode)

typeArguments

List<JCTree.JCExpression> typeArguments()
TypeArguments = "<" TypeArgument {"," TypeArgument} ">"


typeArgument

JCTree.JCExpression typeArgument()
TypeArgument = Type | "?" | "?" EXTENDS Type {"&" Type} | "?" SUPER Type


typeArguments

JCTree.JCTypeApply typeArguments(JCTree.JCExpression t)

bracketsOpt

private JCTree.JCExpression bracketsOpt(JCTree.JCExpression t)
BracketsOpt = {"[" "]"}


bracketsOptCont

private JCTree.JCArrayTypeTree bracketsOptCont(JCTree.JCExpression t,
                                               int pos)

bracketsSuffix

JCTree.JCExpression bracketsSuffix(JCTree.JCExpression t)
BracketsSuffixExpr = "." CLASS BracketsSuffixType =


creator

JCTree.JCExpression creator(int newpos,
                            List<JCTree.JCExpression> typeArgs)
Creator = Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )


innerCreator

JCTree.JCExpression innerCreator(int newpos,
                                 List<JCTree.JCExpression> typeArgs,
                                 JCTree.JCExpression encl)
InnerCreator = Ident [TypeArguments] ClassCreatorRest


arrayCreatorRest

JCTree.JCExpression arrayCreatorRest(int newpos,
                                     JCTree.JCExpression elemtype)
ArrayCreatorRest = "[" ( "]" BracketsOpt ArrayInitializer | Expression "]" {"[" Expression "]"} BracketsOpt )


classCreatorRest

JCTree.JCExpression classCreatorRest(int newpos,
                                     JCTree.JCExpression encl,
                                     List<JCTree.JCExpression> typeArgs,
                                     JCTree.JCExpression t)
ClassCreatorRest = Arguments [ClassBody]


arrayInitializer

JCTree.JCExpression arrayInitializer(int newpos,
                                     JCTree.JCExpression t)
ArrayInitializer = "{" [VariableInitializer {"," VariableInitializer}] [","] "}"


variableInitializer

public JCTree.JCExpression variableInitializer()
VariableInitializer = ArrayInitializer | Expression


parExpression

JCTree.JCExpression parExpression()
ParExpression = "(" Expression ")"


block

JCTree.JCBlock block(int pos,
                     long flags)
Block = "{" BlockStatements "}"


block

public JCTree.JCBlock block()

blockStatements

List<JCTree.JCStatement> blockStatements()
BlockStatements = { BlockStatement } BlockStatement = LocalVariableDeclarationStatement | ClassOrInterfaceOrEnumDeclaration | [Ident ":"] Statement LocalVariableDeclarationStatement = { FINAL | '@' Annotation } Type VariableDeclarators ";"


parseStatement

public JCTree.JCStatement parseStatement()
Statement = Block | IF ParExpression Statement [ELSE Statement] | FOR "(" ForInitOpt ";" [Expression] ";" ForUpdateOpt ")" Statement | FOR "(" FormalParameter : Expression ")" Statement | WHILE ParExpression Statement | DO Statement WHILE ParExpression ";" | TRY Block ( Catches | [Catches] FinallyPart ) | SWITCH ParExpression "{" SwitchBlockStatementGroups "}" | SYNCHRONIZED ParExpression Block | RETURN [Expression] ";" | THROW Expression ";" | BREAK [Ident] ";" | CONTINUE [Ident] ";" | ASSERT Expression [ ":" Expression ] ";" | ";" | ExpressionStatement | Ident ":" Statement emw4: staging additions | "`" Expression

Specified by:
parseStatement in interface Parser
Returns:
an expression

catchClause

JCTree.JCCatch catchClause()
CatchClause = CATCH "(" FormalParameter ")" Block


switchBlockStatementGroups

List<JCTree.JCCase> switchBlockStatementGroups()
SwitchBlockStatementGroups = { SwitchBlockStatementGroup } SwitchBlockStatementGroup = SwitchLabel BlockStatements SwitchLabel = CASE ConstantExpression ":" | DEFAULT ":"


moreStatementExpressions

<T extends ListBuffer<? super JCTree.JCExpressionStatement>> T moreStatementExpressions(int pos,
                                                                                        JCTree.JCExpression first,
                                                                                        T stats)
MoreStatementExpressions = { COMMA StatementExpression }


forInit

List<JCTree.JCStatement> forInit()
ForInit = StatementExpression MoreStatementExpressions | { FINAL | '@' Annotation } Type VariableDeclarators


forUpdate

List<JCTree.JCExpressionStatement> forUpdate()
ForUpdate = StatementExpression MoreStatementExpressions


annotationsOpt

List<JCTree.JCAnnotation> annotationsOpt()
AnnotationsOpt = { '@' Annotation }


modifiersOpt

JCTree.JCModifiers modifiersOpt()
ModifiersOpt = { Modifier } Modifier = PUBLIC | PROTECTED | PRIVATE | STATIC | ABSTRACT | FINAL | NATIVE | SYNCHRONIZED | TRANSIENT | VOLATILE | "@" | "@" Annotation


modifiersOpt

JCTree.JCModifiers modifiersOpt(JCTree.JCModifiers partial)

annotation

JCTree.JCAnnotation annotation(int pos)
Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ]

Parameters:
pos - position of "@" token

annotationFieldValuesOpt

List<JCTree.JCExpression> annotationFieldValuesOpt()

annotationFieldValues

List<JCTree.JCExpression> annotationFieldValues()
AnnotationFieldValues = "(" [ AnnotationFieldValue { "," AnnotationFieldValue } ] ")"


annotationFieldValue

JCTree.JCExpression annotationFieldValue()
AnnotationFieldValue = AnnotationValue | Identifier "=" AnnotationValue


annotationValue

JCTree.JCExpression annotationValue()

variableDeclarators

public <T extends ListBuffer<? super JCTree.JCVariableDecl>> T variableDeclarators(JCTree.JCModifiers mods,
                                                                                   JCTree.JCExpression type,
                                                                                   T vdefs)
VariableDeclarators = VariableDeclarator { "," VariableDeclarator }


variableDeclaratorsRest

<T extends ListBuffer<? super JCTree.JCVariableDecl>> T variableDeclaratorsRest(int pos,
                                                                                JCTree.JCModifiers mods,
                                                                                JCTree.JCExpression type,
                                                                                Name name,
                                                                                boolean reqInit,
                                                                                java.lang.String dc,
                                                                                T vdefs)
VariableDeclaratorsRest = VariableDeclaratorRest { "," VariableDeclarator } ConstantDeclaratorsRest = ConstantDeclaratorRest { "," ConstantDeclarator }

Parameters:
reqInit - Is an initializer always required?
dc - The documentation comment for the variable declarations, or null.

variableDeclarator

JCTree.JCVariableDecl variableDeclarator(JCTree.JCModifiers mods,
                                         JCTree.JCExpression type,
                                         boolean reqInit,
                                         java.lang.String dc)
VariableDeclarator = Ident VariableDeclaratorRest ConstantDeclarator = Ident ConstantDeclaratorRest


variableDeclaratorRest

JCTree.JCVariableDecl variableDeclaratorRest(int pos,
                                             JCTree.JCModifiers mods,
                                             JCTree.JCExpression type,
                                             Name name,
                                             boolean reqInit,
                                             java.lang.String dc)
VariableDeclaratorRest = BracketsOpt ["=" VariableInitializer] ConstantDeclaratorRest = BracketsOpt "=" VariableInitializer

Parameters:
reqInit - Is an initializer always required?
dc - The documentation comment for the variable declarations, or null.

variableDeclaratorId

JCTree.JCVariableDecl variableDeclaratorId(JCTree.JCModifiers mods,
                                           JCTree.JCExpression type)
VariableDeclaratorId = Ident BracketsOpt


parseCompilationUnit

public JCTree.JCCompilationUnit parseCompilationUnit()
CompilationUnit = [ { "@" Annotation } PACKAGE Qualident ";"] {ImportDeclaration} {TypeDeclaration}

Specified by:
parseCompilationUnit in interface Parser
Returns:
a compilation unit

importDeclaration

JCTree importDeclaration()
ImportDeclaration = IMPORT [ STATIC ] Ident { "." Ident } [ "." "*" ] ";"


typeDeclaration

JCTree typeDeclaration(JCTree.JCModifiers mods)
TypeDeclaration = ClassOrInterfaceOrEnumDeclaration | ";"


classOrInterfaceOrEnumDeclaration

JCTree.JCStatement classOrInterfaceOrEnumDeclaration(JCTree.JCModifiers mods,
                                                     java.lang.String dc)
ClassOrInterfaceOrEnumDeclaration = ModifiersOpt (ClassDeclaration | InterfaceDeclaration | EnumDeclaration)

Parameters:
mods - Any modifiers starting the class or interface declaration
dc - The documentation comment for the class, or null.

classDeclaration

JCTree.JCClassDecl classDeclaration(JCTree.JCModifiers mods,
                                    java.lang.String dc)
ClassDeclaration = CLASS Ident TypeParametersOpt [EXTENDS Type] [IMPLEMENTS TypeList] ClassBody

Parameters:
mods - The modifiers starting the class declaration
dc - The documentation comment for the class, or null.

interfaceDeclaration

JCTree.JCClassDecl interfaceDeclaration(JCTree.JCModifiers mods,
                                        java.lang.String dc)
InterfaceDeclaration = INTERFACE Ident TypeParametersOpt [EXTENDS TypeList] InterfaceBody

Parameters:
mods - The modifiers starting the interface declaration
dc - The documentation comment for the interface, or null.

enumDeclaration

JCTree.JCClassDecl enumDeclaration(JCTree.JCModifiers mods,
                                   java.lang.String dc)
EnumDeclaration = ENUM Ident [IMPLEMENTS TypeList] EnumBody

Parameters:
mods - The modifiers starting the enum declaration
dc - The documentation comment for the enum, or null.

enumBody

List<JCTree> enumBody(Name enumName)
EnumBody = "{" { EnumeratorDeclarationList } [","] [ ";" {ClassBodyDeclaration} ] "}"


enumeratorDeclaration

JCTree enumeratorDeclaration(Name enumName)
EnumeratorDeclaration = AnnotationsOpt [TypeArguments] IDENTIFIER [ Arguments ] [ "{" ClassBody "}" ]


typeList

List<JCTree.JCExpression> typeList()
TypeList = Type {"," Type}


classOrInterfaceBody

List<JCTree> classOrInterfaceBody(Name className,
                                  boolean isInterface)
ClassBody = "{" {ClassBodyDeclaration} "}" InterfaceBody = "{" {InterfaceBodyDeclaration} "}"


classOrInterfaceBodyDeclaration

List<JCTree> classOrInterfaceBodyDeclaration(Name className,
                                             boolean isInterface)
ClassBodyDeclaration = ";" | [STATIC] Block | ModifiersOpt ( Type Ident ( VariableDeclaratorsRest ";" | MethodDeclaratorRest ) | VOID Ident MethodDeclaratorRest | TypeParameters (Type | VOID) Ident MethodDeclaratorRest | Ident ConstructorDeclaratorRest | TypeParameters Ident ConstructorDeclaratorRest | ClassOrInterfaceOrEnumDeclaration ) InterfaceBodyDeclaration = ";" | ModifiersOpt Type Ident ( ConstantDeclaratorsRest | InterfaceMethodDeclaratorRest ";" )


methodDeclaratorRest

JCTree methodDeclaratorRest(int pos,
                            JCTree.JCModifiers mods,
                            JCTree.JCExpression type,
                            Name name,
                            List<JCTree.JCTypeParameter> typarams,
                            boolean isInterface,
                            boolean isVoid,
                            java.lang.String dc)
MethodDeclaratorRest = FormalParameters BracketsOpt [Throws TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";") VoidMethodDeclaratorRest = FormalParameters [Throws TypeList] ( MethodBody | ";") InterfaceMethodDeclaratorRest = FormalParameters BracketsOpt [THROWS TypeList] ";" VoidInterfaceMethodDeclaratorRest = FormalParameters [THROWS TypeList] ";" ConstructorDeclaratorRest = "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody


qualidentList

List<JCTree.JCExpression> qualidentList()
QualidentList = Qualident {"," Qualident}


typeParametersOpt

List<JCTree.JCTypeParameter> typeParametersOpt()
TypeParametersOpt = ["<" TypeParameter {"," TypeParameter} ">"]


typeParameter

JCTree.JCTypeParameter typeParameter()
TypeParameter = TypeVariable [TypeParameterBound] TypeParameterBound = EXTENDS Type {"&" Type} TypeVariable = Ident


formalParameters

List<JCTree.JCVariableDecl> formalParameters()
FormalParameters = "(" [ FormalParameterList ] ")" FormalParameterList = [ FormalParameterListNovarargs , ] LastFormalParameter FormalParameterListNovarargs = [ FormalParameterListNovarargs , ] FormalParameter


optFinal

JCTree.JCModifiers optFinal(long flags)

formalParameter

JCTree.JCVariableDecl formalParameter()
FormalParameter = { FINAL | '@' Annotation } Type VariableDeclaratorId LastFormalParameter = { FINAL | '@' Annotation } Type '...' Ident | FormalParameter


checkExprStat

protected JCTree.JCExpression checkExprStat(JCTree.JCExpression t)
Check that given tree is a legal expression statement.


prec

static int prec(Token token)
Return precedence of operator represented by token, -1 if token is not a binary operator. @see TreeInfo.opPrec


optag

static int optag(Token token)
Return operation tag of binary operator represented by token, -1 if token is not a binary operator.


unoptag

static int unoptag(Token token)
Return operation tag of unary operator represented by token, -1 if token is not a binary operator.


typetag

static int typetag(Token token)
Return type tag of basic type represented by token, -1 if token is not a basic type identifier.


checkGenerics

void checkGenerics()

checkVarargs

void checkVarargs()

checkForeach

void checkForeach()

checkStaticImports

void checkStaticImports()

checkAnnotations

void checkAnnotations()