| Modifier and Type | Field and Description |
|---|---|
protected ErrorManager |
errors
Error manager to report errors.
|
protected int |
finish
Finish position of previous token.
|
protected boolean |
isStrictMode
Is this parser running under strict mode?
|
protected int |
k
Index of current token.
|
protected TokenType |
last
Type of last token.
|
protected Lexer |
lexer
Lexer used to scan source content.
|
protected int |
line
Current line number.
|
protected int |
lineOffset
What should line numbers be counted from?
|
protected int |
linePosition
Position of last EOL + 1.
|
protected long |
previousToken
Previous token - accessible to sub classes
|
protected Source |
source
Source to parse.
|
protected int |
start
Start position of current token.
|
protected TokenStream |
stream
Stream of lex tokens to parse.
|
protected long |
token
Descriptor of current token.
|
protected TokenType |
type
Type of current token.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractParser(Source source,
ErrorManager errors,
boolean strict,
int lineOffset)
Construct a parser.
|
| Modifier and Type | Method and Description |
|---|---|
protected IdentNode |
createIdentNode(long identToken,
int identFinish,
com.oracle.truffle.api.strings.TruffleString name)
Creates a new
IdentNode as if invoked with a
constructor but making sure that the
name is deduplicated within this parse job. |
protected ParserException |
error(JSErrorType errorType,
String message)
Report an error.
|
protected ParserException |
error(JSErrorType errorType,
String message,
long errorToken)
Report an error.
|
protected ParserException |
error(String message)
Report an error.
|
protected ParserException |
error(String message,
long errorToken)
Report an error.
|
protected void |
expect(TokenType expected)
Check current token and advance to the next token.
|
protected void |
expectDontAdvance(TokenType expected)
Check current token, but don't advance to the next token.
|
protected String |
expectMessage(TokenType expected)
Generate 'expected' message.
|
protected String |
expectMessage(TokenType expected,
long errorToken) |
protected IdentNode |
getIdent()
Get ident.
|
protected IdentNode |
getIdentifierName()
Create an IdentNode from the current token
|
protected LiteralNode<?> |
getLiteral()
Create a LiteralNode from the current token
|
protected Function<Number,com.oracle.truffle.api.strings.TruffleString> |
getNumberToStringConverter()
Custom number-to-string converter used to convert numeric property names to strings.
|
protected long |
getToken(int i)
Get the ith token.
|
protected Object |
getValue()
Get the value of the current token.
|
protected Object |
getValue(long valueToken)
Get the value of a specific token
|
protected Object |
getValueNoEscape()
Get the value of the current token.
|
protected boolean |
isIdentifierName()
Check if current token is in identifier name
|
protected boolean |
isIdentifierName(long currentToken)
Check if token is an identifier name
|
protected boolean |
isNonStrictModeIdent()
Certain future reserved words can be used as identifiers in non-strict mode.
|
protected static String |
message(String msgId,
IdentNode ident) |
protected static String |
message(String msgId,
String... args)
Get the message string for a message ID and arguments
|
protected TokenType |
next()
Seek next token that is not an EOL or comment.
|
protected TokenType |
nextOrEOL()
Seek next token or EOL (skipping comments.)
|
protected TokenType |
T(int i)
Return the tokenType of the ith token.
|
protected void |
validateLexerToken(Lexer.LexerToken lexerToken)
Lexer token validation hook for subclasses.
|
protected void |
warning(JSErrorType errorType,
String message,
long errorToken)
Report a warning to the error manager.
|
protected final Source source
protected final ErrorManager errors
protected TokenStream stream
protected int k
protected long previousToken
protected long token
protected TokenType type
protected TokenType last
protected int start
protected int finish
protected int line
protected int linePosition
protected Lexer lexer
protected boolean isStrictMode
protected final int lineOffset
protected AbstractParser(Source source, ErrorManager errors, boolean strict, int lineOffset)
source - Source to parse.errors - Error reporting manager.strict - True if we are in strict modelineOffset - Offset from which lines should be countedprotected final long getToken(int i)
i - Index of token.protected final TokenType T(int i)
i - Index of tokenprotected final TokenType next()
protected final TokenType nextOrEOL()
protected static String message(String msgId, String... args)
msgId - The Message IDargs - The argumentsprotected final ParserException error(String message, long errorToken)
message - Error message.errorToken - Offending token.protected final ParserException error(JSErrorType errorType, String message, long errorToken)
errorType - The error typemessage - Error message.errorToken - Offending token.protected final ParserException error(String message)
message - Error message.protected final ParserException error(JSErrorType errorType, String message)
errorType - The error typemessage - Error message.protected final void warning(JSErrorType errorType, String message, long errorToken)
errorType - The error type of the warningmessage - Warning message.errorToken - error tokenprotected final String expectMessage(TokenType expected)
expected - Expected tokenType.protected final void expect(TokenType expected) throws ParserException
expected - Expected tokenType.ParserException - on unexpected token typeprotected final void expectDontAdvance(TokenType expected) throws ParserException
expected - Expected tokenType.ParserException - on unexpected token typeprotected final Object getValueNoEscape()
protected final Object getValue()
protected final Object getValue(long valueToken)
valueToken - the tokenprotected final boolean isNonStrictModeIdent()
protected final IdentNode getIdent()
protected IdentNode createIdentNode(long identToken, int identFinish, com.oracle.truffle.api.strings.TruffleString name)
IdentNode as if invoked with a
constructor but making sure that the
name is deduplicated within this parse job.identToken - the token for the new IdentNodeidentFinish - the finish for the new IdentNodename - the name for the new IdentNode. It will be de-duplicated.IdentNode with the specified token, finish, and name; the
name will be deduplicated.protected final boolean isIdentifierName()
protected final boolean isIdentifierName(long currentToken)
protected final IdentNode getIdentifierName()
protected final LiteralNode<?> getLiteral() throws ParserException
ParserException - if any literals fails to parseprotected void validateLexerToken(Lexer.LexerToken lexerToken)
lexerToken - the lexer token to validate