3
解析以特定字符開頭的單詞嗎?如何解析以ANTLR3開頭的單詞java target
我一直在嘗試以下,但我不能得到任何有希望的結果:
//This one is working it accepts AD CD and such
example1
:
.'D'
;
//This one is not, it expects character D, then any ws character then any character
example2
:
'D'.
;
//These two are not working either
example3
:
'D'.*
;
//Doesn't accept input due to error: "line 1:3 missing 'D' at '<EOF>'"
example4
:
.*'D'
;
//just in case my WS rule:
/** WhiteSpace Characters (HIDDEN)*/
WS : (' '
| '\t'
)+ {$channel=HIDDEN;}
;
我提前
謝謝,這使我更好地理解了概念。 –