[antlr-interest] Exceptions on C#-Target

Anonym error0x2b1 at googlemail.com
Mon Aug 29 04:01:59 PDT 2011


i´m working with antlrworks 1.4.2
i have the following, extremly simple grammar (combined lexer and parser):
*
public sqlfile :
commands*
EOF
;

commands:
STARTWORD (options { greedy=false; } : .*) SEM
;

STARTWORD
: ('SELECT'|'INSERT'|'UPDATE'|'DELETE')
;

SEM : ';' ;

COMMENT : '/*' ( options { greedy=false; } : .*) '*/'
{
$channel = 2;
}
;

SHARP
: '#' ( options { greedy=false; } : .*) NL
{
$channel = 2;
}
;
SINGLELINECOMMENT
: '--' ( options { greedy=false; } : .*) NL
{
$channel = 2;
}
;
WS : (' '|'\t')+ { $channel = 5; } ;
NL : ('\r' '\n'? | '\n') { $channel = 5; } ;
*

i´ve debugged it in antlrworks and works fine (as expected). i used this
test-string:
*--
-- SQL to create the guestbook table
--


CREATE TABLE `guestbook` (
`id` int(11) NOT NULL auto_increment,
`TimeStamp` int(11) default '0',
`Email` varchar(60) default NULL,
`Name` varchar(100) NOT NULL default '',
`Website` varchar(60) default NULL,
`Title` varchar(255) default NULL,
`Message` text,
`Verified` smallint(1) NOT NULL default '0',
`Code` varchar(40) NOT NULL default '',
UNIQUE KEY `id` (`id`)
) TYPE=MyISAM AUTO_INCREMENT=6 ;
*

then i build against csharp3-target and used the parser in my
c#-application.
while executing the parser.sqlfile()-Method 317 Exceptions
(MissmatchToken and NoViableAlt) are thrown!
now i wonder why, because my grammar is REALLY simple and should match,
like it in the java-target did (no error in antlrworks-console).
In the C#-Output the exceptions are thrown at the line
STARTWORD1=(IToken)Match(input,STARTWORD,Follow._STARTWORD_in_commands135);
in commands()-Rule

where is my mistake?



More information about the antlr-interest mailing list