CommonRegexParser class

Extends

Parser

Constructors

CommonRegexParser(TokenStream)

Properties

ALC
Ampersand
AUC
Backslash
BellChar
BLC
BlockQuoted
BUC
Caret
CarriageReturn
CharacterClassEnd
CharacterClassStart
CharWithoutProperty
CharWithProperty
CLC
CloseBrace
CloseParen
Colon
Comma
ControlChar
CUC
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
DecimalDigit
DLC
Dot
DUC
ELC
EndOfSubject
Equals
EscapeChar
EUC
Exclamation
FLC
FormFeed
FUC
GLC
grammarFileName
GreaterThan
GUC
Hash
HexChar
HLC
HUC
Hyphen
ILC
IUC
JLC
JUC
KLC
KUC
LessThan
LLC
LUC
MLC
MUC
NewLine
NLC
NotDecimalDigit
NotWhiteSpace
NotWordChar
NUC
OLC
OpenBrace
OpenParen
OtherChar
OUC
Pipe
PLC
Plus
PUC
QLC
QUC
QuestionMark
Quoted
RLC
RUC
ruleNames
ruleNames
RULE_alpha_nums
RULE_alternation
RULE_atom
RULE_capture
RULE_cc_atom
RULE_cc_literal
RULE_character_class
RULE_digit
RULE_digits
RULE_element
RULE_expr
RULE_letter
RULE_literal
RULE_name
RULE_non_capture
RULE_non_close_paren
RULE_non_close_parens
RULE_number
RULE_octal_char
RULE_octal_digit
RULE_option
RULE_option_flag
RULE_parse
RULE_quantifier
RULE_quantifier_type
RULE_shared_atom
RULE_shared_literal
serializedATN
SingleQuote
SLC
Star
SUC
Tab
TLC
TUC
ULC
Underscore
UUC
VLC
VOCABULARY
vocabulary
VUC
WhiteSpace
WLC
WordChar
WUC
XLC
XUC
YLC
YUC
ZLC
ZUC

Inherited Properties

atn

Get the serializedATN used by the recognizer for prediction.

buildParseTree

Track the <xref:ParserRuleContext> objects during the parse and hook them up using the <xref:ParserRuleContext%23children> list so that it forms a parse tree. The <xref:ParserRuleContext> returned from the start rule represents the root of the parse tree. Note that if we are not building parse trees, rule contexts only point upwards. When a rule exits, it returns the context but that gets garbage collected if nobody holds a reference. It points upwards but nobody points at it.

When we build parse trees, we are adding all of these contexts to <xref:ParserRuleContext%23children> list. Contexts are then not candidates for garbage collection.

context
currentToken

Match needs to return the current input symbol, which gets put into the label for the associated token ref; e.g., x=ID.

EOF
errorHandler
inputStream

Set the token stream and reset the parser.

interpreter

Set the ATN interpreter used by the recognizer for prediction.

isMatchedEOF
isTrace

During a parse is sometimes useful to listen in on the rule entry and exit events as well as token matches. This is for quick and dirty debugging.

numberOfSyntaxErrors

Gets the number of syntax errors reported during parsing. This value is incremented each time <xref:%23notifyErrorListeners> is called.

See #notifyErrorListeners

parseInfo
precedence

Get the precedence level for the top-most precedence rule.

ruleContext
sourceName
state

Indicate that the recognizer has changed internal state that is consistent with the ATN state passed in. This way we always know where we are in the ATN as the parser goes along. The rule context objects form a stack that lets us see the stack of invoking rules. Combine this and we have complete ATN configuration information.

tokenFactory

Methods

alpha_nums()
alternation()
atom()
capture()
cc_atom()
cc_literal()
character_class()
digit()
digits()
element()
expr()
letter()
literal()
name()
non_capture()
non_close_paren()
non_close_parens()
number()
octal_char()
octal_digit()
option()
option_flag()
parse()
quantifier()
quantifier_type()
shared_atom()
shared_literal()

Inherited Methods

action(RuleContext | undefined, number, number)
addErrorListener(ANTLRErrorListener<Token>)
addParseListener(ParseTreeListener)

Registers listener to receive events during the parsing process. To support output-preserving grammar transformations (including but not limited to left-recursion removal, automated left-factoring, and optimized code generation), calls to listener methods during the parse may differ substantially from calls made by <xref:ParseTreeWalker%23DEFAULT> used after the parse is complete. In particular, rule entry and exit events may occur in a different order during the parse than after the parser. In addition, calls to certain rule entry methods may be omitted.

With the following specific exceptions, calls to listener events are deterministic, i.e. for identical input the calls to listener methods will be the same.

  • Alterations to the grammar used to generate code may change the behavior of the listener calls.
  • Alterations to the command line options passed to ANTLR 4 when generating the parser may change the behavior of the listener calls.
  • Changing the version of the ANTLR Tool used to generate the parser may change the behavior of the listener calls.
