help-bison
[Top][All Lists]
Advanced

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

Re: Actions for Javas class_declaration


From: Di-an JAN
Subject: Re: Actions for Javas class_declaration
Date: Thu, 20 Nov 2008 09:20:58 -0800 (PST)

On Thu, 20 Nov 2008, Andreas Leppert wrote:

Hello,

I've seen this which stands for a Java Class Declaration:

class_declaration:
modifiers CLASS_TK identifier super interfaces
        { create_class ($1, $3, $4, $5); }
class_body
        {;}
| CLASS_TK identifier super interfaces
        { create_class (0, $2, $3, $4); }
class_body
        {;}
...


I have problems to understand the semantic action {;}. Does it mean "do
nothing" ? Why just not leave it blank?

{;} does not have any special meaning.  You can leave out the semicolon
or the whole braces in current versions of Bison or Berkeley yacc.
Perhaps it's for compatibility with other versions or just a matter of
style.

Furthermore, I would have expected something like this:

modifiers CLASS_TK identifier super interfaces class_body
        { create_class ($1, $3, $4, $5, $6); }

I mean the body of a class should be attached to the class declaration,
shouldn't it?

We need to consider the rest of the grammar, but I would guess that
it's done this way so that the class is available for use when parsing
the body, and that semantic actions within class_body would add to
the class. If you have the action at the end, the class would not be created until after the class body is processed.

Thanks for the help!
Andreas Leppert

Di-an Jan




reply via email to

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