History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ANTLR-195
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Terence Parr
Reporter: Terence Parr
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
ANTLR v3

scoped attribute translation issue regarding type

Created: 15/Nov/07 12:50 PM   Updated: 29/Dec/07 03:17 PM
Component/s: All targets
Affects Version/s: 3.0.1
Fix Version/s: 3.1


 Description  « Hide
Johannes points out:

I discovered a problem which is likely in all targets. Look at the
following snippet from the C grammar of the C# examples:

direct_declarator
   : ( IDENTIFIER
       {
            if ($declaration.Count>0 && $declaration::isTypedef) {
                $Symbols::types[$IDENTIFIER.Text] = $IDENTIFIER.Text;
                Console.Out.WriteLine("define type "+$IDENTIFIER.Text);
            }
       }
       | '(' declarator ')'
       )
       declarator_suffix*
   ;

The problem is "if ($declaration.Count>0 && $declaration::isTypedef)".
It is translated into

"if (declaration_stack.Count>0 && ((declaration_stack.Count > 0) ?
((declaration_scope)declaration_stack.Peek()).isTypedef : null))"

Note that $declaration::isTypedef is checked with the conditional
operator against the case that declaration_stack doesn't have any
elements and returns in that case a null. But at least in C# null can't
be converted implicitly into false and returns an error. Ironically, the
condition tries to protect it against this possibility already. So, what
is the suggested solution? It looks like that the automatic checking
against null values goes to far in that case.


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Terence Parr - 29/Dec/07 03:17 PM
Using init value according to type rather than always null now.