[antlr-interest] gUnit test cases and Windows paths
Leon Su
leon.antlr at mac.com
Sat Jan 17 23:24:11 PST 2009
Hi David,
Are there only 2 lexical rules in your grammar?
If yes, the following gUnit test case must fail because ANTLR can't
tokenize your input string properly.
dbCommand:
".output C:\TEMP\test.csv" OK
Here is a trick to display the error messages from ANTLR as below:
".output C:\TEMP\test.csv" -> "show me the error message!" // the
rhs expected result can be any arbitrary string...
then you'll see some error messages like no viable alternative at
character '...'
Leon
--------------- your grammar -----------------
grammar sample;
statement
: dbCommand NEWLINE
;
dbCommand
: CMD_OUTPUT { $CMD_OUTPUT.pos == 0 }? ~NEWLINE+
;
CMD_OUTPUT
: ( '.output' | '.outpu' | '.outp' | '.out' | '.ou' | '.o' )
;
NEWLINE
: '\r'? '\n'
;
On Jan 17, 2009, at 6:27 PM, David Peckham wrote:
> On Jan 17, 2009, at 6:11 PM, Gavin Lambert wrote:
>
>> At 14:01 18/01/2009, David Peckham wrote:
>> >My gUnit test cases fail when they contain Windows paths. UNIX
>> >paths work fine.
>> [...]
>> >dbCommand:
>> >".output C:\TEMP\test.csv" OK
>> ><<.output C:\TEMP\test.csv>> OK
>>
>> Did you try doubling the backslashes (ie. using \\ instead)?
>> While I don't know anything about gUnit syntax, it wouldn't
>> surprise me if it was being used as an escape character (so your
>> single backslashes are either getting ignored entirely or being
>> interpreted as tab characters, since they're followed by a "t").
>>
>
> Yes, double backslashes fail too.
>
More information about the antlr-interest
mailing list