grammatica-users
[Top][All Lists]
Advanced

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

Re: [Grammatica-users] More JML Questions...


From: Per Cederberg
Subject: Re: [Grammatica-users] More JML Questions...
Date: Wed, 07 Apr 2004 10:51:42 +0200

On Wed, 2004-04-07 at 09:24, Brandon Silverstein wrote:
> Per,
> 
> Thanks for your help so far.  I'm still having some trouble solving 
> certain inherent ambiguities in my JML grammar.  For example, I rewrote 
> the field declaration based on your suggestion from the first message I 
> wrote:
> 
> field = DOC_COMMENT* modifiers* declaration
>          | methodSpecification initOrStatement
>          | "axiom" predicate ";"
>          | ";";

This conflict can only be coming from the first two lines, as 
neither the "axiom" or ";" tokens appear in the list of 
conflicting tokens. Going down the productions a little bit I
found that the declaraction production can be started with a
methodSpecification (invoked from methodDecl). And that is an
ambiguity that Grammatica cannot resolve automatically.

I don't know what would be the best solution in your case, but
I suspect that you'd have to move the second field alternative
above into the declaration production (or rather one of the 
subproductions) in order to share the "methodSpecification"
between "initOrStatement" and the other productions that use it.

> Now this seemed strange to me because these tokens appear to be from 
> the jmlKeyword prodcution, but not all of the tokens from the 
> jmlKeyword list appear here.  Also, tokens like "{|" appear in the 
> error message but this comes from a different production.  Does this 
> have to do with the order in which my tokens are declared, or should 
> these tags be parsed seperately like you state in your second reply?

The token order is not relevant when it comes to resolving
ambiguities between productions. What I meant by parsing
separately is that my previous DOC_COMMENT token would match
the whole of:

  /**
   * Hello.
   * @since 1.0
   */

That is, if we want to extract the @since information, we 
would have to process the text contents of the matched
DOC_COMMENT token in the analysis stage (or later).

I'd *really* recommend you to follow the advice of doing 
the tokenizer part first if you haven't already. That way
you get a better understanding for how the Grammatica 
parsing works. Then you won't have to worry so much about
the tokenizer while doing the productions.

Cheers,

/Per






reply via email to

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