[antlr-interest] Define "function" as numerical and alphanumerical expression

David-Sarah Hopwood david-sarah at jacaranda.org
Thu Nov 5 23:21:23 PST 2009


David-Sarah Hopwood wrote:
> My advice would be to use a conventional operator precedence grammar,
> as below (now that I've spent the time to fix the grammar I might as
> well give you this part of it), and check types after parsing.
> 
[...]
> logical_expression           : not_expression (logical_op not_expression)* ;
[...]
> numerical_expression         : primary_expression
>                                  (numOp primary_expression)* ;

Incidentally, this treats AND and OR as having the same precedence, and
similarly for all numeric operators. That is probably not what you want
in practice; the grammar should have a separate rule for each precedence
level.

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 292 bytes
Desc: OpenPGP digital signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20091106/c1056724/attachment.bin 


More information about the antlr-interest mailing list