Re: Question on extensibility of a gobo lexer/parser

"thomas beale" <Thomas.Beale-ifdBxBAjbfUj83aOlRudGVaTQe2KTcn/@public.gmane.org> Tue, 17 Aug 2010 22:51:36 -0000
Newsgroups gmane.comp.lang.eiffel.gobo.general
Message-ID <[email protected]>
I wonder if I should consider using gepp to preprocess the files, and embed #include statements in them. It would mean that the source files would be the pieces containing declarations, production rules and user code. A proper .y file would be created by processing a .ypp file containing:

#include "path/to/standard/declarations/file"
%%
#include "path/to/standard/rules/file"
%%
#include "path/to/standard/code/file"

and a parser file wanting to extend this would have 

#include "path/to/standard/declarations/file"
-- some other declarations here
%%
#include "path/to/standard/rules/file"
-- some more rules here
%%
#include "path/to/standard/code/file"
-- other user code here


pretty awful, and pretty annoying to maintain, but I can't see any other way. Otherwise as you say, it is cut and paste. But the need for extendible grammar is quite common. I can't help feeling that we need something smarter than .y and .l files....

- thomas


--- In [email protected], Eric Bezault <ericb@...> wrote:
>
> Hi Thomas
> 
> thomas beale wrote:
> > Hi Eric,
> > we have various parsers in openEHR that follow the standard pattern published in your documentation, i.e. a .y & .l file generating the usual .e files. 
> > 
> > Now let's say Organisation A publishes a language and parser to go with it, such as the dadl syntax we use - some example files - http://www.openehr.org/svn/knowledge2/TRUNK/rm_schemas/
> > 
> > Let's say that Org B wants to use this syntax but extend it by adding some new patterns that can be recognised.
> > 
> > How can Org B use Org A's published stuff to do this? Org B needs to add more patterns into the lexer definition, and more production rules into the parser definition. But there is no way to inherit a .y file into another .y file. Is there any kind of inclusion or other reuse mechanism available?
> > 
> > To make the question more concrete, if it helps, imagine Org A's parser does not support date/time patterns between the <> delimiters, but Org B needs date/times. How could Org B add it (other than taking a copy of Org A's .l/.y files, which of course defeats any kind of maintenance)?
> 
> I don't think that there is any reuse facility in .l and .y
> files. I'm afraid that the only solution is copy/paste.
> 
> -- 
> Eric Bezault
> mailto:ericb@...
> http://www.gobosoft.com
>




------------------------------------

To Post a message, send it to:   [email protected]
To Unsubscribe, send a blank message to: [email protected]! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/gobo-eiffel/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/gobo-eiffel/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/