>>> "Frans" == Frans Englich <[EMAIL PROTECTED]> writes:

 > My wondering is how I practically should modularize the code in order to 
 > efficiently support these different languages.

In the future, I would like to have something like %import in Bison,
but currently, you'll have to put everything into a single file (or
run your own process beforehand).

 > What are people's experiences with these kind of problems? What are the 
 > approaches for solving them?

I don't know how similar/different are your different languages, but
if they share some large parts, say there are common sublanguages
covered by equal nonterminals, then the following technique might
useful.

I have two similar languages (in fact it's almost a single grammar
with two entry points).  First, in the parser I have:

%start program
%%
program:
  /* Parsing a source program.  */
  "seed-source" exp                     { tp.exp_ = $2; }
| /* Parsing an imported file.  */
  "seed-import" "let" decs "end"        { tp.decs_ = $3; }
;

In fact I'm looking either for `exp' or `"let" decs "end"', but I have
fake tokens seed-*.

Then in the (Flex) scanner, I have:

...
%%
%{
  /* Be ready to insert the seed. */
  if (seed)
    {
      int res = seed;
      seed = 0;
      return res;
    }
%}

where seed is initialized in some way to the first token you want to
send (that depends whether your parser is pure or not etc.).

There is no limitation on the number of initial tokens, i.e., the
actual number of start symbols.



_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to