Problems with validating a really small language
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   John_Youren
Posted On:   Sunday, December 3, 2006 02:29 PM

Hi, I want to use ANTLR to verify a small language for a program called FPS Creator. The syntax is... This is a typical event action line. You can have many actions/conditions: :condition[,condition][,condition]:action[,action][,action] This is a comment: ; myscript comment This is a condition: Conditionword=conditionvalue1 [conditionvalue2] This is an action: Actionword=actionvalue Here is my ANTLR, it reports unexpected token NULL, how can I get round this. options { language="CSharp"; } class FPIParser extends Parser; options { k=2; } //:condition[,condition][,condition]:action[,action][,action] program    More>>

Hi,

I want to use ANTLR to verify a small language for a program called FPS Creator. The syntax is...

This is a typical event action line. You can have many actions/conditions:
:condition[,condition][,condition]:action[,action][,action]
This is a comment:
; myscript comment
This is a condition:
Conditionword=conditionvalue1 [conditionvalue2]
This is an action:
Actionword=actionvalue

Here is my ANTLR, it reports unexpected token NULL, how can I get round this.

options { language="CSharp"; }

class FPIParser extends Parser;
options { k=2; }

//:condition[,condition][,condition]:action[,action][,action]
program : (eventLine)*;

eventLine : (COLON condition COLON action);

condition : WORD EQUALS (WORD | NUMBER) (COMMA WORD EQUALS (WORD | NUMBER))*;
action : WORD (EQUALS (WORD | NUMBER))* (COMMA WORD EQUALS (WORD | NUMBER))*;

class FPILexer extends Lexer;
options { k=2; }

WS : (' ' | ' ' | '
')
{$setType(Token.SKIP);}
;

NEWLINE : ('
') ;

EQUALS : '=' ;

NUMBER : ('0'..'9')+ ;

WORD : ('a'..'z'|'A'..'Z')+ ;

COLON : ':' ;

COMMA : ',' ;

MINUS : '-' ;

FILESLASH : '\\' ;
FILEDOT : '.' ;

COMMENT : ';' (~('
'))*
{ $setType(Token.SKIP); }
;

DESC : "desc" (~('
'))*
{ $setType(Token.SKIP); }
;

Thanks for your time,
John

   <<Less
About | Sitemap | Contact