general architecture question

a7244270@yahoo.com (Alfonso Urdaneta)
13 Oct 2003 00:18:04 -0400

          From comp.compilers

Related articles
general architecture question a7244270@yahoo.com (2003-10-13)
| List of all articles for this month |

From: a7244270@yahoo.com (Alfonso Urdaneta)
Newsgroups: comp.compilers
Date: 13 Oct 2003 00:18:04 -0400
Organization: http://groups.google.com
Keywords: design, question
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,
etc.


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
statements ?


Say we have 3 statement types, A, B, C, which use say, integers.


Option 1.


  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


Option 2.


There is a handler for A B and C, all of which implement the function
"handleInteger".


    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.


Regards,


Alfonso.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.