Parrot and Perl 6 Parrot and Perl 6 - Environments for Dynamic Languages #38

Operator precedence parsing

Once again, pgc.pir has borrowed a bit of Perl 6-like syntax:

proto "infix:+" is precedence('=') { ... }
proto "infix:-" is equiv('infix:+') { ... }

proto "infix:*" is tighter('infix:+') { ... }
proto "infix:/" is equiv('infix:*') { ... }

This defines the four basic arithmetic operators, and generates code to initialize an operator precedence parser.

These definitions can go in the same grammar input file that defines other rules.

Copyright © 2007 Patrick Michaud