help-bison
[Top][All Lists]
Advanced

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

Questions on 3.4.6 Actions


From: slipbits
Subject: Questions on 3.4.6 Actions
Date: Wed, 8 Jun 2022 10:07:57 -0700
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0

In 3.4.6 Actions the format of a name, as in RULE[name}, not mentioned nor is the scope of the name, nor any constraint. For purposes of this discussion we define EBNF tag as the RULE name. Am I correct in assuming that:

1. A EBNF tag is composed of alphabetic, numeric characters and a dash
   ('-') and underscore, ('_').
2. The format of a EBNF tagis ([a-zA-Z] | (-|_)+)([a-zA-Z]|'-'|'_'_)*.
   Embedded white space is not allowed.
3. EBNF tags are case sensitive. Name and name are different.
4. EBNF tags can be used for terminals and non-terminals. For
     * expr : expr '+' expr
       expr[tag2] : exprtag2] '+'[tag3] expr[tag4] is legal
5. EBNF tags can only be used in a block statement (brace block).
   expr[name] : name + expr is not legal,
6. Within a block statement, EBNF tag are referenced by '$'tag or
   '@'tag. That is, LHS[name} is referenced by $name or @name.
     * The '$' prefix refers to the terminal/non-terminal value
       (semantics).
     * The '@' prefix refers to the location of the
       terminal/non-terminal. (see 1.6 Location).
7. The scope of a EBNF tag is the EBNF expression it is in, with the
   following conditions:
     * LHS[name] : RHS // is a scope
     * LHS[name] | RHS // is a scope
8. EBNF tags are unique within their scope.
     * LHS[name] : RHS[name] // is not legal
     * LHS : R1[name] R2[name] // is not legal
9. EBNF tags declared in the EBNF statement do not  hide names within
   the scope of the block statement.For example:
         <type> name;    // in global scope
            o o o
        LHS[name] : RHS { $name = name;} is legal
10. EBNF tags and terminal/non-terminal names can be the same. That is:
     * expr[expr] : expr '+' expr is legal
11. The scope of the LHS EBNF tag is the entire expression. That is in
       LHS[name] : RHS1 {$name = }
                 | RHS2 {$name = }
   both refer the the LHS EBNF tag, name.
12. yy and YY have special meanings within Bison and should not be used
   as EBNF tag prefixes. That is yyname and YYname are both legal but
   should not be used.
13. "__" should not be used in C/C++ block statements. Both C and C++
   standards and compilers use these prefixes.
14. Where one blank is legal, many can be  used. The following is legal:
     * LHS  [  name  ] and
     * LHS[name  ] and
     * LHS[   name] and so on for the RHS.
15. A "EBNF tag block" is defined as EBNF[name], where [name] is a "EBNF
   tag block". Only one name is allowed in  a EBNF tag block. That is
   LHS[name1 name2] is not legal
16. The LHS EBNF tag has no value on rule reduction and must be assigned
   a value (lvalue). After assignment it can be used as an rvalue.
     * LHS[name] : ... { $name = value; ...}  // is legal
     * LHS[name]: ... { var = $name; .. }     // is not legal
     * LHS[name]: ... { $name = value; ... var = $name; ... )  // is legal
17. The RHS EBNF tag has a value on rule reduction.
18. The EBNF tag for the LHS and RHS have a location on rule reduction.
19. If the tagged terminal/non-terminal is a structure or class, then
   it's public members can be accessed by  using a '.',. if the EBNF
   tag is name, then for example,
     * if it has a value (semantic) as in
       struct {
           int x;
           int y;
       }
       then name.x refers to the x component of the structure.
     * if it is a location then name.first_column refers to a value in
       the location structure.

Definition:
    LHS left hand size   LHS : RHS
    RHS right hand side   LHS : RHS

Are these assumptions correct.


reply via email to

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