compileParseTreePattern(string, number)

The preferred method of getting a tree pattern. For example, here's a sample use:

let t: ParseTree = parser.expr();
let p: ParseTreePattern = await parser.compileParseTreePattern("<ID>+0", MyParser.RULE_expr);
let m: ParseTreeMatch = p.match(t);
let id: string = m.get("ID");
compileParseTreePattern(string, number, Lexer)

The same as [int)](xref:%23compileParseTreePattern(String%2C) but specify a CommonRegexLexer rather than trying to deduce it from this parser.

consume()

Consume and return the current symbol. E.g., given the following input with A being the current lookahead symbol, this function moves the cursor to B and returns A.

A B
^

If the parser is not in error recovery mode, the consumed symbol is added to the parse tree using <xref:ParserRuleContext%23addChild(TerminalNode)>, and <xref:ParseTreeListener%23visitTerminal> is called on any parse listeners. If the parser is in error recovery mode, the consumed symbol is added to the parse tree using [Token)](xref:%23createErrorNode(ParserRuleContext%2C) then <xref:ParserRuleContext%23addErrorNode(ErrorNode)> and <xref:ParseTreeListener%23visitErrorNode> is called on any parse listeners.

createErrorNode(ParserRuleContext, Token)

How to create an error node, given a token, associated with a parent. Typically, the error node to create is not a function of the parent.

createTerminalNode(ParserRuleContext, Token)

How to create a token leaf node associated with a parent. Typically, the terminal node to create is not a function of the parent.

dumpDFA()

For debugging and other purposes.

enterLeftFactoredRule(ParserRuleContext, number, number)
enterOuterAlt(ParserRuleContext, number)
enterRecursionRule(ParserRuleContext, number, number, number)
enterRule(ParserRuleContext, number, number)

Always called by generated parsers upon entry to a rule. Access field <xref:%23_ctx> get the current context.

exitRule()
getATNWithBypassAlts()

The ATN with bypass alternatives is expensive to create so we create it lazily. @ if the current parser does not implement the serializedATN property.

getDFAStrings()

For debugging and other purposes.

getErrorHeader(RecognitionException)

What is the error header, normally line/character position information?

getErrorListenerDispatch()
getErrorListeners()
getExpectedTokens()

Computes the set of input symbols which could follow the current parser state and context, as given by <xref:%23getState> and <xref:%23getContext>, respectively.

See ATN#getExpectedTokens(int, RuleContext)

getExpectedTokensWithinCurrentRule()
getInvokingContext(number)
getParseListeners()
getRuleIndex(string)

Get a rule's index (i.e., RULE_ruleName field) or -1 if not found.

getRuleIndexMap()

Get a map from rule names to rule indexes. Used for XPath and tree pattern compilation.

getRuleInvocationStack(RuleContext)

Return List<String> of the rule names in your parser instance leading up to a call to the current rule. You could override if you want more details such as the file/line info of where in the ATN a rule is invoked. This is very useful for error messages.

getTokenType(string)
getTokenTypeMap()

Get a map from token names to token types. Used for XPath and tree pattern compilation.

inContext(string)
isExpectedToken(number)

Checks whether or not symbol can follow the current state in the ATN. The behavior of this method is equivalent to the following, but is implemented such that the complete context-sensitive follow set does not need to be explicitly constructed.

return getExpectedTokens().contains(symbol);
match(number)

Match current input symbol against ttype. If the symbol type matches, <xref:ANTLRErrorStrategy%23reportMatch> and <xref:%23consume> are called to complete the match process. If the symbol type does not match, <xref:ANTLRErrorStrategy%23recoverInline> is called on the current error strategy to attempt recovery. If <xref:%23getBuildParseTree> is true and the token index of the symbol returned by <xref:ANTLRErrorStrategy%23recoverInline> is -1, the symbol is added to the parse tree by calling [Token)](xref:%23createErrorNode(ParserRuleContext%2C) then <xref:ParserRuleContext%23addErrorNode(ErrorNode)>.

matchWildcard()

Match current input symbol as a wildcard. If the symbol type matches (i.e. has a value greater than 0), <xref:ANTLRErrorStrategy%23reportMatch> and <xref:%23consume> are called to complete the match process. If the symbol type does not match, <xref:ANTLRErrorStrategy%23recoverInline> is called on the current error strategy to attempt recovery. If <xref:%23getBuildParseTree> is true and the token index of the symbol returned by <xref:ANTLRErrorStrategy%23recoverInline> is -1, the symbol is added to the parse tree by calling [Token)](xref:Parser%23createErrorNode(ParserRuleContext%2C) then <xref:ParserRuleContext%23addErrorNode(ErrorNode)>.

notifyErrorListeners(string)
notifyErrorListeners(string, Token | null, RecognitionException | undefined)
precpred(RuleContext, number)
pushNewRecursionContext(ParserRuleContext, number, number)

Like <xref:%23enterRule> but for recursive rules. Make the current context the child of the incoming localctx.

removeErrorListener(ANTLRErrorListener<Token>)
removeErrorListeners()
removeParseListener(ParseTreeListener)

Remove listener from the list of parse listeners. If listener is undefined or has not been added as a parse listener, this method does nothing.

See #addParseListener

removeParseListeners()

Remove all parse listeners.

See #addParseListener

reset()

reset the parser's state

reset(boolean)
sempred(RuleContext | undefined, number, number)
setProfile(boolean)
unrollRecursionContexts(ParserRuleContext)

Constructor Details

CommonRegexParser(TokenStream)

new CommonRegexParser(input: TokenStream)

Parameters

input

TokenStream

Property Details

ALC

public static ALC: 44 = 44

Property Value

44

Ampersand

public static Ampersand: 43 = 43

Property Value

43

AUC

public static AUC: 70 = 70

Property Value

70

Backslash

public static Backslash: 10 = 10

Property Value

10

BellChar

public static BellChar: 3 = 3

Property Value

3

BLC

public static BLC: 45 = 45

Property Value

45

BlockQuoted

public static BlockQuoted: 2 = 2

Property Value

2

BUC

public static BUC: 71 = 71

Property Value

71

Caret

public static Caret: 23 = 23

Property Value

23

CarriageReturn

public static CarriageReturn: 8 = 8

Property Value

8

CharacterClassEnd

public static CharacterClassEnd: 22 = 22

Property Value

22

CharacterClassStart

public static CharacterClassStart: 21 = 21

Property Value

21

CharWithoutProperty

public static CharWithoutProperty: 16 = 16

Property Value

16

CharWithProperty

public static CharWithProperty: 15 = 15

Property Value

15

CLC

public static CLC: 46 = 46

Property Value

46

CloseBrace

public static CloseBrace: 29 = 29

Property Value

29

CloseParen

public static CloseParen: 34 = 34

Property Value

34

Colon

public static Colon: 39 = 39

Property Value

39

Comma

public static Comma: 30 = 30

Property Value

30

ControlChar

public static ControlChar: 4 = 4

Property Value

4

CUC

public static CUC: 72 = 72

Property Value

72

D0

public static D0: 105 = 105

Property Value

105

D1

public static D1: 96 = 96

Property Value

96

D2

public static D2: 97 = 97

Property Value

97

D3

public static D3: 98 = 98

Property Value

98

D4

public static D4: 99 = 99

Property Value

99

D5

public static D5: 100 = 100

Property Value

100

D6

public static D6: 101 = 101

Property Value

101

D7

public static D7: 102 = 102

Property Value

102

D8

public static D8: 103 = 103

Property Value

103

D9

public static D9: 104 = 104

Property Value

104

DecimalDigit

public static DecimalDigit: 13 = 13

Property Value

13

DLC

public static DLC: 47 = 47

Property Value

47

Dot

public static Dot: 12 = 12

Property Value

12

DUC

public static DUC: 73 = 73

Property Value

73

ELC

public static ELC: 48 = 48

Property Value

48

EndOfSubject

public static EndOfSubject: 31 = 31

Property Value

31

Equals

public static Equals: 41 = 41

Property Value

41

EscapeChar

public static EscapeChar: 5 = 5

Property Value

5

EUC

public static EUC: 74 = 74

Property Value

74

Exclamation

public static Exclamation: 42 = 42

Property Value

42

FLC

public static FLC: 49 = 49

Property Value

49

FormFeed

public static FormFeed: 6 = 6

Property Value

6

FUC

public static FUC: 75 = 75

Property Value

75

GLC

public static GLC: 50 = 50

Property Value

50

grammarFileName

string grammarFileName

Property Value

string

GreaterThan

public static GreaterThan: 36 = 36

Property Value

36

GUC

public static GUC: 76 = 76

Property Value

76

Hash

public static Hash: 40 = 40

Property Value

40

HexChar

public static HexChar: 11 = 11

Property Value

11

HLC

public static HLC: 51 = 51

Property Value

51

HUC

public static HUC: 77 = 77

Property Value

77

Hyphen

public static Hyphen: 24 = 24

Property Value

24

ILC

public static ILC: 52 = 52

Property Value

52

IUC

public static IUC: 78 = 78

Property Value

78

JLC

public static JLC: 53 = 53

Property Value

53

JUC

public static JUC: 79 = 79

Property Value

79

KLC

public static KLC: 54 = 54

Property Value

54

KUC

public static KUC: 80 = 80

Property Value

80

LessThan

public static LessThan: 35 = 35

Property Value

35

LLC

public static LLC: 55 = 55

Property Value

55

LUC

public static LUC: 81 = 81

Property Value

81

MLC

public static MLC: 56 = 56

Property Value

56

MUC

public static MUC: 82 = 82

Property Value

82

NewLine

public static NewLine: 7 = 7

Property Value

7

NLC

public static NLC: 57 = 57

Property Value

57

NotDecimalDigit

public static NotDecimalDigit: 14 = 14

Property Value

14

NotWhiteSpace

public static NotWhiteSpace: 18 = 18

Property Value

18

NotWordChar

public static NotWordChar: 20 = 20

Property Value

20

NUC

public static NUC: 83 = 83

Property Value

83

OLC

public static OLC: 58 = 58

Property Value

58

OpenBrace

public static OpenBrace: 28 = 28

Property Value

28

OpenParen

public static OpenParen: 33 = 33

Property Value

33

OtherChar

public static OtherChar: 106 = 106

Property Value

106

OUC

public static OUC: 84 = 84

Property Value

84

Pipe

public static Pipe: 32 = 32

Property Value

32

PLC

public static PLC: 59 = 59

Property Value

59

Plus

public static Plus: 26 = 26

Property Value

26

PUC

public static PUC: 85 = 85

Property Value

85

QLC

public static QLC: 60 = 60

Property Value

60

QUC

public static QUC: 86 = 86

Property Value

86

QuestionMark

public static QuestionMark: 25 = 25

Property Value

25

Quoted

public static Quoted: 1 = 1

Property Value

1

RLC

public static RLC: 61 = 61

Property Value

61

RUC

public static RUC: 87 = 87

Property Value

87

ruleNames

public static ruleNames: string[] = [
		"parse", "alternation", "expr", "element", "quantifier", "quantifier_type", 
		"character_class", "capture", "non_capture", "option", "option_flag", 
		"atom", "cc_atom", "shared_atom", "literal", "cc_literal", "shared_literal", 
		"number", "octal_char", "octal_digit", "digits", "digit", "name", "alpha_nums", 
		"non_close_parens", "non_close_paren", "letter",
	]

Property Value

string[]

ruleNames

string[] ruleNames

Property Value

string[]

RULE_alpha_nums

public static RULE_alpha_nums: 23 = 23

Property Value

23

RULE_alternation

public static RULE_alternation: 1 = 1

Property Value

1

RULE_atom

public static RULE_atom: 11 = 11

Property Value

11

RULE_capture

public static RULE_capture: 7 = 7

Property Value

7

RULE_cc_atom

public static RULE_cc_atom: 12 = 12

Property Value

12

RULE_cc_literal

public static RULE_cc_literal: 15 = 15

Property Value

15

RULE_character_class

public static RULE_character_class: 6 = 6

Property Value

6

RULE_digit

public static RULE_digit: 21 = 21

Property Value

21

RULE_digits

public static RULE_digits: 20 = 20

Property Value

20

RULE_element

public static RULE_element: 3 = 3

Property Value

3

RULE_expr

public static RULE_expr: 2 = 2

Property Value

2

RULE_letter

public static RULE_letter: 26 = 26

Property Value

26

RULE_literal

public static RULE_literal: 14 = 14

Property Value

14

RULE_name

public static RULE_name: 22 = 22

Property Value

22

RULE_non_capture

public static RULE_non_capture: 8 = 8

Property Value

8

RULE_non_close_paren

public static RULE_non_close_paren: 25 = 25

Property Value

25

RULE_non_close_parens

public static RULE_non_close_parens: 24 = 24

Property Value

24

RULE_number

public static RULE_number: 17 = 17

Property Value

17

RULE_octal_char

public static RULE_octal_char: 18 = 18

Property Value

18

RULE_octal_digit

public static RULE_octal_digit: 19 = 19

Property Value

19

RULE_option

public static RULE_option: 9 = 9

Property Value

9

RULE_option_flag

public static RULE_option_flag: 10 = 10

Property Value

10

RULE_parse

public static RULE_parse: 0 = 0

Property Value

0

RULE_quantifier

public static RULE_quantifier: 4 = 4

Property Value

4

RULE_quantifier_type

public static RULE_quantifier_type: 5 = 5

Property Value

5

RULE_shared_atom

public static RULE_shared_atom: 13 = 13

Property Value

13

RULE_shared_literal

public static RULE_shared_literal: 16 = 16

Property Value

16

serializedATN

string serializedATN

Property Value

string

SingleQuote

public static SingleQuote: 37 = 37

Property Value

37

SLC

public static SLC: 62 = 62

Property Value

62

Star

public static Star: 27 = 27

Property Value

27

SUC

public static SUC: 88 = 88

Property Value

88

Tab

public static Tab: 9 = 9

Property Value

9

TLC

public static TLC: 63 = 63

Property Value

63

TUC

public static TUC: 89 = 89

Property Value

89

ULC

public static ULC: 64 = 64

Property Value

64

Underscore

public static Underscore: 38 = 38

Property Value

38

UUC

public static UUC: 90 = 90

Property Value

90

VLC

public static VLC: 65 = 65

Property Value

65

VOCABULARY

public static VOCABULARY: Vocabulary = new VocabularyImpl(CommonRegexParser._LITERAL_NAMES, CommonRegexParser._SYMBOLIC_NAMES, [])

Property Value

Vocabulary

vocabulary

Vocabulary vocabulary

Property Value

Vocabulary

VUC

public static VUC: 91 = 91

Property Value

91

WhiteSpace

public static WhiteSpace: 17 = 17

Property Value

17

WLC

public static WLC: 66 = 66

Property Value

66

WordChar

public static WordChar: 19 = 19

Property Value

19

WUC

public static WUC: 92 = 92

Property Value

92

XLC

public static XLC: 67 = 67

Property Value

67

XUC

public static XUC: 93 = 93

Property Value

93

YLC

public static YLC: 68 = 68

Property Value

68

YUC

public static YUC: 94 = 94

Property Value

94

ZLC

public static ZLC: 69 = 69

Property Value

69

ZUC

public static ZUC: 95 = 95

Property Value

95

Inherited Property Details

atn

Get the serializedATN used by the recognizer for prediction.

atn: ATN

Property Value

ATN

Inherited From Recognizer.atn

buildParseTree

Track the <xref:ParserRuleContext> objects during the parse and hook them up using the <xref:ParserRuleContext%23children> list so that it forms a parse tree. The <xref:ParserRuleContext> returned from the start rule represents the root of the parse tree. Note that if we are not building parse trees, rule contexts only point upwards. When a rule exits, it returns the context but that gets garbage collected if nobody holds a reference. It points upwards but nobody points at it.

When we build parse trees, we are adding all of these contexts to <xref:ParserRuleContext%23children> list. Contexts are then not candidates for garbage collection.

buildParseTree: boolean

Property Value

boolean

Inherited From Parser.buildParseTree

context

context: ParserRuleContext

Property Value

ParserRuleContext

Inherited From Parser.context

currentToken

Match needs to return the current input symbol, which gets put into the label for the associated token ref; e.g., x=ID.

currentToken: Token

Property Value

Token

Inherited From Parser.currentToken

EOF

static EOF: number

Property Value

number

Inherited From Recognizer.EOF

errorHandler

errorHandler: ANTLRErrorStrategy

Property Value

ANTLRErrorStrategy

Inherited From Parser.errorHandler

inputStream

Set the token stream and reset the parser.

inputStream: TokenStream

Property Value

TokenStream

Inherited From Parser.inputStream

interpreter

Set the ATN interpreter used by the recognizer for prediction.

interpreter: ParserATNSimulator

Property Value

ParserATNSimulator

Inherited From Recognizer.interpreter

isMatchedEOF

isMatchedEOF: boolean

Property Value

boolean

Inherited From Parser.isMatchedEOF

isTrace

During a parse is sometimes useful to listen in on the rule entry and exit events as well as token matches. This is for quick and dirty debugging.

isTrace: boolean

Property Value

boolean

Inherited From Parser.isTrace

numberOfSyntaxErrors

Gets the number of syntax errors reported during parsing. This value is incremented each time <xref:%23notifyErrorListeners> is called.

See #notifyErrorListeners

numberOfSyntaxErrors: number

Property Value

number

Inherited From Parser.numberOfSyntaxErrors

parseInfo

parseInfo: Promise<ParseInfo | undefined>

Property Value

Promise<ParseInfo | undefined>

Inherited From Parser.parseInfo

precedence

Get the precedence level for the top-most precedence rule.

precedence: number

Property Value

number

Inherited From Parser.precedence

ruleContext

ruleContext: ParserRuleContext

Property Value

ParserRuleContext

Inherited From Parser.ruleContext

sourceName

sourceName: string

Property Value

string

Inherited From Parser.sourceName

state

Indicate that the recognizer has changed internal state that is consistent with the ATN state passed in. This way we always know where we are in the ATN as the parser goes along. The rule context objects form a stack that lets us see the stack of invoking rules. Combine this and we have complete ATN configuration information.

state: number

Property Value

number

Inherited From Recognizer.state

tokenFactory

tokenFactory: TokenFactory

Property Value

TokenFactory

Inherited From Parser.tokenFactory

Method Details

alpha_nums()

function alpha_nums(): Alpha_numsContext

Returns

alternation()

function alternation(): AlternationContext

Returns

atom()

function atom(): AtomContext

Returns

capture()

function capture(): CaptureContext

Returns

cc_atom()

function cc_atom(): Cc_atomContext

Returns

cc_literal()

function cc_literal(): Cc_literalContext

Returns

character_class()

function character_class(): Character_classContext

Returns

digit()

function digit(): DigitContext

Returns

digits()

function digits(): DigitsContext

Returns

element()

function element(): ElementContext

Returns

expr()

function expr(): ExprContext

Returns

letter()

function letter(): LetterContext

Returns

literal()

function literal(): LiteralContext

Returns

name()

function name(): NameContext

Returns

non_capture()

function non_capture(): Non_captureContext

Returns

non_close_paren()

function non_close_paren(): Non_close_parenContext

Returns

non_close_parens()

function non_close_parens(): Non_close_parensContext

Returns

number()

function number(): NumberContext

Returns

octal_char()

function octal_char(): Octal_charContext

Returns

octal_digit()

function octal_digit(): Octal_digitContext

Returns

option()

function option(): OptionContext

Returns

option_flag()

function option_flag(): Option_flagContext

Returns

parse()

function parse(): ParseContext

Returns

quantifier()

function quantifier(): QuantifierContext

Returns

quantifier_type()

function quantifier_type(): Quantifier_typeContext

Returns

shared_atom()

function shared_atom(): Shared_atomContext

Returns

shared_literal()

function shared_literal(): Shared_literalContext

Returns

Inherited Method Details

action(RuleContext | undefined, number, number)

function action(_localctx: RuleContext | undefined, ruleIndex: number, actionIndex: number)

Parameters

_localctx

RuleContext | undefined

ruleIndex

number

actionIndex

number

Inherited From Recognizer.action

addErrorListener(ANTLRErrorListener<Token>)

function addErrorListener(listener: ANTLRErrorListener<Token>)

Parameters

listener

ANTLRErrorListener<Token>

Inherited From Recognizer.addErrorListener

addParseListener(ParseTreeListener)

Registers listener to receive events during the parsing process. To support output-preserving grammar transformations (including but not limited to left-recursion removal, automated left-factoring, and optimized code generation), calls to listener methods during the parse may differ substantially from calls made by <xref:ParseTreeWalker%23DEFAULT> used after the parse is complete. In particular, rule entry and exit events may occur in a different order during the parse than after the parser. In addition, calls to certain rule entry methods may be omitted.

With the following specific exceptions, calls to listener events are deterministic, i.e. for identical input the calls to listener methods will be the same.

  • Alterations to the grammar used to generate code may change the behavior of the listener calls.
  • Alterations to the command line options passed to ANTLR 4 when generating the parser may change the behavior of the listener calls.
  • Changing the version of the ANTLR Tool used to generate the parser may change the behavior of the listener calls.
function addParseListener(listener: ParseTreeListener)

Parameters

listener

ParseTreeListener

the listener to add

Inherited From Parser.addParseListener

compileParseTreePattern(string, number)

The preferred method of getting a tree pattern. For example, here's a sample use:

let t: ParseTree = parser.expr();
let p: ParseTreePattern = await parser.compileParseTreePattern("<ID>+0", MyParser.RULE_expr);
let m: ParseTreeMatch = p.match(t);
let id: string = m.get("ID");
function compileParseTreePattern(pattern: string, patternRuleIndex: number): Promise<ParseTreePattern>

Parameters

pattern

string

patternRuleIndex

number

Returns

Promise<ParseTreePattern>

Inherited From Parser.compileParseTreePattern

compileParseTreePattern(string, number, Lexer)

The same as [int)](xref:%23compileParseTreePattern(String%2C) but specify a CommonRegexLexer rather than trying to deduce it from this parser.

function compileParseTreePattern(pattern: string, patternRuleIndex: number, lexer?: Lexer): Promise<ParseTreePattern>

Parameters

pattern

string

patternRuleIndex

number

lexer

Lexer

Returns

Promise<ParseTreePattern>

Inherited From Parser.compileParseTreePattern

consume()

Consume and return the current symbol. E.g., given the following input with A being the current lookahead symbol, this function moves the cursor to B and returns A.

A B
^

If the parser is not in error recovery mode, the consumed symbol is added to the parse tree using <xref:ParserRuleContext%23addChild(TerminalNode)>, and <xref:ParseTreeListener%23visitTerminal> is called on any parse listeners. If the parser is in error recovery mode, the consumed symbol is added to the parse tree using [Token)](xref:%23createErrorNode(ParserRuleContext%2C) then <xref:ParserRuleContext%23addErrorNode(ErrorNode)> and <xref:ParseTreeListener%23visitErrorNode> is called on any parse listeners.

function consume(): Token

Returns

Token

Inherited From Parser.consume

createErrorNode(ParserRuleContext, Token)

How to create an error node, given a token, associated with a parent. Typically, the error node to create is not a function of the parent.

function createErrorNode(parent: ParserRuleContext, t: Token): ErrorNode

Parameters

parent

ParserRuleContext

t

Token

Returns

ErrorNode

Inherited From Parser.createErrorNode

createTerminalNode(ParserRuleContext, Token)

How to create a token leaf node associated with a parent. Typically, the terminal node to create is not a function of the parent.

function createTerminalNode(parent: ParserRuleContext, t: Token): TerminalNode

Parameters

parent

ParserRuleContext

t

Token

Returns

TerminalNode

Inherited From Parser.createTerminalNode

dumpDFA()

For debugging and other purposes.

function dumpDFA()

Inherited From Parser.dumpDFA

enterLeftFactoredRule(ParserRuleContext, number, number)

function enterLeftFactoredRule(localctx: ParserRuleContext, state: number, ruleIndex: number)

Parameters

localctx

ParserRuleContext

state

number

ruleIndex

number

Inherited From Parser.enterLeftFactoredRule

enterOuterAlt(ParserRuleContext, number)

function enterOuterAlt(localctx: ParserRuleContext, altNum: number)

Parameters

localctx

ParserRuleContext

altNum

number

Inherited From Parser.enterOuterAlt

enterRecursionRule(ParserRuleContext, number, number, number)

function enterRecursionRule(localctx: ParserRuleContext, state: number, ruleIndex: number, precedence: number)

Parameters

localctx

ParserRuleContext

state

number

ruleIndex

number

precedence

number

Inherited From Parser.enterRecursionRule

enterRule(ParserRuleContext, number, number)

Always called by generated parsers upon entry to a rule. Access field <xref:%23_ctx> get the current context.

function enterRule(localctx: ParserRuleContext, state: number, ruleIndex: number)

Parameters

localctx

ParserRuleContext

state

number

ruleIndex

number

Inherited From Parser.enterRule

exitRule()

function exitRule()

Inherited From Parser.exitRule

getATNWithBypassAlts()

The ATN with bypass alternatives is expensive to create so we create it lazily. @ if the current parser does not implement the serializedATN property.

function getATNWithBypassAlts(): ATN

Returns

ATN

Inherited From Parser.getATNWithBypassAlts

getDFAStrings()

For debugging and other purposes.

function getDFAStrings(): string[]

Returns

string[]

Inherited From Parser.getDFAStrings

getErrorHeader(RecognitionException)

What is the error header, normally line/character position information?

function getErrorHeader(e: RecognitionException): string

Parameters

e

RecognitionException

Returns

string

Inherited From Recognizer.getErrorHeader

getErrorListenerDispatch()

function getErrorListenerDispatch(): ParserErrorListener

Returns

ParserErrorListener

Inherited From Parser.getErrorListenerDispatch

getErrorListeners()

function getErrorListeners(): Array<ANTLRErrorListener<Token>>

Returns

Array<ANTLRErrorListener<Token>>

Inherited From Recognizer.getErrorListeners

getExpectedTokens()

Computes the set of input symbols which could follow the current parser state and context, as given by <xref:%23getState> and <xref:%23getContext>, respectively.

See ATN#getExpectedTokens(int, RuleContext)

function getExpectedTokens(): IntervalSet

Returns

IntervalSet

Inherited From Parser.getExpectedTokens

getExpectedTokensWithinCurrentRule()

function getExpectedTokensWithinCurrentRule(): IntervalSet

Returns

IntervalSet

Inherited From Parser.getExpectedTokensWithinCurrentRule

getInvokingContext(number)

function getInvokingContext(ruleIndex: number): ParserRuleContext | undefined

Parameters

ruleIndex

number

Returns

ParserRuleContext | undefined

Inherited From Parser.getInvokingContext

getParseListeners()

function getParseListeners(): ParseTreeListener[]

Returns

ParseTreeListener[]

Inherited From Parser.getParseListeners

getRuleIndex(string)

Get a rule's index (i.e., RULE_ruleName field) or -1 if not found.

function getRuleIndex(ruleName: string): number

Parameters

ruleName

string

Returns

number

Inherited From Parser.getRuleIndex

getRuleIndexMap()

Get a map from rule names to rule indexes. Used for XPath and tree pattern compilation.

function getRuleIndexMap(): ReadonlyMap<string, number>

Returns

ReadonlyMap<string, number>

Inherited From Recognizer.getRuleIndexMap

getRuleInvocationStack(RuleContext)

Return List<String> of the rule names in your parser instance leading up to a call to the current rule. You could override if you want more details such as the file/line info of where in the ATN a rule is invoked. This is very useful for error messages.

function getRuleInvocationStack(ctx?: RuleContext): string[]

Parameters

ctx

RuleContext

Returns

string[]

Inherited From Parser.getRuleInvocationStack

getTokenType(string)

function getTokenType(tokenName: string): number

Parameters

tokenName

string

Returns

number

Inherited From Recognizer.getTokenType

getTokenTypeMap()

Get a map from token names to token types. Used for XPath and tree pattern compilation.

function getTokenTypeMap(): ReadonlyMap<string, number>

Returns

ReadonlyMap<string, number>

Inherited From Recognizer.getTokenTypeMap

inContext(string)

function inContext(context: string): boolean

Parameters

context

string

Returns

boolean

Inherited From Parser.inContext

isExpectedToken(number)

Checks whether or not symbol can follow the current state in the ATN. The behavior of this method is equivalent to the following, but is implemented such that the complete context-sensitive follow set does not need to be explicitly constructed.

return getExpectedTokens().contains(symbol);
function isExpectedToken(symbol: number): boolean

Parameters

symbol

number

the symbol type to check

Returns

boolean

true if symbol can follow the current state in the ATN, otherwise false.

Inherited From Parser.isExpectedToken

match(number)

Match current input symbol against ttype. If the symbol type matches, <xref:ANTLRErrorStrategy%23reportMatch> and <xref:%23consume> are called to complete the match process. If the symbol type does not match, <xref:ANTLRErrorStrategy%23recoverInline> is called on the current error strategy to attempt recovery. If <xref:%23getBuildParseTree> is true and the token index of the symbol returned by <xref:ANTLRErrorStrategy%23recoverInline> is -1, the symbol is added to the parse tree by calling [Token)](xref:%23createErrorNode(ParserRuleContext%2C) then <xref:ParserRuleContext%23addErrorNode(ErrorNode)>.

function match(ttype: number): Token

Parameters

ttype

number

the token type to match

Returns

Token

the matched symbol @ if the current input symbol did not match ttype and the error strategy could not recover from the mismatched symbol

Inherited From Parser.match

matchWildcard()

Match current input symbol as a wildcard. If the symbol type matches (i.e. has a value greater than 0), <xref:ANTLRErrorStrategy%23reportMatch> and <xref:%23consume> are called to complete the match process. If the symbol type does not match, <xref:ANTLRErrorStrategy%23recoverInline> is called on the current error strategy to attempt recovery. If <xref:%23getBuildParseTree> is true and the token index of the symbol returned by <xref:ANTLRErrorStrategy%23recoverInline> is -1, the symbol is added to the parse tree by calling [Token)](xref:Parser%23createErrorNode(ParserRuleContext%2C) then <xref:ParserRuleContext%23addErrorNode(ErrorNode)>.

function matchWildcard(): Token

Returns

Token

the matched symbol @ if the current input symbol did not match a wildcard and the error strategy could not recover from the mismatched symbol

Inherited From Parser.matchWildcard

notifyErrorListeners(string)

function notifyErrorListeners(msg: string)

Parameters

msg

string

Inherited From Parser.notifyErrorListeners

notifyErrorListeners(string, Token | null, RecognitionException | undefined)

function notifyErrorListeners(msg: string, offendingToken: Token | null, e: RecognitionException | undefined)

Parameters

msg

string

offendingToken

Token | null

e

RecognitionException | undefined

Inherited From Parser.notifyErrorListeners

precpred(RuleContext, number)

function precpred(localctx: RuleContext, precedence: number): boolean

Parameters

localctx

RuleContext

precedence

number

Returns

boolean

Inherited From Parser.precpred

pushNewRecursionContext(ParserRuleContext, number, number)

Like <xref:%23enterRule> but for recursive rules. Make the current context the child of the incoming localctx.

function pushNewRecursionContext(localctx: ParserRuleContext, state: number, ruleIndex: number)

Parameters

localctx

ParserRuleContext

state

number

ruleIndex

number

Inherited From Parser.pushNewRecursionContext

removeErrorListener(ANTLRErrorListener<Token>)

function removeErrorListener(listener: ANTLRErrorListener<Token>)

Parameters

listener

ANTLRErrorListener<Token>

Inherited From Recognizer.removeErrorListener

removeErrorListeners()

function removeErrorListeners()

Inherited From Recognizer.removeErrorListeners

removeParseListener(ParseTreeListener)

Remove listener from the list of parse listeners. If listener is undefined or has not been added as a parse listener, this method does nothing.

See #addParseListener

function removeParseListener(listener: ParseTreeListener)

Parameters

listener

ParseTreeListener

the listener to remove

Inherited From Parser.removeParseListener

removeParseListeners()

Remove all parse listeners.

See #addParseListener

function removeParseListeners()

Inherited From Parser.removeParseListeners

reset()

reset the parser's state

function reset()

Inherited From Parser.reset

reset(boolean)

function reset(resetInput: boolean)

Parameters

resetInput

boolean

Inherited From Parser.reset

sempred(RuleContext | undefined, number, number)

function sempred(_localctx: RuleContext | undefined, ruleIndex: number, actionIndex: number): boolean

Parameters

_localctx

RuleContext | undefined

ruleIndex

number

actionIndex

number

Returns

boolean

Inherited From Recognizer.sempred

setProfile(boolean)

function setProfile(profile: boolean): Promise<void>

Parameters

profile

boolean

Returns

Promise<void>

Inherited From Parser.setProfile

unrollRecursionContexts(ParserRuleContext)

function unrollRecursionContexts(_parentctx: ParserRuleContext)

Parameters

_parentctx

ParserRuleContext

Inherited From Parser.unrollRecursionContexts