CommonRegexParser class
- 扩展
-
Parser
构造函数
Common |
属性
继承属性
atn | 获取识别器用于预测的 serializedATN。 |
build |
在分析期间跟踪 <xref:ParserRuleContext> 对象,并使用 <xref:ParserRuleContext%23children> 列表将它们挂钩,以便形成分析树。 从开始规则返回的 <xref:ParserRuleContext> 表示分析树的根。 请注意,如果不生成分析树,规则上下文只会向上点。 当规则退出时,它将返回上下文,但如果没有人持有引用,则会回收垃圾。 它向上点,但没有人指向它。 生成分析树时,我们将所有这些上下文添加到 <xref:ParserRuleContext%23children> 列表。 然后,上下文不是垃圾回收的候选项。 |
context | |
current |
匹配需要返回当前输入符号,该符号将放入关联标记 ref 的标签中;例如,x=ID。 |
EOF | |
error |
|
input |
设置令牌流并重置分析程序。 |
interpreter | 设置识别器用于预测的 ATN 解释器。 |
is |
|
is |
在分析期间,有时有助于侦听规则进入和退出事件以及令牌匹配。 这是用于快速和脏调试。 |
number |
获取分析期间报告的语法错误数。 每次调用 <xref:%23notifyErrorListeners> 时,都会递增此值。 请参阅 #notifyErrorListeners |
parse |
|
precedence | 获取最高优先级规则的优先级别。 |
rule |
|
source |
|
state | 指示识别器已更改与传入的 ATN 状态一致的内部状态。 这样,我们总是知道我们在 ATN 中的位置,因为分析器一直在。 规则上下文对象构成一个堆栈,用于查看调用规则的堆栈。 结合这一点,我们已获得完整的 ATN 配置信息。 |
token |
方法
继承的方法
action(Rule |
|
add |
|
add |
注册 对于以下特定异常,对侦听器事件的调用 确定性,即对于相同的输入,对侦听器方法的调用将相同。
|
compile |
获取树模式的首选方法。 例如,下面是一个示例用法:
|
compile |
与 [int](xref:%23compileParseTreePattern(字符串%2C)相同,但指定 CommonRegexLexer,而不是尝试从此分析器推断它。 |
consume() | 使用并返回当前符号 。
例如,鉴于以下输入,
如果分析程序未处于错误恢复模式,则使用符号会使用 <xref:ParserRuleContext%23addChild(TerminalNode)>添加到分析树中,并在任何分析侦听器上调用 <xref:ParseTreeListener%23visitTerminal>。 如果分析程序 处于错误恢复模式,则使用符号会使用 [Token](xref:%23createErrorNode(ParserRuleContext%2C)添加到分析树中,然后在任何分析侦听器上调用 <xref:ParserRuleContext%23addErrorNode(ErrorNode)> 和 <xref:ParseTreeListener%23visitErrorNode>。 |
create |
如何创建与父级关联的令牌的错误节点。 通常,要创建的错误节点不是父级的函数。 |
create |
如何创建与父节点关联的令牌叶节点。 通常,要创建的终端节点不是父级的函数。 |
dumpDFA() | 用于调试和其他目的。 |
enter |
|
enter |
|
enter |
|
enter |
在进入规则时,始终由生成的分析程序调用。 Access 字段 <xref:%23_ctx> 获取当前上下文。 |
exit |
|
get |
使用旁路替代项的 ATN 非常昂贵,因此我们懒散地创建它。
@ 如果当前分析程序未实现 |
get |
用于调试和其他目的。 |
get |
错误标头是什么,通常是行/字符位置信息? |
get |
|
get |
|
get |
计算可以分别遵循当前分析器状态和上下文的输入符号集,<xref:%23getState> 和 <xref:%23getContext>。 请参阅 ATN#getExpectedTokens(int、RuleContext) |
get |
|
get |
|
get |
|
get |
获取规则的索引(即 |
get |
从规则名称到规则索引获取映射。 用于 XPath 和树模式编译。 |
get |
返回列表<字符串> 分析器实例中导致对当前规则的调用。 如果需要更多详细信息(例如调用 ATN 中规则的位置的文件/行信息),可以重写。 这对于错误消息非常有用。 |
get |
|
get |
从令牌名称到令牌类型获取映射。 用于 XPath 和树模式编译。 |
in |
|
is |
检查
|
match(number) | 将当前输入符号与 |
match |
将当前输入符号匹配为通配符。 如果符号类型匹配(即值大于 0),则调用 <xref:ANTLRErrorStrategy%23reportMatch> 和 <xref:%23consume> 来完成匹配过程。
如果符号类型不匹配,则对当前错误策略调用 <xref:ANTLRErrorStrategy%23recoverInline> 以尝试恢复。 如果 <xref:%23getBuildParseTree> |
notify |
|
notify |
|
precpred(Rule |
|
push |
与 <xref:%23enterRule> 类似,但对于递归规则。 将当前上下文设置为传入 localctx 的子级。 |
remove |
|
remove |
|
remove |
从分析侦听器列表中删除 请参阅 #addParseListener |
remove |
删除所有分析侦听器。 请参阅 #addParseListener |
reset() | 重置分析程序的状态 |
reset(boolean) | |
sempred(Rule |
|
set |
|
unroll |
构造函数详细信息
CommonRegexParser(TokenStream)
new CommonRegexParser(input: TokenStream)
参数
- input
-
TokenStream
属性详细信息
ALC
public static ALC: 44 = 44
属性值
44
Ampersand
public static Ampersand: 43 = 43
属性值
43
AUC
public static AUC: 70 = 70
属性值
70
Backslash
public static Backslash: 10 = 10
属性值
10
BellChar
public static BellChar: 3 = 3
属性值
3
BLC
public static BLC: 45 = 45
属性值
45
BlockQuoted
public static BlockQuoted: 2 = 2
属性值
2
BUC
public static BUC: 71 = 71
属性值
71
Caret
public static Caret: 23 = 23
属性值
23
CarriageReturn
public static CarriageReturn: 8 = 8
属性值
8
CharacterClassEnd
public static CharacterClassEnd: 22 = 22
属性值
22
CharacterClassStart
public static CharacterClassStart: 21 = 21
属性值
21
CharWithoutProperty
public static CharWithoutProperty: 16 = 16
属性值
16
CharWithProperty
public static CharWithProperty: 15 = 15
属性值
15
CLC
public static CLC: 46 = 46
属性值
46
CloseBrace
public static CloseBrace: 29 = 29
属性值
29
CloseParen
public static CloseParen: 34 = 34
属性值
34
Colon
public static Colon: 39 = 39
属性值
39
Comma
public static Comma: 30 = 30
属性值
30
ControlChar
public static ControlChar: 4 = 4
属性值
4
CUC
public static CUC: 72 = 72
属性值
72
D0
public static D0: 105 = 105
属性值
105
D1
public static D1: 96 = 96
属性值
96
D2
public static D2: 97 = 97
属性值
97
D3
public static D3: 98 = 98
属性值
98
D4
public static D4: 99 = 99
属性值
99
D5
public static D5: 100 = 100
属性值
100
D6
public static D6: 101 = 101
属性值
101
D7
public static D7: 102 = 102
属性值
102
D8
public static D8: 103 = 103
属性值
103
D9
public static D9: 104 = 104
属性值
104
DecimalDigit
public static DecimalDigit: 13 = 13
属性值
13
DLC
public static DLC: 47 = 47
属性值
47
Dot
public static Dot: 12 = 12
属性值
12
DUC
public static DUC: 73 = 73
属性值
73
ELC
public static ELC: 48 = 48
属性值
48
EndOfSubject
public static EndOfSubject: 31 = 31
属性值
31
Equals
public static Equals: 41 = 41
属性值
41
EscapeChar
public static EscapeChar: 5 = 5
属性值
5
EUC
public static EUC: 74 = 74
属性值
74
Exclamation
public static Exclamation: 42 = 42
属性值
42
FLC
public static FLC: 49 = 49
属性值
49
FormFeed
public static FormFeed: 6 = 6
属性值
6
FUC
public static FUC: 75 = 75
属性值
75
GLC
public static GLC: 50 = 50
属性值
50
grammarFileName
string grammarFileName
属性值
string
GreaterThan
public static GreaterThan: 36 = 36
属性值
36
GUC
public static GUC: 76 = 76
属性值
76
Hash
public static Hash: 40 = 40
属性值
40
HexChar
public static HexChar: 11 = 11
属性值
11
HLC
public static HLC: 51 = 51
属性值
51
HUC
public static HUC: 77 = 77
属性值
77
Hyphen
public static Hyphen: 24 = 24
属性值
24
ILC
public static ILC: 52 = 52
属性值
52
IUC
public static IUC: 78 = 78
属性值
78
JLC
public static JLC: 53 = 53
属性值
53
JUC
public static JUC: 79 = 79
属性值
79
KLC
public static KLC: 54 = 54
属性值
54
KUC
public static KUC: 80 = 80
属性值
80
LessThan
public static LessThan: 35 = 35
属性值
35
LLC
public static LLC: 55 = 55
属性值
55
LUC
public static LUC: 81 = 81
属性值
81
MLC
public static MLC: 56 = 56
属性值
56
MUC
public static MUC: 82 = 82
属性值
82
NewLine
public static NewLine: 7 = 7
属性值
7
NLC
public static NLC: 57 = 57
属性值
57
NotDecimalDigit
public static NotDecimalDigit: 14 = 14
属性值
14
NotWhiteSpace
public static NotWhiteSpace: 18 = 18
属性值
18
NotWordChar
public static NotWordChar: 20 = 20
属性值
20
NUC
public static NUC: 83 = 83
属性值
83
OLC
public static OLC: 58 = 58
属性值
58
OpenBrace
public static OpenBrace: 28 = 28
属性值
28
OpenParen
public static OpenParen: 33 = 33
属性值
33
OtherChar
public static OtherChar: 106 = 106
属性值
106
OUC
public static OUC: 84 = 84
属性值
84
Pipe
public static Pipe: 32 = 32
属性值
32
PLC
public static PLC: 59 = 59
属性值
59
Plus
public static Plus: 26 = 26
属性值
26
PUC
public static PUC: 85 = 85
属性值
85
QLC
public static QLC: 60 = 60
属性值
60
QUC
public static QUC: 86 = 86
属性值
86
QuestionMark
public static QuestionMark: 25 = 25
属性值
25
Quoted
public static Quoted: 1 = 1
属性值
1
RLC
public static RLC: 61 = 61
属性值
61
RUC
public static RUC: 87 = 87
属性值
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",
]
属性值
string[]
ruleNames
string[] ruleNames
属性值
string[]
RULE_alpha_nums
public static RULE_alpha_nums: 23 = 23
属性值
23
RULE_alternation
public static RULE_alternation: 1 = 1
属性值
1
RULE_atom
public static RULE_atom: 11 = 11
属性值
11
RULE_capture
public static RULE_capture: 7 = 7
属性值
7
RULE_cc_atom
public static RULE_cc_atom: 12 = 12
属性值
12
RULE_cc_literal
public static RULE_cc_literal: 15 = 15
属性值
15
RULE_character_class
public static RULE_character_class: 6 = 6
属性值
6
RULE_digit
public static RULE_digit: 21 = 21
属性值
21
RULE_digits
public static RULE_digits: 20 = 20
属性值
20
RULE_element
public static RULE_element: 3 = 3
属性值
3
RULE_expr
public static RULE_expr: 2 = 2
属性值
2
RULE_letter
public static RULE_letter: 26 = 26
属性值
26
RULE_literal
public static RULE_literal: 14 = 14
属性值
14
RULE_name
public static RULE_name: 22 = 22
属性值
22
RULE_non_capture
public static RULE_non_capture: 8 = 8
属性值
8
RULE_non_close_paren
public static RULE_non_close_paren: 25 = 25
属性值
25
RULE_non_close_parens
public static RULE_non_close_parens: 24 = 24
属性值
24
RULE_number
public static RULE_number: 17 = 17
属性值
17
RULE_octal_char
public static RULE_octal_char: 18 = 18
属性值
18
RULE_octal_digit
public static RULE_octal_digit: 19 = 19
属性值
19
RULE_option
public static RULE_option: 9 = 9
属性值
9
RULE_option_flag
public static RULE_option_flag: 10 = 10
属性值
10
RULE_parse
public static RULE_parse: 0 = 0
属性值
0
RULE_quantifier
public static RULE_quantifier: 4 = 4
属性值
4
RULE_quantifier_type
public static RULE_quantifier_type: 5 = 5
属性值
5
RULE_shared_atom
public static RULE_shared_atom: 13 = 13
属性值
13
RULE_shared_literal
public static RULE_shared_literal: 16 = 16
属性值
16
serializedATN
string serializedATN
属性值
string
SingleQuote
public static SingleQuote: 37 = 37
属性值
37
SLC
public static SLC: 62 = 62
属性值
62
Star
public static Star: 27 = 27
属性值
27
SUC
public static SUC: 88 = 88
属性值
88
Tab
public static Tab: 9 = 9
属性值
9
TLC
public static TLC: 63 = 63
属性值
63
TUC
public static TUC: 89 = 89
属性值
89
ULC
public static ULC: 64 = 64
属性值
64
Underscore
public static Underscore: 38 = 38
属性值
38
UUC
public static UUC: 90 = 90
属性值
90
VLC
public static VLC: 65 = 65
属性值
65
VOCABULARY
public static VOCABULARY: Vocabulary = new VocabularyImpl(CommonRegexParser._LITERAL_NAMES, CommonRegexParser._SYMBOLIC_NAMES, [])
属性值
Vocabulary
vocabulary
Vocabulary vocabulary
属性值
Vocabulary
VUC
public static VUC: 91 = 91
属性值
91
WhiteSpace
public static WhiteSpace: 17 = 17
属性值
17
WLC
public static WLC: 66 = 66
属性值
66
WordChar
public static WordChar: 19 = 19
属性值
19
WUC
public static WUC: 92 = 92
属性值
92
XLC
public static XLC: 67 = 67
属性值
67
XUC
public static XUC: 93 = 93
属性值
93
YLC
public static YLC: 68 = 68
属性值
68
YUC
public static YUC: 94 = 94
属性值
94
ZLC
public static ZLC: 69 = 69
属性值
69
ZUC
public static ZUC: 95 = 95
属性值
95
继承属性详细信息
atn
buildParseTree
在分析期间跟踪 <xref:ParserRuleContext> 对象,并使用 <xref:ParserRuleContext%23children> 列表将它们挂钩,以便形成分析树。 从开始规则返回的 <xref:ParserRuleContext> 表示分析树的根。 请注意,如果不生成分析树,规则上下文只会向上点。 当规则退出时,它将返回上下文,但如果没有人持有引用,则会回收垃圾。 它向上点,但没有人指向它。
生成分析树时,我们将所有这些上下文添加到 <xref:ParserRuleContext%23children> 列表。 然后,上下文不是垃圾回收的候选项。
buildParseTree: boolean
属性值
boolean
继承自 Parser.buildParseTree
context
context: ParserRuleContext
属性值
ParserRuleContext
继承自 Parser.context
currentToken
匹配需要返回当前输入符号,该符号将放入关联标记 ref 的标签中;例如,x=ID。
currentToken: Token
属性值
Token
继承自 Parser.currentToken
EOF
static EOF: number
属性值
number
继承自 Recognizer.EOF 的
errorHandler
errorHandler: ANTLRErrorStrategy
属性值
ANTLRErrorStrategy
继承自 Parser.errorHandler
inputStream
设置令牌流并重置分析程序。
inputStream: TokenStream
属性值
TokenStream
继承自 Parser.inputStream
interpreter
设置识别器用于预测的 ATN 解释器。
interpreter: ParserATNSimulator
属性值
ParserATNSimulator
继承自 Recognizer.interpreter
isMatchedEOF
isMatchedEOF: boolean
属性值
boolean
继承自 Parser.isMatchedEOF
isTrace
在分析期间,有时有助于侦听规则进入和退出事件以及令牌匹配。 这是用于快速和脏调试。
isTrace: boolean
属性值
boolean
继承自 Parser.isTrace
numberOfSyntaxErrors
获取分析期间报告的语法错误数。 每次调用 <xref:%23notifyErrorListeners> 时,都会递增此值。
请参阅 #notifyErrorListeners
numberOfSyntaxErrors: number
属性值
number
继承自 Parser.numberOfSyntaxErrors
parseInfo
parseInfo: Promise<ParseInfo | undefined>
属性值
Promise<ParseInfo | undefined>
继承自 Parser.parseInfo
precedence
获取最高优先级规则的优先级别。
precedence: number
属性值
number
继承自 Parser.precedence
ruleContext
ruleContext: ParserRuleContext
属性值
ParserRuleContext
继承自 Parser.ruleContext
sourceName
sourceName: string
属性值
string
继承自 Parser.sourceName
state
指示识别器已更改与传入的 ATN 状态一致的内部状态。 这样,我们总是知道我们在 ATN 中的位置,因为分析器一直在。 规则上下文对象构成一个堆栈,用于查看调用规则的堆栈。 结合这一点,我们已获得完整的 ATN 配置信息。
state: number
属性值
number
继承自 Recognizer.state
tokenFactory
tokenFactory: TokenFactory
属性值
TokenFactory
继承自 Parser.tokenFactory
方法详细信息
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()
继承的方法详细信息
action(RuleContext | undefined, number, number)
function action(_localctx: RuleContext | undefined, ruleIndex: number, actionIndex: number)
参数
- _localctx
-
RuleContext | undefined
- ruleIndex
-
number
- actionIndex
-
number
继承自 Recognizer.action
addErrorListener(ANTLRErrorListener<Token>)
function addErrorListener(listener: ANTLRErrorListener<Token>)
参数
- listener
-
ANTLRErrorListener<Token>
继承自 Recognizer.addErrorListener
addParseListener(ParseTreeListener)
注册 listener
以在分析过程中接收事件。
为了支持输出保留语法转换(包括但不限于左递归删除、自动左因素处理和优化代码生成),分析期间对侦听器方法的调用可能与分析完成后使用的 <xref:ParseTreeWalker%23DEFAULT> 调用有很大不同。 具体而言,在分析期间,规则进入和退出事件的顺序可能与分析器之后不同。 此外,可以省略对某些规则条目方法的调用。
对于以下特定异常,对侦听器事件的调用 确定性,即对于相同的输入,对侦听器方法的调用将相同。
- 对用于生成代码的语法的更改可能会更改侦听器调用的行为。
- 生成分析器时传递给 ANTLR 4 的命令行选项的更改可能会更改侦听器调用的行为。
- 更改用于生成分析程序的 ANTLR 工具的版本可能会更改侦听器调用的行为。
function addParseListener(listener: ParseTreeListener)
参数
- listener
-
ParseTreeListener
要添加的侦听器
继承自 Parser.addParseListener
compileParseTreePattern(string, number)
获取树模式的首选方法。 例如,下面是一个示例用法:
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>
参数
- pattern
-
string
- patternRuleIndex
-
number
返回
Promise<ParseTreePattern>
继承自 Parser.compileParseTreePattern
compileParseTreePattern(string, number, Lexer)
与 [int](xref:%23compileParseTreePattern(字符串%2C)相同,但指定 CommonRegexLexer,而不是尝试从此分析器推断它。
function compileParseTreePattern(pattern: string, patternRuleIndex: number, lexer?: Lexer): Promise<ParseTreePattern>
参数
- pattern
-
string
- patternRuleIndex
-
number
- lexer
-
Lexer
返回
Promise<ParseTreePattern>
继承自 Parser.compileParseTreePattern
consume()
使用并返回当前符号 。
例如,鉴于以下输入,A
为当前看头符号,此函数将光标移动到 B
并返回 A
。
A B
^
如果分析程序未处于错误恢复模式,则使用符号会使用 <xref:ParserRuleContext%23addChild(TerminalNode)>添加到分析树中,并在任何分析侦听器上调用 <xref:ParseTreeListener%23visitTerminal>。 如果分析程序 处于错误恢复模式,则使用符号会使用 [Token](xref:%23createErrorNode(ParserRuleContext%2C)添加到分析树中,然后在任何分析侦听器上调用 <xref:ParserRuleContext%23addErrorNode(ErrorNode)> 和 <xref:ParseTreeListener%23visitErrorNode>。
function consume(): Token
返回
Token
继承自 Parser.consume
createErrorNode(ParserRuleContext, Token)
如何创建与父级关联的令牌的错误节点。 通常,要创建的错误节点不是父级的函数。
function createErrorNode(parent: ParserRuleContext, t: Token): ErrorNode
参数
- parent
-
ParserRuleContext
- t
-
Token
返回
ErrorNode
继承自 Parser.createErrorNode
createTerminalNode(ParserRuleContext, Token)
如何创建与父节点关联的令牌叶节点。 通常,要创建的终端节点不是父级的函数。
function createTerminalNode(parent: ParserRuleContext, t: Token): TerminalNode
参数
- parent
-
ParserRuleContext
- t
-
Token
返回
TerminalNode
继承自 Parser.createTerminalNode
dumpDFA()
用于调试和其他目的。
function dumpDFA()
继承自 Parser.dumpDFA
enterLeftFactoredRule(ParserRuleContext, number, number)
function enterLeftFactoredRule(localctx: ParserRuleContext, state: number, ruleIndex: number)
参数
- localctx
-
ParserRuleContext
- state
-
number
- ruleIndex
-
number
继承自 Parser.enterLeftFactoredRule
enterOuterAlt(ParserRuleContext, number)
function enterOuterAlt(localctx: ParserRuleContext, altNum: number)
参数
- localctx
-
ParserRuleContext
- altNum
-
number
继承自 Parser.enterOuterAlt
enterRecursionRule(ParserRuleContext, number, number, number)
function enterRecursionRule(localctx: ParserRuleContext, state: number, ruleIndex: number, precedence: number)
参数
- localctx
-
ParserRuleContext
- state
-
number
- ruleIndex
-
number
- precedence
-
number
继承自 Parser.enterRecursionRule
enterRule(ParserRuleContext, number, number)
在进入规则时,始终由生成的分析程序调用。 Access 字段 <xref:%23_ctx> 获取当前上下文。
function enterRule(localctx: ParserRuleContext, state: number, ruleIndex: number)
参数
- localctx
-
ParserRuleContext
- state
-
number
- ruleIndex
-
number
继承自 Parser.enterRule
exitRule()
function exitRule()
继承自 Parser.exitRule
getATNWithBypassAlts()
使用旁路替代项的 ATN 非常昂贵,因此我们懒散地创建它。
@ 如果当前分析程序未实现 serializedATN
属性。
function getATNWithBypassAlts(): ATN
返回
ATN
继承自 Parser.getATNWithBypassAlts
getDFAStrings()
用于调试和其他目的。
function getDFAStrings(): string[]
返回
string[]
继承自 Parser.getDFAStrings
getErrorHeader(RecognitionException)
错误标头是什么,通常是行/字符位置信息?
function getErrorHeader(e: RecognitionException): string
参数
- e
-
RecognitionException
返回
string
继承自 Recognizer.getErrorHeader
getErrorListenerDispatch()
function getErrorListenerDispatch(): ParserErrorListener
返回
ParserErrorListener
继承自 Parser.getErrorListenerDispatch
getErrorListeners()
function getErrorListeners(): Array<ANTLRErrorListener<Token>>
返回
Array<ANTLRErrorListener<Token>>
继承自 Recognizer.getErrorListeners
getExpectedTokens()
计算可以分别遵循当前分析器状态和上下文的输入符号集,<xref:%23getState> 和 <xref:%23getContext>。
请参阅 ATN#getExpectedTokens(int、RuleContext)
function getExpectedTokens(): IntervalSet
返回
IntervalSet
继承自 Parser.getExpectedTokens
getExpectedTokensWithinCurrentRule()
function getExpectedTokensWithinCurrentRule(): IntervalSet
返回
IntervalSet
继承自 Parser.getExpectedTokensWithinCurrentRule
getInvokingContext(number)
function getInvokingContext(ruleIndex: number): ParserRuleContext | undefined
参数
- ruleIndex
-
number
返回
ParserRuleContext | undefined
继承自 Parser.getInvokingContext
getParseListeners()
function getParseListeners(): ParseTreeListener[]
返回
ParseTreeListener[]
继承自 Parser.getParseListeners
getRuleIndex(string)
获取规则的索引(即 RULE_ruleName
字段)或 -1(如果未找到)。
function getRuleIndex(ruleName: string): number
参数
- ruleName
-
string
返回
number
继承自 Parser.getRuleIndex
getRuleIndexMap()
从规则名称到规则索引获取映射。 用于 XPath 和树模式编译。
function getRuleIndexMap(): ReadonlyMap<string, number>
返回
ReadonlyMap<string, number>
继承自 Recognizer.getRuleIndexMap
getRuleInvocationStack(RuleContext)
返回列表<字符串> 分析器实例中导致对当前规则的调用。 如果需要更多详细信息(例如调用 ATN 中规则的位置的文件/行信息),可以重写。 这对于错误消息非常有用。
function getRuleInvocationStack(ctx?: RuleContext): string[]
参数
- ctx
-
RuleContext
返回
string[]
继承自 Parser.getRuleInvocationStack
getTokenType(string)
function getTokenType(tokenName: string): number
参数
- tokenName
-
string
返回
number
继承自 Recognizer.getTokenType
getTokenTypeMap()
从令牌名称到令牌类型获取映射。 用于 XPath 和树模式编译。
function getTokenTypeMap(): ReadonlyMap<string, number>
返回
ReadonlyMap<string, number>
继承自 Recognizer.getTokenTypeMap
inContext(string)
function inContext(context: string): boolean
参数
- context
-
string
返回
boolean
继承自 Parser.inContext
isExpectedToken(number)
检查 symbol
是否可以遵循 ATN 中的当前状态。 此方法的行为等效于以下内容,但已实现,因此不需要显式构造完整的上下文敏感关注集。
return getExpectedTokens().contains(symbol);
function isExpectedToken(symbol: number): boolean
参数
- symbol
-
number
要检查的符号类型
返回
boolean
如果 symbol
可以遵循 ATN 中的当前状态,则 true
否则 false
。
继承自 Parser.isExpectedToken
match(number)
将当前输入符号与 ttype
匹配。 如果符号类型匹配,则调用 <xref:ANTLRErrorStrategy%23reportMatch> 和 <xref:%23consume> 来完成匹配过程。
如果符号类型不匹配,则对当前错误策略调用 <xref:ANTLRErrorStrategy%23recoverInline> 以尝试恢复。 如果 <xref:%23getBuildParseTree>true
,<xref:ANTLRErrorStrategy%23recoverInline> 返回的符号的标记索引为 -1,则通过调用 [Token] (xref:%23createErrorNode(ParserRuleContext%2C) 将符号添加到分析树中,然后 <xref:ParserRuleContext%23addErrorNode(ErrorNode)>。
function match(ttype: number): Token
参数
- ttype
-
number
要匹配的标记类型
返回
Token
匹配的符号 @ 如果当前输入符号与 ttype
不匹配,并且错误策略无法从不匹配的符号中恢复
继承自 Parser.match
matchWildcard()
将当前输入符号匹配为通配符。 如果符号类型匹配(即值大于 0),则调用 <xref:ANTLRErrorStrategy%23reportMatch> 和 <xref:%23consume> 来完成匹配过程。
如果符号类型不匹配,则对当前错误策略调用 <xref:ANTLRErrorStrategy%23recoverInline> 以尝试恢复。 如果 <xref:%23getBuildParseTree>true
,<xref:ANTLRErrorStrategy%23recoverInline> 返回的符号的标记索引为 -1,则通过调用 [Token](xref:Parser%23createErrorNode(ParserRuleContext%2C)将符号添加到分析树中,然后 <xref:ParserRuleContext%23addErrorNode(ErrorNode)>。
function matchWildcard(): Token
返回
Token
匹配的符号 @ 如果当前输入符号与通配符不匹配,并且错误策略无法从不匹配的符号中恢复
继承自 Parser.matchWildcard
notifyErrorListeners(string)
function notifyErrorListeners(msg: string)
参数
- msg
-
string
继承自 Parser.notifyErrorListeners
notifyErrorListeners(string, Token | null, RecognitionException | undefined)
function notifyErrorListeners(msg: string, offendingToken: Token | null, e: RecognitionException | undefined)
参数
- msg
-
string
- offendingToken
-
Token | null
- e
-
RecognitionException | undefined
继承自 Parser.notifyErrorListeners
precpred(RuleContext, number)
function precpred(localctx: RuleContext, precedence: number): boolean
参数
- localctx
-
RuleContext
- precedence
-
number
返回
boolean
继承自 Parser.precpred
pushNewRecursionContext(ParserRuleContext, number, number)
与 <xref:%23enterRule> 类似,但对于递归规则。 将当前上下文设置为传入 localctx 的子级。
function pushNewRecursionContext(localctx: ParserRuleContext, state: number, ruleIndex: number)
参数
- localctx
-
ParserRuleContext
- state
-
number
- ruleIndex
-
number
继承自 Parser.pushNewRecursionContext
removeErrorListener(ANTLRErrorListener<Token>)
function removeErrorListener(listener: ANTLRErrorListener<Token>)
参数
- listener
-
ANTLRErrorListener<Token>
继承自 Recognizer.removeErrorListener
removeErrorListeners()
function removeErrorListeners()
继承自 Recognizer.removeErrorListeners
removeParseListener(ParseTreeListener)
从分析侦听器列表中删除 listener
。
如果 listener
undefined
或尚未添加为分析侦听器,则此方法不执行任何作。
请参阅 #addParseListener
function removeParseListener(listener: ParseTreeListener)
参数
- listener
-
ParseTreeListener
要删除的侦听器
继承自 Parser.removeParseListener
removeParseListeners()
删除所有分析侦听器。
请参阅 #addParseListener
function removeParseListeners()
继承自 Parser.removeParseListeners
reset()
重置分析程序的状态
function reset()
继承自 Parser.reset
reset(boolean)
function reset(resetInput: boolean)
参数
- resetInput
-
boolean
继承自 Parser.reset
sempred(RuleContext | undefined, number, number)
function sempred(_localctx: RuleContext | undefined, ruleIndex: number, actionIndex: number): boolean
参数
- _localctx
-
RuleContext | undefined
- ruleIndex
-
number
- actionIndex
-
number
返回
boolean
继承自 Recognizer.sempred
setProfile(boolean)
function setProfile(profile: boolean): Promise<void>
参数
- profile
-
boolean
返回
Promise<void>
继承自 Parser.setProfile
unrollRecursionContexts(ParserRuleContext)
function unrollRecursionContexts(_parentctx: ParserRuleContext)
参数
- _parentctx
-
ParserRuleContext
继承自 Parser.unrollRecursionContexts