[antlr-interest] Wrapping my head around ANTLR v3
Matt Holmes
tegan at gnometank.net
Tue Apr 10 17:50:04 PDT 2007
First off, let me say hello. This is my first message to the list. I
recently discovered ANTLR as I was looking for tools to help my
implement a scripting language in a C#/.NET project I am working on. I
started writing my lexer and parser with v2, when I realized that v3 was
available at seemed stable enough to use.
The first thing I noticed is that the lexer and parser in all of the v3
examples seemed to be combined in a single grammar file now. Is this a
required situation, or can I split them across multiple grammar files to
keep the grammar clean and easy to read? Is there any particular reason
to keep them combined? Perhaps I am too "attached to the old school",
the ole' yacc/lex days when you not only put them in separate files, you
used separate tools, hehe. Perhaps I am over analyzing this and keeping
them in a single grammar file is not that big an issue, I am just
curious if it's still possible.
Also, I noticed that in many grammars, tokens are no longer defined
(such as tokens { FOR="for"; WHILE="while"; } ), but instead single
parser rules are used to define those tokens (e.g. FOR: 'for'; ). Is
there a technical reason behind this? Is it simply a conscious choice by
the developer, or is something gained by using this method?
Apologies if this are extremely novice questions, I am just trying to
understand some of the things that seem "odd" to me as a past user of
older lexical tools.
Thanks,
Matt Holmes
More information about the antlr-interest
mailing list