Hi,

I'm learning antlr by implementing a javascript parser. My target 
language is C#. I'm using Patrick Hulsmeijer's Ecmascript3 grammar. I 
converted java codes to c# code in the grammar file. I was able to 
compile a lexer, a parser and a tree walker with this grammar. I tried a 
lot of js input, and I fixed some errors in the c# code in the grammar 
file. But in the belov input, tree walker display "no viable alternative 
at input 'PAREXPR'".
The input is :
if ((a1 = this.prototype[a1])) return add(this, a2, a1, a3);

I looked at grammar and tree walker files, but I didn't solve this 
problem. In grammar file, I saw:

primaryExpression
    : THIS
    | Identifier
    | literal
    | arrayLiteral
    | objectLiteral
    | lpar=LPAREN expression RPAREN -> ^( PAREXPR[$lpar, "PAREXPR"] 
expression )
    ;

And in the tree walker file, there is:
primaryExpression
    : Identifier
    | literal
    ;

This implementation works well when the input has not recursive 
parenthesises. If the input has recursive parens like "((( expression 
)))", the tree walker gives the error I mentioned before.

I studied compilers before. But I am new at antlr grammar. I couldn't 
understand what PARAEXPR is and what is the "-> ^(    )" in the 
primaryExpression.

How can solve this problem?

Any help'll be appreciated.

Regards.

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