[antlr-interest] newbie stuck here....
Mike Hingley
computa_mike at hotmail.com
Fri Apr 16 06:35:40 PDT 2004
Hi -
I work for these guys : www.boxtelematics.com, and they make a
hardware unit that offers a scripting abilty.
So... anyway I figured that it would be nice to provide a nice IDE
to develop the scripts in - one that looks for syntax errors etc,
and one that I could look for logical errors in script design in.
Anyway - my first step has been to define a lexicon, describing all
of the tokens (right terminology?) thant can be inputted in the
stream - my idea is start small (say less than 10 commands) and add
the rest in once the concept has been proved.
Anyway - here's my lexer grammar ...
protected NEWLINE
: '\r' '\n' // DOS
| '\n' // UNIX
;
BOXDALLASKEY :
('0'..'9')+;
BOXaddkey :
".addkey"
{System.Console.WriteLine("<<Lex :: .addkey>>");};
BOXalarm :
".alarm"
{System.Console.WriteLine("<<Lex :: .alarm>>");};
BOXalive :
".alive"
{System.Console.WriteLine("<<Lex :: .alive>>");};
at the moment i am just experimenting, so I have put the print lines
there to prove it's all working.
to provide the main structure for the commands, the following parser
grammar has been constructed :
box_addkey : BOXaddkey
BOXDALLASKEY NEWLINE ;
box_ai : BOXai
;
ok - hopefully everyone's clear with that. Anyway - what I wanted
to do was to compile this little lot to give a lexer / parser that I
could use in C#, to provide a gui to the user - and that 'seems' to
have worked ok - however I am unsure if I am doing this right. Does
anyone have any advice regarding my structure here? Can i get away
with merely a lexer( I'm sort of thinking that I can - I'm only
interested in returning valid tokens not interpreting them - am I
missing something?)?
Is there any documentation for the c# lexer and parsers?
I'm using the eclipse IDE, and the ANTLR plugin (by the way - that
doesn't seem to like compiling if language = CSHARP? any ideas?)
Cheers guys -
Mike Hingley
ANTLR newbie, and quite liking it so far.......
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list