help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Include %token and %union declaration from a shared file


From: Alexander Barkov
Subject: Re: Include %token and %union declaration from a shared file
Date: Fri, 8 Jul 2016 16:46:54 +0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

Hi Hans,

Thanks for your replies.

We're inclined toward generating the *.yy files with help of some text
pre-processor. Possibly, using some CMake commands...

It would be great though if bison could collect the grammar definition
from multiple files. Where can I post this feature request?

Thanks!

On 07/08/2016 04:39 PM, Hans Åberg wrote:

On 7 Jul 2016, at 14:47, Alexander Barkov <address@hidden> wrote:

In our application we need to have two parsers using:

- the same yylex function (the tokenizer)
- the same set of terminal symbols (%token)
- the same YYSTYPE structure (%union)

but implementing very different syntax rules.

One other possibility might be to implement two grammars headed by two dummy 
tokens not used otherwise:
   start:
       "foo" grammar1
     | "bar” grammar2
   ;

   grammar1: …

   grammar2: …

When the parsers start, insert one of the tokens first to select the grammar.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]