Parse::RecDescent problem, $::RD_TRACE showing something very odd. 
Author Message
 Parse::RecDescent problem, $::RD_TRACE showing something very odd.

Quote:

> Hi, everyone.

> I'm still working on my long RecDescent grammar,
> and right now my script dies with

>     ERROR (line 1264): Untranslatable item encountered: "}"
>                 (Hint: Did you misspell "}" or forget to comment it
> out?)
> Bad grammar!

[snip]

Quote:
>     'sizeof' | 'static' | 'typedef' | "union"
> }};

[snip]

Quote:

> The second closing curly brace is an experiment. If I delete it I get
> this error message:
> Can't find string terminator "}" anywhere before EOF at www/decss.pl
> line 33.

Hmm , but you don't show us what opening braces those ending braces
match up with.  Where do they open, and is it possible one of them
should be closed before there?

--
Jeff



Wed, 18 Jun 1902 08:00:00 GMT  
 Parse::RecDescent problem, $::RD_TRACE showing something very odd.

Quote:

> my $Grammar = q{

How about using a different delimiter for your string?  I still don't
see what the }}: is doing at the end of your last rule.  The second };
closes your string delimiter, ok got that, but why is the first one
there, after the rule definition?

--
Jeff



Wed, 18 Jun 1902 08:00:00 GMT  
 Parse::RecDescent problem, $::RD_TRACE showing something very odd.
Hi, everyone.

I'm still working on my long RecDescent grammar,
and right now my script dies with

    ERROR (line 1264): Untranslatable item encountered: "}"
                (Hint: Did you misspell "}" or forget to comment it
out?)
Bad grammar!

Turning on RD_TRACE shows that before dying, the interpreter gets as far
as this
before quitting:

 .......

    Parse::RecDescent: Treating "goto" as a literal terminal
    Parse::RecDescent: Treating "|" as a new production
    Parse::RecDescent: Treating "long" as a literal terminal
    Parse::RecDescent: Treating "|" as a new production
    Parse::RecDescent: Treating "register" as a literal terminal
    Parse::RecDescent: Treating "|" as a new production
    Parse::RecDescent: Treating "sizeof" as a literal terminal
    Parse::RecDescent: Treating "|" as a new production
    Parse::RecDescent: Treating "static" as a literal terminal
    Parse::RecDescent: Treating "|" as a new production
    Parse::RecDescent: Treating "typedef" as a literal terminal
    Parse::RecDescent: Treating "|" as a new production
    Parse::RecDescent: Treating ""union"" as an interpolated literal
terminal

The last rule in my grammar is this:

identifier : ...!reserved identifier_word

    identifier_word : / [a-z_]            # LEADING ALPHA OR UNDERSCORE
    [a-z0-9_]*        # THEN DIGITS ALSO ALLOWED
    /ix                 # CASE/SPACE/COMMENT INSENSITIVE

    #todo : complete the list.
    reserved: 'int' | 'double' | 'short' | 'volatile' | 'register' |
'float' | 'signed' | 'unsigned' | 'char' |
    'for' | 'if' | 'switch' | 'case' | 'while' | 'do' | 'case' |
'extern' | 'void' | 'exit' | 'return' |
    'auto' | 'break' | 'const' | 'continue' | 'default' | 'else' |
'enum' | 'struct' | 'goto' | 'long' | 'register' |
    'sizeof' | 'static' | 'typedef' | "union"

Quote:
}};

So you can see that it does treat the last rule correctly.

The second closing curly brace is an experiment. If I delete it I get
this error message:
Can't find string terminator "}" anywhere before EOF at www/decss.pl
line 33.

THis leaves me at a loss to what might be happening.

Any suggestions, anyone?

Regards,

Omri Schwarz



Wed, 18 Jun 1902 08:00:00 GMT  
 Parse::RecDescent problem, $::RD_TRACE showing something very odd.

Quote:


> > Hi, everyone.

> > I'm still working on my long RecDescent grammar,
> > and right now my script dies with

> >     ERROR (line 1264): Untranslatable item encountered: "}"
> >                 (Hint: Did you misspell "}" or forget to comment it
> > out?)
> > Bad grammar!

> [snip]

> >     'sizeof' | 'static' | 'typedef' | "union"
> > }};

