First of all, thank you Alec for this great utility. Actually much better than bison++ / flex++. I have a request.
I would like to make my parser modular, being able to #include code from other files into the "main" .cg file. For example, suppose I want to parse several types of "animals"; I would then write
...now, in order to make the thing modular, the associated code for each animal should reside in a separate grammar file - say, cat.cg, dog.cg and squirrel.cg. At cppcc'ing time, we should have an #include directive, much like in C, so to assemble the files back into one.
this is absolutely useful if one plans to let other people extend one's grammar. The other party writes cat.cg, and I just #include it in animals.cg.
Why not simply feed your main file into the C preprocessor ? I don't see wny reason for this solution not to work (cppcc's lexical structure is very C-like, so there should be no hiccups).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First of all, thank you Alec for this great utility. Actually much better than bison++ / flex++. I have a request.
I would like to make my parser modular, being able to #include code from other files into the "main" .cg file. For example, suppose I want to parse several types of "animals"; I would then write
---------------- animals.cg
(void) AnimalToken () {
cat() | dog() | squirrel()
}
----------------
...now, in order to make the thing modular, the associated code for each animal should reside in a separate grammar file - say, cat.cg, dog.cg and squirrel.cg. At cppcc'ing time, we should have an #include directive, much like in C, so to assemble the files back into one.
this is absolutely useful if one plans to let other people extend one's grammar. The other party writes cat.cg, and I just #include it in animals.cg.
do you plan to have anything like this?
thanks,
Claudio Castellini
claudio.castellini _AT_ dist.unige.it
Why not simply feed your main file into the C preprocessor ? I don't see wny reason for this solution not to work (cppcc's lexical structure is very C-like, so there should be no hiccups).
a very interesting and simple idea. I will be trying it, and will let you know.
ciao
c.