ANTLR 4 extraneous input matching non lexer item
问题 I have a grammar like this : grammar MyGrammar; field : f1 (STROKE f2 f3)? ; f1 : FIELDTEXT+ ; f2 : 'A' ; f3 : NUMBER4 ; FIELDTEXT : ~['/'] ; NUMBER4 : [0-9][0-9][0-9][0-9]; STROKE : '/' ; This works well enough, and fields f1 f2 f3 are all populated correctly. Except when there is an A to the left of the / , (regardless of the presence of the optional part) this additionally causes an error: extraneous input 'A' expecting {<EOF>, FIELDTEXT, '/'} Some sample Data: PHOEN -> OK. KLM405/A4046 ->