Top Description Fields Constructors Methods
io.github.kusoroadeolu.veneer

pack-priv abstract Class JavaScriptLexerBase

extends Lexer
Class Inheritance
Known Direct Subclasses
io.github.kusoroadeolu.veneer.JavaScriptLexer
Imports
org.antlr.v4.runtime.*, java.util.ArrayDeque, .Deque, io.github.kusoroadeolu.veneer.JavaScriptLexer

All lexer methods that used in grammar (IsStrictMode) should start with Upper Case Char similar to Lexer rules.

Field Summary

Modifier and TypeField and Description
private Token
private final Deque<Boolean>
scopeStrictModes

Stores values of nested modes.

private int
templateDepth

Keeps track of the current depth of nested template string backticks.

private boolean
useStrictCurrent

Current value of strict mode Can be defined during parsing, see StringFunctions.js and StringGlobal.js samples

private boolean
useStrictDefault

Default value of strict mode Can be defined externally by setUseStrictDefault

Inherited from org.antlr.v4.runtime.Lexer:
_channel_factory_hitEOF_input_mode_modeStack_text_token_tokenFactorySourcePair_tokenStartCharIndex_tokenStartCharPositionInLine_tokenStartLine_typeDEFAULT_MODEDEFAULT_TOKEN_CHANNELHIDDENMAX_CHAR_VALUEMIN_CHAR_VALUEMORESKIP

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public boolean
public void
public boolean
protected boolean
IsJsxPossible()

Returns true if the lexer can match a JSX opening element.

protected boolean
IsRegexPossible()

Returns true if the lexer can match a regex literal.

public boolean
public boolean
public Token

Returns:

the next token from the character stream.
nextToken
()

Overrides org.antlr.v4.runtime.Lexer.nextToken.

Implements org.antlr.v4.runtime.TokenSource.nextToken.

Return the next token from the character stream and records this last token in case it resides on the default channel.

protected void
protected void
protected void
public void
setUseStrictDefault(boolean value)

Inherited from org.antlr.v4.runtime.Lexer:
emitemitemitEOFgetAllTokensgetChannelgetChannelNamesgetCharErrorDisplaygetCharIndexgetCharPositionInLinegetErrorDisplaygetErrorDisplaygetInputStreamgetLinegetModeNamesgetSourceNamegetTextgetTokengetTokenFactorygetTokenNamesgetTypemodemorenotifyListenerspopModepushModerecoverrecoverresetsetChannelsetCharPositionInLinesetInputStreamsetLinesetTextsetTokensetTokenFactorysetTypeskip

Field Detail

lastTokenback to summary
private Token lastToken
scopeStrictModesback to summary
private final Deque<Boolean> scopeStrictModes

Stores values of nested modes. By default, mode is strict or defined externally (useStrictDefault)

templateDepthback to summary
private int templateDepth

Keeps track of the current depth of nested template string backticks. E.g. after the X in: `${a ? `${X templateDepth will be 2. This variable is needed to determine if a `}` is a plain CloseBrace, or one that closes an expression inside a template string.

useStrictCurrentback to summary
private boolean useStrictCurrent

Current value of strict mode Can be defined during parsing, see StringFunctions.js and StringGlobal.js samples

useStrictDefaultback to summary
private boolean useStrictDefault

Default value of strict mode Can be defined externally by setUseStrictDefault

Constructor Detail

JavaScriptLexerBaseback to summary
public JavaScriptLexerBase(CharStream input)

Method Detail

DecreaseTemplateDepthback to summary
public void DecreaseTemplateDepth()
getStrictDefaultback to summary
public boolean getStrictDefault()
IncreaseTemplateDepthback to summary
public void IncreaseTemplateDepth()
IsInTemplateStringback to summary
public boolean IsInTemplateString()
IsJsxPossibleback to summary
protected boolean IsJsxPossible()

Returns true if the lexer can match a JSX opening element.

IsRegexPossibleback to summary
protected boolean IsRegexPossible()

Returns true if the lexer can match a regex literal.

IsStartOfFileback to summary
public boolean IsStartOfFile()
IsStrictModeback to summary
public boolean IsStrictMode()
nextTokenback to summary
public Token nextToken()

Overrides org.antlr.v4.runtime.Lexer.nextToken.

Implements org.antlr.v4.runtime.TokenSource.nextToken.

Return the next token from the character stream and records this last token in case it resides on the default channel. This recorded token is used to determine when the lexer could possibly match a regex literal. Also changes scopeStrictModes stack if tokenize special string 'use strict';

Returns:Token

the next token from the character stream.

Annotations
@Override
ProcessCloseBraceback to summary
protected void ProcessCloseBrace()
ProcessOpenBraceback to summary
protected void ProcessOpenBrace()
ProcessStringLiteralback to summary
protected void ProcessStringLiteral()
setUseStrictDefaultback to summary
public void setUseStrictDefault(boolean value)