[antlr-interest] Exceptions on C#-Target

Sam Harwell sharwell at pixelminegames.com
Tue Oct 25 14:57:56 PDT 2011


Hello,

I just ran your test, and it didn't throw any externally visible exceptions. Internally I would expect a very large number of exceptions because your lexer has no rules that match any of your input except comments, whitespace, the word CREATE, and the semicolon at the end.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Anonym
Sent: Monday, August 29, 2011 6:02 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Exceptions on C#-Target

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?


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list