let { return LET; }
in { return IN; }
+!sra { return SRATOK; }
+!srl { return SRLTOK; }
+!shl { return SHLTOK; }
+
+
{Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng);
return ID; }
${Identifier} { Filelval.StrVal = new std::string(yytext+1, yytext+yyleng);
};
%token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD LET IN
+%token SHLTOK SRATOK SRLTOK
%token <IntVal> INTVAL
%token <StrVal> ID VARNAME STRVAL CODEFRAGMENT
exit(1);
}
delete $3;
+ } | SHLTOK '(' Value ',' Value ')' {
+ $$ = $3->getBinaryOp(Init::SHL, $5);
+ if ($$ == 0) {
+ err() << "Cannot shift values '" << *$3 << "' and '" << *$5 << "'!\n";
+ exit(1);
+ }
+ } | SRATOK '(' Value ',' Value ')' {
+ $$ = $3->getBinaryOp(Init::SRA, $5);
+ if ($$ == 0) {
+ err() << "Cannot shift values '" << *$3 << "' and '" << *$5 << "'!\n";
+ exit(1);
+ }
+ } | SRLTOK '(' Value ',' Value ')' {
+ $$ = $3->getBinaryOp(Init::SRL, $5);
+ if ($$ == 0) {
+ err() << "Cannot shift values '" << *$3 << "' and '" << *$5 << "'!\n";
+ exit(1);
+ }
};
OptVarName : /* empty */ {
virtual Init *getFieldInit(Record &R, const std::string &FieldName) const {
return 0;
}
+
+ enum BinaryOp { SHL, SRA, SRL };
+ virtual Init *getBinaryOp(BinaryOp Op, Init *RHS) {
+ return 0;
+ }
/// resolveReferences - This method is used by classes that refer to other
/// variables which may not be defined at the time they expression is formed.