|general architecture question email@example.com (2003-10-13)|
|From:||firstname.lastname@example.org (Alfonso Urdaneta)|
|Date:||13 Oct 2003 00:18:04 -0400|
|Posted-Date:||13 Oct 2003 00:18:04 EDT|
This is more of a general architecture question, rather than one
specific to compilers. Basically I'm trying to find out what is
preferred practice for the code that handles the output from the
parser, and its general code structure.
Any language has some fundamental building blocks that can occur in
all sorts of statement, such as integers, quoted character strings,
Is it common practice to have a central repository into which all
these values go to, and the specific handlers then cherrypick from it
the data they need, or is preferable to have a base class which has
interfaces for all the primitives, and subclass this for specific
Say we have 3 statement types, A, B, C, which use say, integers.
parser finds an int, stick it in common int pool
parser realizes last statement is of type A, B or C, and calls the
the specific handler for that statememnt, which then pulls the
integers from the common pool to do their thing
There is a handler for A B and C, all of which implement the function
parser realizes its parsing a statement of type B, sets the overall
handler to be of type "B". when an integer is cound,
B->handleInteger(val) is called. likewise for all the others.
Which of those two ways is this type of thing done - or is there
another alternate ? Option 2 seems cleaner, but it also seems like it
will require a lot more overhead.
I hope this question makes sense to you guys, I can't think of another
way to phrase it.
Return to the
Search the comp.compilers archives again.