Re: [CSG111] MP5: Q3,Q4: multiple branch for grammars?


Subject: Re: [CSG111] MP5: Q3,Q4: multiple branch for grammars?
From: Therapon Skotiniotis (skotthe@ccs.neu.edu)
Date: Sat Mar 11 2006 - 18:35:32 EST


On Sat, Mar 11, 2006 at 12:38:54PM -0500, Sang Yun Woo wrote:
> Hi, I am curious about using two grammars in a single translator.
>
> Because different grammar is used for Q3 and Q4,
> I am not sure it is necessary to separate source code (lang.scm).
>
> for example,
>
> for Q1and Q2:
>
> program :: expression
>
> for Q3 and Q4:
> program :: statement
>
> is the beginning rule of each grammar.
>
> Is there any way to use both grammar?
>
> PS.
> Could it be a kind of smart way to write like this?
>
> in lang.scm:
> ...
> (define the-grammar
> '( (program (statement) a-program)
> (program (expression) a-program2)

 The grammar for Q3 onwards uses expressions in some of its
 productions. Specifically look at the grammar rule for
 print. So the language is using both grammars but not in
 the same way that you sketched above.
 
 What you have above (although I have not tried it out) is
 creating 2 possible variants for a program.

 -- Theo

_______________________________________________
csg111 mailing list
csg111@lists.ccs.neu.edu
https://lists.ccs.neu.edu/bin/listinfo/csg111



This archive was generated by hypermail 2b28 : Thu Mar 15 2007 - 15:00:09 EDT