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

Re: *Almost* free-form syntax



Can we please keep attachment sizes to a minimum on the lists.
Or at least compress them before sending. I don't mind 100k
attachments personally but 800k is a bit much.

Regards,
Indrek

On Thursday 22 January 2004 04:30, Etienne Gagnon wrote:
> Hi Danilo.
>
> I have attached the output of:
>    java -mx1024m -jar [...]/lib/sablecc.jar lua_modified.scc 2>&1 | cat -
> >lua_modified.scc.output
>
> Note the -mx parameter to the Java virtual machine.  Also, I am using
> the SableCC snapshot extracted from Kevin's latest Subversion code:
>
> $ svn co
> svn://svn.sablecc.org/developers/kevin/tags/sablecc3-inlining-beta3-2003-12
>-01/ $ ant jar
> ## you now have sablecc.jar in the lib/ subdirectory
>
> For you information, SableCC 3 does "cosmetic" changes your grammar [it
> "inlines" some productions to eliminate conflicts].  For this reason,
> SableCC 3 tells you about a conflict, but it also outputs the *modified*
> grammar which exhibits the conflict. This is why the attached output seems
> complex.
>
> By the way, SableCC 2.18.2 does also report a conflict with your grammar.
> [A different one than SableCC 3, as the inlining process does eliminate a
> few conflicts].
>
> Have fun!
>
> Etienne
>
> Danilo Tuler wrote:
> > First of all, thanks for the help.
> >
> >>Ugly!  I'm pretty sure they use bison's default shift on
> >>shift/reduce conflicts to deal with this.  It's an inherently
> >>ambiguous grammar.
> >
> > As Fidel said, Lua parser is implemented by hand.
> > Here is the fragment of the source code that "solves" the ambiguity.
> >
> > static void funcargs (LexState *ls, expdesc *f) {
> >
> >   (...)
> >
> >   int line = ls->linenumber;
> >   switch (ls->t.token) {
> >     case '(': {  /* funcargs -> `(' [ explist1 ] `)' */
> >       if (line != ls->lastline)
> >         luaX_syntaxerror(ls,"ambiguous syntax (function call x new
> > statement)");
> >
> >   (...)
> >
> > This code can be seen here
> > http://www.lua.org/source/5.0/src_lparser.c.html
> >
> >>OK.  This being said, this is how you deal with it.  The idea
> >>is to do as with the well known if/if-else ambiguity, and
> >>duplicate parts of the grammar to express the restrictions
> >>you want to impose (thus eliminating the ambiguity).
> >
> > I'm trying to follow Etienne's suggestion, but something is very wrong.
> > I think sablecc is in an infinite loop, and throws a OutOfMemory
> > exception. I'm attaching my grammar.
> >
> > Is there any other possibility to resolve the ambiguity? Maybe playing
> > with the lexer... Mr Etienne said: "Dealing with the newline thing
> > requires playing with lexer states, and is beyond the scope of this
> > email"
> >
> > Any help is very welcome!
> > Thanks in advance.
> > Danilo