CommonRegexParser class

Extends

Parser

建構函式

CommonRegexParser(TokenStream)

屬性

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

繼承的屬性

atn

serializedATN取得辨識器用於預測的 。

buildParseTree

<xref:ParserRuleContext>在剖析期間追蹤物件,並使用 <xref:ParserRuleContext%23children> 清單加以連結,使其形成剖析樹狀結構。 <xref:ParserRuleContext>從開始規則傳回的 ,代表剖析樹狀結構的根目錄。 請注意,如果我們不是建置剖析樹狀結構,規則內容只會指向上。 當規則結束時,它會傳回內容,但如果沒有人保有參考,就會收集垃圾。 它會向上指向,但沒有人指向它。

當我們建置剖析樹狀結構時,我們會新增所有這些內容以 <xref:ParserRuleContext%23children> 列出。 內容接著不是垃圾收集的候選項目。

context
currentToken

比對必須傳回目前的輸入符號,這會放入相關聯標記 ref 的標籤中;例如 x=ID。

EOF
errorHandler
inputStream

設定權杖資料流程並重設剖析器。

interpreter

設定辨識器用於預測的 ATN 解譯器。

isMatchedEOF
isTrace

在剖析期間,有時候對規則進入和結束事件以及權杖相符專案進行接聽很有用。 這是快速且已變更的偵錯。

numberOfSyntaxErrors

取得剖析期間報告的語法錯誤數目。 每次呼叫 時 <xref:%23notifyErrorListeners> ,這個值都會遞增。

請參閱#notifyErrorListeners

parseInfo
precedence

取得最上層優先順序規則的優先順序層級。

ruleContext
sourceName
state

指出辨識器已變更與傳入 ATN 狀態一致的內部狀態。 如此一來,我們一律會知道剖析器在 ATN 中的所在位置。 規則內容物件形成堆疊,可讓我們查看叫用規則的堆疊。 結合這一點,我們已完成 ATN 組態資訊。

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)
addErrorListener(ANTLRErrorListener<Token>)
addParseListener(ParseTreeListener)

listener註冊以在剖析程式期間接收事件。 為了支援輸出保留文法轉換, (包括但不限於從左遞迴移除、自動化左因素處理和優化程式碼產生) ,剖析期間對接聽程式方法的呼叫可能會與剖析完成之後使用的呼叫 <xref:ParseTreeWalker%23DEFAULT> 有很大的差異。 特別是,在剖析期間,規則進入和結束事件可能會以不同于剖析器之後的順序發生。 此外,可能會省略對特定規則專案方法的呼叫。

在下列特定例外狀況下,對接聽程式事件的呼叫是 具決定性的,也就是對於相同的輸入,接聽程式方法的呼叫會相同。

  • 變更用來產生程式碼的文法可能會變更接聽程式呼叫的行為。
  • 產生剖析器時,傳遞至 ANTLR 4 的命令列選項變更可能會變更接聽程式呼叫的行為。
  • 變更用來產生剖析器的 ANTLR 工具版本,可能會變更接聽程式呼叫的行為。
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");
compileParseTreePattern(string, number, Lexer)

