[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

YACC-like priority rules for METAL wanted



=> Is there a way in METAL to use the precedence and associativity rules
=> available in YACC, i.e.  %left, %right and %nonassoc declarations?

I had to use a very dirty hack to achieve what you want to do: I
modified the Buildfile (containing the dependency rules for compiling
metal) in order to run a sed-script on the generated yacc file. This
sed-script adds the relevant precedence rules to the yacc file.

Here is the content of my sed-script (in metal, my operators are
"EQUL",  "EQV", ...):

/^%start/i\
\
\
%left	KW_COMMA\
%nonassoc	KW_COLON\
%right	KW_EQUL\
%left	KW_EQV KW_NEQV\
%left	KW_OR\
%left	KW_AND\
%left	KW_NOT\
%nonassoc	KW_EQ KW_NE KW_LE KW_LT KW_GE KW_GT\
%left	KW_SLASHSLASH\
%left	KW_PLUS KW_MINU\
%left	KW_STAR KW_SLASH\
%right	KW_STARSTAR\