[antlr-interest] Parsing dynamically defined templates ?

mzukowski at yci.com mzukowski at yci.com
Thu May 1 08:44:40 PDT 2003


This is very similar to structs in C.  Best bet is to parse them generically
and then use a tree parser to check the semantics that the use of a template
matches its definition.  The GCC grammar has rules for structs.  It does not
check semantics though.  http://www.codetransform.com/gcc.html

You're not going to be able to generate a specific parser for a particular
template.  ANTLR isn't that dynamic.

Monty

-----Original Message-----
From: blade_x123 [mailto:blade_x123 at yahoo.com]
Sent: Wednesday, April 30, 2003 6:44 PM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Parsing dynamically defined templates ?


Hi,
 This may be a slightly long mail so please bear with me. In the file
format that I am trying to parse with antlr I have something called
Data Templates. These are defined at the beginning of each file, or
can also be a pre defined set. Here is an example

Template myTemplate {
DWORD myVar;
}
an instance of this template will look like this
myTemplate mT {
1.245;
}
also there can be array's which are comma seperated objects, as in
Template myArrayTemp {
array DWORD myArr[3];
}
which would be like
myArrayTemp {
1.0, 2.0, 3.0;
}
It gets more complicated :-(
a template can have an array of templates, for example
Template myTempArrTemp {
DWORD myVar;
array myArrayTemp bleh[3];
}
which would look like this
myTempArrTemp {
2.0;
1.0,2.0,3.0;,2.0,3.0,4.0;,5.0,6.0,7.0;;
}
the 2 semicolons at the end are needed to signify the end of a
template.

There are roughly 30-40 templates that are in common use. Also these
templates can be defined on the fly. How would I parse these ? A
general idea or tips would be helpful. I am assuming I have to do this
in my C++ code once I read in the template contents. Any ideas to
simplify my life ?

Thanks in advance,
Manju


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list