與 [int) ] (xref:%23compileParseTreePattern (String%2C) 相同,但請指定 , CommonRegexLexer 而不是嘗試從這個剖析器中將其除法。

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> 取用的符號新增至剖析樹狀結構。

createErrorNode(ParserRuleContext, Token)

如何建立與父代相關聯的權杖的錯誤節點。 一般而言,要建立的錯誤節點不是父代的函式。

createTerminalNode(ParserRuleContext, Token)

如何建立與父代相關聯的權杖分葉節點。 一般而言,要建立的終端節點不是父系的函式。

dumpDFA()

用於偵錯和其他用途。

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

在規則專案時,一律由產生的剖析器呼叫。 [存取] 欄位 <xref:%23_ctx> 會取得目前的內容。

exitRule()
getATNWithBypassAlts()

使用略過替代方案的 ATN 很昂貴,因此我們會延遲建立。 @ 如果目前的剖析器未實 serializedATN 作 屬性。

getDFAStrings()

用於偵錯和其他用途。

getErrorHeader(RecognitionException)

錯誤標頭是什麼,通常是行/字元位置資訊?

getErrorListenerDispatch()
getErrorListeners()
getExpectedTokens()

計算一組輸入符號,這些符號可以分別遵循目前的剖析器狀態和內容,如 和 <xref:%23getContext> 所 <xref:%23getState> 指定。

請參閱 ATN#getExpectedTokens (int、RuleCoNtext)

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

取得規則的索引 (,例如 RULE_ruleName ,如果找不到欄位) 或 -1。

getRuleIndexMap()

從規則名稱到規則索引取得對應。 用於 XPath 和樹狀架構模式編譯。

getRuleInvocationStack(RuleContext)

<傳回剖析器實例中規則名稱的清單字串 > ,導致呼叫目前規則。 如果您想要更多詳細資料,例如叫用規則在 ATN 中位置的檔案/行資訊,則可以覆寫。 這非常適用于錯誤訊息。

getTokenType(string)
getTokenTypeMap()

從權杖名稱到權杖類型取得對應。 用於 XPath 和樹狀架構模式編譯。

inContext(string)
isExpectedToken(number)

檢查 ATN 中的目前狀態是否 symbol 可遵循。 這個方法的行為相當於下列專案,但實作時,不需要明確建構完整的內容相關追蹤集。

return getExpectedTokens().contains(symbol);
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)> 將符號新增至剖析樹狀結構。

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)> 將符號新增至剖析樹狀結構。

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

就像 <xref:%23enterRule> ,但用於遞迴規則。 將目前內容設為傳入 localctx 的子系。

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

從剖析接聽程式清單中移除 listener 。 如果 為 listenerundefined 或 尚未新增為剖析接聽程式,則這個方法不會執行任何動作。

請參閱#addParseListener

removeParseListeners()

移除所有剖析接聽程式。

請參閱#addParseListener

reset()

重設剖析器的狀態

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

建構函式詳細資料

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

serializedATN取得辨識器用於預測的 。

atn: ATN

屬性值

ATN

繼承自 Recognizer.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()

function alpha_nums(): Alpha_numsContext

傳回

alternation()

function alternation(): AlternationContext

傳回

atom()

function atom(): AtomContext

傳回

capture()

function capture(): CaptureContext

傳回

cc_atom()

function cc_atom(): Cc_atomContext

傳回

cc_literal()

function cc_literal(): Cc_literalContext

傳回

character_class()

function character_class(): Character_classContext

傳回

digit()

function digit(): DigitContext

傳回

digits()

function digits(): DigitsContext

傳回

element()

function element(): ElementContext

傳回

expr()

function expr(): ExprContext

傳回

letter()

function letter(): LetterContext

傳回

literal()

function literal(): LiteralContext

傳回

name()

function name(): NameContext

傳回

non_capture()

function non_capture(): Non_captureContext

傳回

non_close_paren()

function non_close_paren(): Non_close_parenContext

傳回

non_close_parens()

function non_close_parens(): Non_close_parensContext

傳回

number()

function number(): NumberContext

傳回

octal_char()

function octal_char(): Octal_charContext

傳回

octal_digit()

function octal_digit(): Octal_digitContext

傳回

option()

function option(): OptionContext

傳回

option_flag()

function option_flag(): Option_flagContext

傳回

parse()

function parse(): ParseContext

傳回

quantifier()

function quantifier(): QuantifierContext

傳回

quantifier_type()

function quantifier_type(): Quantifier_typeContext

傳回

shared_atom()

function shared_atom(): Shared_atomContext

傳回

shared_literal()

function shared_literal(): Shared_literalContext

傳回

繼承的方法的詳細資料

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)

在規則專案時,一律由產生的剖析器呼叫。 [存取] 欄位 <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)

檢查 ATN 中的目前狀態是否 symbol 可遵循。 這個方法的行為相當於下列專案,但實作時,不需要明確建構完整的內容相關追蹤集。

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 。 如果 為 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