[antlr-interest] Grammar Question

Andrew Deren andrew at adersoftware.com
Sun Jun 5 20:54:53 PDT 2005


I'm working on a small language with syntax similar to basic. 
One of the expression types is array access, where you can use parenthesis
for accessing the array member:
x = somearray(3)

the problem I'm having is that this somearray(3) could also be function
call. Currently I'm creating FunctionCall for those and converting those to
ArrayAccess at type checking stage. 
I don't like doing that, so are there any ways around it? I'm constructing
heterogeneous immutable AST, so just for this little thing as a hack I allow
modification of the expression tree. The tree is constructed by the parser. 
The future problem could be that someone could define array with name
somearray and function somearray(int), so which expression should be used?
The language spec allows function and variable names to be the same (I
didn't write it and can't change it).
If anyone has experience with basic, how do they handle it?
Thanks,
Andrew




More information about the antlr-interest mailing list