antlr4 - ANTLR - number surrounded by single quotes -
I want to recognize the ANTLR for '10' (including single quotes) but it only gives me an error: "" "" "" at 10 "
I have Test.g4
is for:
grammar test; Rule: Number; Number: Quote NUM quotes; NUM: [0-9] +; Excerpt: '\' '; WS: ['\ t \ r \ n] + - & gt; Skip;
Then the driver looks like a file:
public class teststaff {public static zero main (string [] args) {charstream input = new ANTLRInputStream ( "10"); TestLexer lexer = New TestLuxer; GeneralTokenStream Token = New CommonTokenStream (Lexer); Test Parser Parser = New Test Parser (token); parser.rules ();}}
I have tried to think about every difference and I am getting this: missing from '10'
If this is the case, then using version 4.1.
Your rule:
WS: ['\ t \ r \ n] + - & gt; Skip;
Match , And skips, input "'"
(space + quote).
Remove the quote from that class:
WS: [\ t \ R \ n] + - & gt; Skip;
and you should be OK.