LGTemplateParser class
- Extends
-
Parser
建構函式
LGTemplate |
屬性
繼承的屬性
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) 相同,但請指定 , LGFileLexer 而不是嘗試從這個剖析器中將其除法。 |
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 |
在規則專案時,一律由產生的剖析器呼叫。 [存取] 欄位 <xref:%23_ctx> 會取得目前的內容。 |
exit |
|
get |
使用略過替代方案的 ATN 很昂貴,因此我們會延遲建立。
@ 如果目前的剖析器未實 |
get |
用於偵錯和其他用途。 |
get |
錯誤標頭是什麼,通常是行/字元位置資訊? |
get |
|
get |
|
get |
計算一組輸入符號,這些符號可以分別遵循目前的剖析器狀態和內容,如 和 <xref:%23getContext> 所 <xref:%23getState> 指定。 請參閱 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 |
建構函式詳細資料
LGTemplateParser(TokenStream)
new LGTemplateParser(input: TokenStream)
參數
- input
-
TokenStream
屬性詳細資料
CASE
public static CASE: 14 = 14
屬性值
14
COMMENTS
public static COMMENTS: 3 = 3
屬性值
3
DASH
public static DASH: 4 = 4
屬性值
4
DEFAULT
public static DEFAULT: 15 = 15
屬性值
15
ELSE
public static ELSE: 12 = 12
屬性值
12
ELSEIF
public static ELSEIF: 11 = 11
屬性值
11
ESCAPE_CHARACTER
public static ESCAPE_CHARACTER: 16 = 16
屬性值
16
ESCAPE_CHARACTER_IN_STRUCTURE_BODY
public static ESCAPE_CHARACTER_IN_STRUCTURE_BODY: 31 = 31
屬性值
31
EXPRESSION
public static EXPRESSION: 17 = 17
屬性值
17
EXPRESSION_IN_STRUCTURE_BODY
public static EXPRESSION_IN_STRUCTURE_BODY: 32 = 32
屬性值
32
grammarFileName
string grammarFileName
屬性值
string
IF
public static IF: 10 = 10
屬性值
10
INVALID_TOKEN
public static INVALID_TOKEN: 6 = 6
屬性值
6
LEFT_SQUARE_BRACKET
public static LEFT_SQUARE_BRACKET: 5 = 5
屬性值
5
MULTILINE_PREFIX
public static MULTILINE_PREFIX: 8 = 8
屬性值
8
MULTILINE_SUFFIX
public static MULTILINE_SUFFIX: 19 = 19
屬性值
19
NEWLINE
public static NEWLINE: 2 = 2
屬性值
2
NEWLINE_IN_BODY
public static NEWLINE_IN_BODY: 9 = 9
屬性值
9
NEWLINE_IN_STRUCTURE_NAME
public static NEWLINE_IN_STRUCTURE_NAME: 21 = 21
屬性值
21
ruleNames
public static ruleNames: string[] = [
"template", "body", "structuredTemplateBody", "structuredBodyNameLine",
"errorStructuredName", "structuredBodyContentLine", "errorStructureLine",
"keyValueStructureLine", "keyValueStructureValue", "structuredBodyEndLine",
"normalTemplateBody", "templateString", "normalTemplateString", "errorTemplateString",
"ifElseTemplateBody", "ifConditionRule", "ifCondition", "switchCaseTemplateBody",
"switchCaseRule", "switchCaseStat", "expression", "expressionInStructure",
]
屬性值
string[]
ruleNames
string[] ruleNames
屬性值
string[]
RULE_body
public static RULE_body: 1 = 1
屬性值
1
RULE_errorStructuredName
public static RULE_errorStructuredName: 4 = 4
屬性值
4
RULE_errorStructureLine
public static RULE_errorStructureLine: 6 = 6
屬性值
6
RULE_errorTemplateString
public static RULE_errorTemplateString: 13 = 13
屬性值
13
RULE_expression
public static RULE_expression: 20 = 20
屬性值
20
RULE_expressionInStructure
public static RULE_expressionInStructure: 21 = 21
屬性值
21
RULE_ifCondition
public static RULE_ifCondition: 16 = 16
屬性值
16
RULE_ifConditionRule
public static RULE_ifConditionRule: 15 = 15
屬性值
15
RULE_ifElseTemplateBody
public static RULE_ifElseTemplateBody: 14 = 14
屬性值
14
RULE_keyValueStructureLine
public static RULE_keyValueStructureLine: 7 = 7
屬性值
7
RULE_keyValueStructureValue
public static RULE_keyValueStructureValue: 8 = 8
屬性值
8
RULE_normalTemplateBody
public static RULE_normalTemplateBody: 10 = 10
屬性值
10
RULE_normalTemplateString
public static RULE_normalTemplateString: 12 = 12
屬性值
12
RULE_structuredBodyContentLine
public static RULE_structuredBodyContentLine: 5 = 5
屬性值
5
RULE_structuredBodyEndLine
public static RULE_structuredBodyEndLine: 9 = 9
屬性值
9
RULE_structuredBodyNameLine
public static RULE_structuredBodyNameLine: 3 = 3
屬性值
3
RULE_structuredTemplateBody
public static RULE_structuredTemplateBody: 2 = 2
屬性值
2
RULE_switchCaseRule
public static RULE_switchCaseRule: 18 = 18
屬性值
18
RULE_switchCaseStat
public static RULE_switchCaseStat: 19 = 19
屬性值
19
RULE_switchCaseTemplateBody
public static RULE_switchCaseTemplateBody: 17 = 17
屬性值
17
RULE_template
public static RULE_template: 0 = 0
屬性值
0
RULE_templateString
public static RULE_templateString: 11 = 11
屬性值
11
serializedATN
string serializedATN
屬性值
string
STRUCTURED_BODY_END
public static STRUCTURED_BODY_END: 27 = 27
屬性值
27
STRUCTURED_COMMENTS
public static STRUCTURED_COMMENTS: 24 = 24
屬性值
24
STRUCTURED_NEWLINE
public static STRUCTURED_NEWLINE: 26 = 26
屬性值
26
STRUCTURE_EQUALS
public static STRUCTURE_EQUALS: 29 = 29
屬性值
29
STRUCTURE_IDENTIFIER
public static STRUCTURE_IDENTIFIER: 28 = 28
屬性值
28
STRUCTURE_NAME
public static STRUCTURE_NAME: 22 = 22
屬性值
22
STRUCTURE_OR_MARK
public static STRUCTURE_OR_MARK: 30 = 30
屬性值
30
SWITCH
public static SWITCH: 13 = 13
屬性值
13
TEXT
public static TEXT: 18 = 18
屬性值
18
TEXT_IN_STRUCTURE_BODY
public static TEXT_IN_STRUCTURE_BODY: 33 = 33
屬性值
33
TEXT_IN_STRUCTURE_NAME
public static TEXT_IN_STRUCTURE_NAME: 23 = 23
屬性值
23
VOCABULARY
public static VOCABULARY: Vocabulary = new VocabularyImpl(LGTemplateParser._LITERAL_NAMES, LGTemplateParser._SYMBOLIC_NAMES, [])
屬性值
Vocabulary
vocabulary
Vocabulary vocabulary
屬性值
Vocabulary
WS
public static WS: 1 = 1
屬性值
1
WS_IN_BODY
public static WS_IN_BODY: 7 = 7
屬性值
7
WS_IN_STRUCTURE_BODY
public static WS_IN_STRUCTURE_BODY: 25 = 25
屬性值
25
WS_IN_STRUCTURE_NAME
public static WS_IN_STRUCTURE_NAME: 20 = 20
屬性值
20
繼承的屬性詳細資料
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
方法詳細資料
body()
errorStructuredName()
errorStructureLine()
errorTemplateString()
expression()
expressionInStructure()
ifCondition()
ifConditionRule()
ifElseTemplateBody()
keyValueStructureLine()
keyValueStructureValue()
normalTemplateBody()
normalTemplateString()
structuredBodyContentLine()
function structuredBodyContentLine(): StructuredBodyContentLineContext
傳回
structuredBodyEndLine()
structuredBodyNameLine()
structuredTemplateBody()
switchCaseRule()
switchCaseStat()
switchCaseTemplateBody()
template()
templateString()
繼承的方法的詳細資料
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) 相同,但請指定 , LGFileLexer 而不是嘗試從這個剖析器中將其除法。
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)
在規則專案時,一律由產生的剖析器呼叫。 [存取] 欄位 <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:%23getContext> 所 <xref:%23getState> 指定。
請參閱 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
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 (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