[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
syntax howto question
From: |
Sean Middleditch |
Subject: |
syntax howto question |
Date: |
02 Nov 2002 21:47:37 -0500 |
Hi all,
I've got a hairy bit of grammar to deal with - I need to be able to
differentiate in a language between function call and method calls. The
syntax for a function may look like
blah (args);
and for a method
object.blah (args);
Now, object.blah can also be a member lookup (versus a method call), so
a valid expression can contain a function call, method call, or member
lookup. Also, function calls can be against an expression, not just an
identifier (since functions are first-class values in the language).
I've got here the grammar snippets giving me pains:
expr: ...
| expr '(' args ')' { ... }
| expr '.' name '(' args ')' { ... }
| expr '.' name { ... }
...
The problem I'm having is that the grammer is not picking up method
calls right. It sees object.blah (args); as an expression
(object.blah the member lookup), then puts that into the function call
expression. This makes method calls rather not work... I've tried
giving the function/method calls explicit precedence (the method call
being higher) like so:
%nonassoc TFUNCCALL
%nonassoc TMETHODCALL
expr: ...
| expr '(' args ')' %prec TFUNCCALL { ... }
| expr '.' name '(' args ')' %prec TMETHODCALL { ... }
| expr '.' name { ... }
...
But it helps not. Bison isn't giving me any shift or reduce errors,
either. Any insight on how I can get this working the way I'd like it
to?
Thankies,
Sean Etc.
- syntax howto question,
Sean Middleditch <=