2004-06-05

PackRats

What I've been doing lately is a parser.

I don't like the idea that you have a write grammar-generate code-compile loop each time you want to add something to a grammar, and you have to rewrite grammars to suit parsers. There seems something wrong with a system that doesn't allow new rules at runtime, and means that you end up with several thousand lines of code for what should be a simple part of a tool.

Therefore I've been playing with something like the Pack Rat technique, but using a 2-3 tree for forward parsing and a stack for backtracking over possible terminals (this is to allow only one subtree- that found by the tree- to need to be stored, but have the capability of going back to previously not explored subtrees whitout such a large table of possible states).

There are three design aims-

  1. to allow grammars that are simple mappings to abstract syntax

  2. to allow the grammar to be extensible at runtime (allowing new abstract values for metadata constructs)

  3. to allow the current parse state to be used for structure aware autocomplete


This is part of an on-going metadata driven toolset for Java programming.. more later.

TME

0 Comments:

Post a Comment

<< Home