Hi Fredrik,

I think the correct approach (for parsing an ambiguous language
which requires symbol table knowledge to parse) is while
parsing the code in the first parse, to:

* insert each symbol into the symbol table, which needs to know
all the scoping rules.

* in each situation where the language is ambiguous, to use a
dis-ambiguating semantic predicate to lookup the symbol in the
symbol table, and based on the answer from the dis-ambiguating
semantic predicates, the correct rule is selected.

Thanks, Mark

On Wed, 17 Jun 2009 16:19:28 +0200
Fredrik Ohrstrom <[email protected]> wrote:

> Sadly enough ;-) , the following c-code compiles both using gcc and
> cl.exe
> 
> ---------------
> typedef int alfa;
> typedef int beta;
> 
> struct { struct { int z; } alfa; } c;
> 
> int main(int alfa)
> {
>    beta beta;
> }
> ---------------
> 
> The example antlv3 c-parser found on the antlr homepage will wrongly
> parse the alfa inside the struct as a type_id and not a
> direct_declarator. In the same way it wrongly parses the argument
> alfa and the function local beta.
> 
> I have tried to extend the grammar to fix this, unfortunately I have
> not been able to solve all the cases in the example, only the arg and
> local var case.
> 
> What is the correct way of solving this?
> 
> //Fredrik
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address


-- 

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to