
|
If you were logged in you would be able to see more operations.
|
|
|
ANTLR v3
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
|
|
|
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.
|
|
Description
|
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.
|
Show » |
|