Re: [Scriptonite-dev] grammar
Status: Planning
Brought to you by:
egagnon
|
From: Etienne M. G. <eg...@j-...> - 2000-02-25 16:30:59
|
Uwe Hoffmann wrote:
> when I started resolving conflicts in the typed-up grammar I might have gone
> the wrong path down. Maybe we should keep the other version of the grammar
> around (the one before I started to mess with it ;-).
I've replaced the grammar with this version in CVS. I moved the files one
directory higher too. (scriptonite/scriptonite/* -> scriptonite/*)
> On the lexer side most of it is copied from sablecc's java grammar so later
> on we should check to make sure we catch the token differences (there are a
> few between java and javascript)
Why don't you guys start looking at the lexer. It will buy me some time. I
have many other things to do. I'll send a message as soon as I get some time
to look at the grammar conflicts (and the extra lookahead directives in the
spec...)
If you run out of things to do, you might also start thinking and designing
the simplified AST grammar.
Ideally, this is a grammar where precedence is removed, as well as unnecessary
tokens. e.g.
exp =
{plus} [lexp]:exp [recp]:exp |
{mult} [lexp]:exp [recp]:exp |
{div} [lexp]:exp [recp]:exp |
... |
{id} identifier |
{this} |
{num} num;
statement =
{if} [cond]:exp [then]:statement? [else]:statement? |
{for} ... |
...
Obviously, this grammar will be ambiguous, and is definitely not the "parsing"
grammar, but it contains the semantic essence of the program, it is much
smaller and, it is a lot easier to work with.
At this point, don't worry about how to get from the parsing grammar to the
AST grammar.
This should keep you busy for a while. You should put this ast grammar into
scriptonite/src/scriptonite-ast.grammar. You can include a "Tokens" part, if
you want, but you should stip it from any unused token. (e.g. "if" ";" "for"
"+" ...)
Have fun!
Etienne
|