mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-13 17:38:39 +00:00
Add initial lexer and parser support for shifting values. Every use of this
will lead to it being rejected though. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21335 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1cbf3abbb8
commit
b9266f880a
@ -195,6 +195,11 @@ field { return FIELD; }
|
|||||||
let { return LET; }
|
let { return LET; }
|
||||||
in { return IN; }
|
in { return IN; }
|
||||||
|
|
||||||
|
!sra { return SRATOK; }
|
||||||
|
!srl { return SRLTOK; }
|
||||||
|
!shl { return SHLTOK; }
|
||||||
|
|
||||||
|
|
||||||
{Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng);
|
{Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng);
|
||||||
return ID; }
|
return ID; }
|
||||||
${Identifier} { Filelval.StrVal = new std::string(yytext+1, yytext+yyleng);
|
${Identifier} { Filelval.StrVal = new std::string(yytext+1, yytext+yyleng);
|
||||||
|
@ -189,6 +189,7 @@ using namespace llvm;
|
|||||||
};
|
};
|
||||||
|
|
||||||
%token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD LET IN
|
%token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD LET IN
|
||||||
|
%token SHLTOK SRATOK SRLTOK
|
||||||
%token <IntVal> INTVAL
|
%token <IntVal> INTVAL
|
||||||
%token <StrVal> ID VARNAME STRVAL CODEFRAGMENT
|
%token <StrVal> ID VARNAME STRVAL CODEFRAGMENT
|
||||||
|
|
||||||
@ -308,6 +309,24 @@ Value : INTVAL {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
delete $3;
|
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 */ {
|
OptVarName : /* empty */ {
|
||||||
|
@ -463,6 +463,11 @@ struct Init {
|
|||||||
virtual Init *getFieldInit(Record &R, const std::string &FieldName) const {
|
virtual Init *getFieldInit(Record &R, const std::string &FieldName) const {
|
||||||
return 0;
|
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
|
/// resolveReferences - This method is used by classes that refer to other
|
||||||
/// variables which may not be defined at the time they expression is formed.
|
/// variables which may not be defined at the time they expression is formed.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user