[plt-scheme] Parser tools and actions in mid-rules

From: Dave Herman (dherman at ccs.neu.edu)
Date: Thu Mar 19 13:40:31 EDT 2009

Can you do something like the following?

    [(EVENT locals event-rest)
     ($3 $2)])
    [(BODY expression END)
     (lambda (locals)
       ;; update the environment


On Mar 19, 2009, at 12:26 PM, Paulo J. Matos wrote:

> Hi all,
> Bison supports actions in mid-rule:
> http://www.gnu.org/software/bison/manual/html_mono/bison.html#Mid_002dRule-Actions
> however this doesn't seem the case with Parser Tools.
> I wonder then, what's the best way to solve the following issue:
> I am parsing a formal specification language which introduce several
> environments which are just pairs of Variable / Type.
> One structure of the language is an Event which has a local variables
> section and a body section.
> Something like:
> event ::= EVENT locals BODY expression END;
> The way to do this would be to have a mid-rule after locals to create
> a new environment which contains the variables defined in locals and
> then after END, we remove the destroy the environment.
> Without mid-rules I am a bit lost. Is there any other way to do this
> kind of thing? (or maybe some way to turn an unambiguous grammar with
> mid-rules into an unambiguous grammar without mid-rules)
> -- 
> Paulo Jorge Matos - pocmatos at gmail.com
> Webpage: http://www.personal.soton.ac.uk/pocm
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.