> [snip]

> > The second closing curly brace is an experiment. If I delete it I get
> > this error message:
> > Can't find string terminator "}" anywhere before EOF at www/decss.pl
> > line 33.

> Hmm , but you don't show us what opening braces those ending braces
> match up with.  Where do they open, and is it possible one of them
> should be closed before there?

They open 1200 lines above with:

my $Grammar = q{
    {

        my $defined_types = "";
        my $declared_global_vars = "";
    }
    startrule : startrule2(s)    

.....

I've gone over the script several times to see if I left a closing brace
somewhere
by mistake, but the RD_TRACE indicates that it didn't.

It was parsing the last rule correctly. This is what leaves me
mystified.



Wed, 18 Jun 1902 08:00:00 GMT  
 Parse::RecDescent problem, $::RD_TRACE showing something very odd.

Quote:


> > my $Grammar = q{

> How about using a different delimiter for your string?  I still don't
> see what the }}: is doing at the end of your last rule.  The second };
> closes your string delimiter, ok got that, but why is the first one
> there, after the rule definition?

It's only there because if it isn't I get this error message:

Can't find string terminator "}" anywhere before EOF at www/decss.pl
line 33.



Wed, 18 Jun 1902 08:00:00 GMT  
 Parse::RecDescent problem, $::RD_TRACE showing something very odd.

Omri> It's only there because if it isn't I get this error message:

Omri> Can't find string terminator "}" anywhere before EOF at www/decss.pl
Omri> line 33.

That probably means that the "brace balancer" is confused for the q{}
string.  Try using a here-doc instead.  The odds of you having
\nYOUR_END_TAG\n in the midst of your string are a lot less than you
having unbalanced { and }, as you apparently have. :)

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Wed, 18 Jun 1902 08:00:00 GMT  
 Parse::RecDescent problem, $::RD_TRACE showing something very odd.

Quote:

>I'm still working on my long RecDescent grammar,
>and right now my script dies with
>    ERROR (line 1264): Untranslatable item encountered: "}"
>                (Hint: Did you misspell "}" or forget to comment it
>out?)
>Bad grammar!

 [snip]
>    'sizeof' | 'static' | 'typedef' | "union"
>}};

>The second closing curly brace is an experiment. If I delete it I get
>this error message:
>Can't find string terminator "}" anywhere before EOF at www/decss.pl
>line 33.

I bet you have an extra _opening_ curly brace in there.  In
particular, I bet it's quoted or commented out so that RecDescent
doesn't consider it a paired delimiter, but _perl does_.

You might want to use some other string delimiter.

--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.



Wed, 18 Jun 1902 08:00:00 GMT  
 Parse::RecDescent problem, $::RD_TRACE showing something very odd.

Quote:


> Omri> It's only there because if it isn't I get this error message:

> Omri> Can't find string terminator "}" anywhere before EOF at www/decss.pl
> Omri> line 33.

> That probably means that the "brace balancer" is confused for the q{}
> string.  Try using a here-doc instead.  The odds of you having
> \nYOUR_END_TAG\n in the midst of your string are a lot less than you
> having unbalanced { and }, as you apparently have. :)

Switching to q[] then pointed to an error midway through the script.


]I bet you have an extra _opening_ curly brace in there.  In
]particular, I bet it's quoted or commented out so that RecDescent
]doesn't consider it a paired delimiter, but _perl does_.

]You might want to use some other string delimiter.

And indeed, the next error was because of a comment that contained a
quoted closing square bracket.

Thank you very much, everyone!



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Help: Problem with simple parsing and Parse::RecDescent

2. Text Parsing - Parse::RecDescent or another method?

3. Problem mit Parse::RecDescent

4. Parsing with Parse::RecDescent

5. Parse::RecDescent and parsing comments

6. HELP needed on a simple Parse::RecDescent program (problem: some rules are matched twice)

7. Parsing with Parse::RecDescent

8. HELP needed on a simple Parse::RecDescent program (problem: some rules are matched twice)

9. Parse::RecDescent stops parsing.

10. Parse::RecDescent: Problem with a Grammar

11. problem with parsing something

12. $? returning something odd

 

 
Powered by phpBB® Forum Software