[colm-users] yacc-style precedence rules

Adrian Thurston thurston at complang.org
Sat Apr 4 23:02:19 UTC 2009


Hello,

Colm now supports yacc-style precedence specifications. Many programming 
languages use them and supporting them in Colm makes the specification 
of these languages easier.

Colm runs the yacc-style precedence resolution after actions have been 
ordered by its own algorithm, therefore the yacc-style precedence rules 
take priority. Unlike Colm's ordering algorithm, the yacc-style 
precedence rules result in a permanent resolution of the conflict.

Here's an example from a Ruby grammar:

right '='
left 'rescue'
right '?', ':'
nonassoc '..', '...'
left '||'
left '&&'
nonassoc '<=>', '==', '===', '!=', '=~', '!~'
left '>', '>=', '<', '<='
left '|', '^'
left '&'
left '<<', '>>'
left '+', '-'
left '*', '/', '%'
#right tUMINUS_NUM tUMINUS
right tUMINUS
right '**'
right '!', '~', tUPLUS

def arg
     [lhs '=' arg]
|   [lhs '=' arg 'rescue' arg]
|   [arg '?' arg ':' arg]
|   [arg '..' arg]
|   [arg '...' arg]
|   [arg '||' arg]
|   [arg '&&' arg]
|   [arg '<=>' arg]
|   [arg '==' arg]
|   [arg '===' arg]
|   [arg '!=' arg]
|   [arg '=~' arg]
|   [arg '!~' arg]
|   [arg '>' arg]
|   [arg '>=' arg]
|   [arg '<' arg]
|   [arg '<=' arg]
|   [arg '|' arg]
|   [arg '^' arg]
|   [arg '&' arg]
|   [arg '<<' arg]
|   [arg '>>' arg]
|   [arg '+' arg]
|   [arg '-' arg]
|   [arg '*' arg]
|   [arg '/' arg]
|   [arg '%' arg]
|   [arg '**' arg]
|   ['!' primary]
|   ['~' primary]
|   [tUMINUS primary]
|   [tUPLUS primary]
|   ['defined?' arg]
|   [primary]




More information about the colm-users mailing list