public class Parser extends AbstractParser
| Modifier and Type | Field and Description |
|---|---|
protected Lexer.LineInfoReceiver |
lineInfoReceiver
to receive line information from Lexer when scanning multiline literals.
|
errors, finish, isStrictMode, k, last, lexer, line, lineOffset, linePosition, previousToken, source, start, stream, token, type| Constructor and Description |
|---|
Parser(ScriptEnvironment env,
Source source,
ErrorManager errors)
Constructor
|
Parser(ScriptEnvironment env,
Source source,
ErrorManager errors,
boolean strict)
Constructor
|
Parser(ScriptEnvironment env,
Source source,
ErrorManager errors,
boolean strict,
int lineOffset)
Construct a parser.
|
| Modifier and Type | Method and Description |
|---|---|
List<Expression> |
decoratorList(boolean yield,
boolean await)
Parse a decorator list.
|
FunctionNode |
parse()
Execute parse and return the resulting function node.
|
FunctionNode |
parse(com.oracle.truffle.api.strings.TruffleString scriptName,
int startPos,
int len,
int reparseFlags,
Scope parentScope,
List<String> argumentNames)
Execute parse and return the resulting function node.
|
FunctionNode |
parseEval(boolean functionContext,
Scope parentScope)
Parse eval code.
|
Expression |
parseExpression()
Parse and return an expression.
|
void |
parseFormalParameterList()
Parse and return the list of function parameter list.
|
FunctionNode |
parseFunctionBody(boolean generator,
boolean async)
Execute parse and return the resulting function node.
|
FunctionNode |
parseModule(String moduleName) |
FunctionNode |
parseModule(String moduleName,
int startPos,
int len)
Parse and return the resulting module.
|
FunctionNode |
parseWithArguments(List<String> argumentNames)
Parse code assuming a set of given arguments for the returned
FunctionNode. |
void |
setReparsedFunction(RecompilableScriptFunctionData reparsedFunction)
Sets the @link RecompilableScriptFunctionData representing the function being reparsed (when
this parser instance is used to reparse a previously parsed function, as part of its
on-demand compilation).
|
String |
toString() |
createIdentNode, error, error, error, error, expect, expectDontAdvance, expectMessage, expectMessage, getIdent, getIdentifierName, getLiteral, getNumberToStringConverter, getToken, getValue, getValue, getValueNoEscape, isIdentifierName, isIdentifierName, isNonStrictModeIdent, message, message, next, nextOrEOL, T, validateLexerToken, warningprotected final Lexer.LineInfoReceiver lineInfoReceiver
public Parser(ScriptEnvironment env, Source source, ErrorManager errors)
env - script environmentsource - source to parseerrors - error managerpublic Parser(ScriptEnvironment env, Source source, ErrorManager errors, boolean strict)
env - script environmentsource - source to parseerrors - error managerstrict - strictpublic Parser(ScriptEnvironment env, Source source, ErrorManager errors, boolean strict, int lineOffset)
env - script environmentsource - source to parseerrors - error managerstrict - parser created with strict mode enabled.lineOffset - line offset to start counting lines frompublic FunctionNode parse()
Parser.PROGRAM_NAME.public void setReparsedFunction(RecompilableScriptFunctionData reparsedFunction)
reparsedFunction - the function being reparsed.public FunctionNode parse(com.oracle.truffle.api.strings.TruffleString scriptName, int startPos, int len, int reparseFlags, Scope parentScope, List<String> argumentNames)
scriptName - name for the script, given to the parsed FunctionNodestartPos - start position in sourcelen - length of parsereparseFlags - flags provided by RecompilableScriptFunctionData as context for
the code being reparsed. This allows us to recognize special forms of functions
such as property getters and setters or instances of ES6 method shorthand in
object literals.argumentNames - optional names of arguments assumed by the parsed function node.public FunctionNode parseModule(String moduleName, int startPos, int len)
moduleName - name for the module, given to the parsed FunctionNodestartPos - start position in sourcelen - length of parsepublic FunctionNode parseModule(String moduleName)
public FunctionNode parseEval(boolean functionContext, Scope parentScope)
parentScope - optional caller context scope (direct eval)public FunctionNode parseWithArguments(List<String> argumentNames)
FunctionNode.argumentNames - names of arguments assumed by the parsed function node.public void parseFormalParameterList()
public FunctionNode parseFunctionBody(boolean generator, boolean async)
Parser.parseFormalParameterList()public List<Expression> decoratorList(boolean yield, boolean await)
DecoratorList[Yield, Await] :
DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await]
Decorator[Yield, Await] :
@ DecoratorMemberExpression[?Yield, ?Await]
@ DecoratorParenthesizedExpression[?Yield, ?Await]
@ DecoratorCallExpression[?Yield, ?Await]
DecoratorMemberExpression[Yield, Await] :
IdentifierReference[?Yield, ?Await]
PrivateIdentifier
DecoratorMemberExpression[?Yield, ?Await] . IdentifierName
DecoratorCallExpression[Yield, Await] :
DecoratorMemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
DecoratorParenthesizedExpression[Yield, Await] :
( Expression[+In, ?Yield, ?Await] )
ClassDeclaration[Yield, Await, Default] :
DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await]
[+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await]
public Expression parseExpression()