CommonRegexParser class
- Extends
-
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(String%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 |
傳回 List<String> 剖析器實例中規則名稱,導致呼叫目前規則。 如果您想要更多詳細資料,例如叫用規則之 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
繼承自 辨識器.EOF
errorHandler
errorHandler: ANTLRErrorStrategy
屬性值
ANTLRErrorStrategy
繼承自 Parser.errorHandler
inputStream
設定令牌數據流並重設剖析器。
inputStream: TokenStream
屬性值
TokenStream
繼承自 Parser.inputStream
interpreter
設定辨識器用於預測的 ATN 解釋器。
interpreter: ParserATNSimulator
屬性值
ParserATNSimulator
繼承自 Recognizer.解釋器
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(String%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)
傳回 List<String> 剖析器實例中規則名稱,導致呼叫目前規則。 如果您想要更多詳細資料,例如叫用規則之 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
true 如果 symbol 可以遵循 ATN 中的目前狀態,則為 ,否則 false。
繼承自 Parser.isExpectedToken
match(number)
比對目前的輸入符號與 ttype。 如果符號類型相符,則會呼叫 <xref:ANTLRErrorStrategy%23reportMatch> 和 <xref:%23consume> 來完成比對程式。
如果符號類型不相符,則會在目前的錯誤策略上呼叫 <xref:ANTLRErrorStrategy%23recoverInline>,以嘗試復原。 如果 <xref:%23getBuildParseTree>true 且 <xref:ANTLRErrorStrategy%23recoverInline> 傳回之符號的標記索引為 -1,則會呼叫 [Token](xref:%23createErrorNode%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。
如果 listenerundefined 或尚未新增為剖析接聽程式,則此方法不會執行任何動作。
請參閱 #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