Making part of representation WAS RE: [antlr-interest] Preserving ALL comments!

Jeff Barnes Jeff.Barnes at codesic.com
Tue Feb 21 12:32:06 PST 2006


> Very well put. You can't do language translation + comments without making
> comments part of your representation.

Uh, oh...
 
I think I'm painting myself into a corner.
 
This thread is beginning to sound eerily familiar :)
 
I'm parsing a lisp-style file format that looks something like this
 
...
 
(object Class_Category "Logical View"
 quid        "43BB1622020D"
 exportControl  "Public"
 global      TRUE
 subsystem   "Component View"
 quidu       "43BB16A90015"
 logical_models  (list unit_reference_list
     (object Class "NewClass3"
  quid        "43BB1E27029B"
  stereotype  "Actor"))
 
...
 
My lexer symbols are the STRING, INT, BOOLEAN primitive stuff and such. For example,
BOOLEAN:
    "TRUE" | "FALSE" | "true" | "false"
;
    
COMMA:
    ","
;
    
protected
DIGIT:
    '0'..'9'
;
 
My parser symbols are the meta symbols (object, list, attribute, etc.). For example,
 
object
{
}
:
    LPAREN! OBJECT^
    typeid:ID 
    (
        param
    )*
    (
        attribute
    )* 
    RPAREN!
;
 
Now I'm at the tree phase and finding out there may be some serious brute force involved.
 
It looks like I'm faced with the alternative of instantiating the meta meta model (creating the instances of object, list, etc) with a StringTemplate or write custom tree navigation code to instantiate the meta model (Class_Category, Class).
 
Which one is the least amount of work?
 
Regards,
Jeff
 


More information about the antlr-interest mailing list