grammatica-users
[Top][All Lists]
Advanced

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

Re: [Grammatica-users] Grammatica Hangs


From: Per Cederberg
Subject: Re: [Grammatica-users] Grammatica Hangs
Date: Wed, 3 Apr 2013 18:42:36 +0200

Ah, yes. It is always java... Guess it shows how much time has passed since I used Grammatica myself. ;-)

The problem is in the rule CellParameterList (found that out by commenting out the suspicious rule bodies one by one). It seems that the rule bodies "... (A B C?)? ..." are problematic, i.e. using nested optional elements. Better to break this out as separate rules.

The reason for the loop here is probably related to the Grammatica analysis of the tokens used in each rule. When too much is optional, this set grows very large and risks triggering these kind of issues.

Solution:

CellParameterList = "(" CellParameters ")" ;

CellParameters = CellParameter ("," CellParameter)* ;

CellParameter = "width" "=" NUMBER
    | "height" "=" NUMBER
    | "verticaloffset" "=" NUMBER
    ...

Better still might be to break out these even further:

HeightParameter = "height" "=" NUMBER ;
VerticalOffsetParameter = "verticaloffset" "=" NUMBER ;

A few further comments:

1. XML is hard to parse properly with a tool like Grammatica, since its structure cannot be fully captured in regex tokens and LL(k) productions in a sensible manner. That said, it is still possible to create something useful for machine-generated inputs.

2. The grammar would be easier and faster if fewer regexes were used. Use case-insensitive tokens for example. And create tokens that have a "higher level". Like this:

CASESENSITIVE = false
...
WHEN_START = "<xsl:when>"
WHEN_END = "</xsl:when>"

3. Use the token strings in the rules to make things more readable. Such as in the example Cell* rules above.

Cheers,

/Per



On Wed, Apr 3, 2013 at 5:57 PM, <address@hidden> wrote:
I'm generating C#, and I'm using it on .Net, but my command line is:
"C:\Program Files (x86)\Java\jre6\bin\java" -jar lib/grammatica-1.5.jar  XSLTableCreator2.parser --parse Test.txt

The grammar is attached.





From:        Per Cederberg <address@hidden>
To:        address@hidden
Date:        04/03/2013 10:47 AM
Subject:        Re: [Grammatica-users] Grammatica Hangs
Sent by:        grammatica-users-bounces+lmaturo=address@hidden




If it's not secret or too large, try posting the grammar file to this group.

Also. Are you using the Java or the .NET version?

Cheers,

/Per


On Wed, Apr 3, 2013 at 5:44 PM, <address@hidden> wrote:
I have a grammar I was debugging, and after a fix to the grammar, Grammitica
just hangs with no output.  I've seen that it has code to detect infinite loops, but

it sure looks like it's in one that isn't detected.


Any idea of what I should try next?


-- Larry

_______________________________________________
Grammatica-users mailing list

address@hidden
https://lists.nongnu.org/mailman/listinfo/grammatica-users

_______________________________________________
Grammatica-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/grammatica-users


_______________________________________________
Grammatica-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/grammatica-users



reply via email to

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