[antlr-interest] Fwd: ANTLR first time user getting error
Dibyendu Majumdar
mobile at majumdar.org.uk
Sat Sep 11 17:20:58 PDT 2010
The grammar works if I change the packageDeclaration production as follows:
packageDeclaration
: PACKAGE WS qualifiedName SEMI
;
So it seems something is amiss with the handling of whitespace. Any tips?
Thanks and Regards
Dibyendu
---------- Forwarded message ----------
From: Dibyendu Majumdar <mobile at majumdar.org.uk>
Date: 12 September 2010 00:51
Subject: ANTLR first time user getting error
To: antlr-interest at antlr.org
Hi,
I am trying to use ANTLR for the first time, and am getting an error when
trying to run the grammar shown below; I would be grateful for any help in
identifying what the issue is.
The test input I am using is:
package test;
I am using the Eclipse ANTLR IDE plugin and when I try to interpret above, I
get:
MimatchedTokenException: Line 1:7 mismatched input '' expecting '\u0006'
Below is the grammar I am using:
----------------------------------
grammar Problematic;
options {
language = Java;
}
compilationUnit
: packageDeclaration
;
packageDeclaration
: PACKAGE qualifiedName SEMI
;
qualifiedName
: IDENTIFIER (DOT IDENTIFIER)*
;
WS
: (
' '
| '\r'
| '\t'
| '\u000C'
| '\n'
)
{
skip();
}
;
PACKAGE
: 'package'
;
SEMI
: ';'
;
DOT
: '.'
;
IDENTIFIER
: ('a'..'z'|'A'..'Z'|'_'|'$') ('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'$')*
;
More information about the antlr-interest
mailing list