mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Start transitioning towards using 'let X = y in' statements, instead of 'set X = y in'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7562 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e9d019c364
commit
42aa89eeb1
@ -159,7 +159,8 @@ dag { return DAG; }
|
|||||||
class { return CLASS; }
|
class { return CLASS; }
|
||||||
def { return DEF; }
|
def { return DEF; }
|
||||||
field { return FIELD; }
|
field { return FIELD; }
|
||||||
set { return SET; }
|
let { return LET; }
|
||||||
|
set { return LET; }
|
||||||
in { return IN; }
|
in { return IN; }
|
||||||
|
|
||||||
{Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng);
|
{Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng);
|
||||||
|
@ -18,18 +18,18 @@ static Record *CurRec = 0;
|
|||||||
|
|
||||||
typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
|
typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
|
||||||
|
|
||||||
struct SetRecord {
|
struct LetRecord {
|
||||||
std::string Name;
|
std::string Name;
|
||||||
std::vector<unsigned> Bits;
|
std::vector<unsigned> Bits;
|
||||||
Init *Value;
|
Init *Value;
|
||||||
bool HasBits;
|
bool HasBits;
|
||||||
SetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
|
LetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
|
||||||
: Name(N), Value(V), HasBits(B != 0) {
|
: Name(N), Value(V), HasBits(B != 0) {
|
||||||
if (HasBits) Bits = *B;
|
if (HasBits) Bits = *B;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<std::vector<SetRecord> > SetStack;
|
static std::vector<std::vector<LetRecord> > LetStack;
|
||||||
|
|
||||||
|
|
||||||
extern std::ostream &err();
|
extern std::ostream &err();
|
||||||
@ -168,7 +168,7 @@ static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
|
|||||||
std::vector<SubClassRefTy> *SubClassList;
|
std::vector<SubClassRefTy> *SubClassList;
|
||||||
};
|
};
|
||||||
|
|
||||||
%token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD SET IN
|
%token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD LET IN
|
||||||
%token <IntVal> INTVAL
|
%token <IntVal> INTVAL
|
||||||
%token <StrVal> ID STRVAL CODEFRAGMENT
|
%token <StrVal> ID STRVAL CODEFRAGMENT
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ Declaration : OptPrefix Type ID OptValue {
|
|||||||
|
|
||||||
BodyItem : Declaration ';' {
|
BodyItem : Declaration ';' {
|
||||||
delete $1;
|
delete $1;
|
||||||
} | SET ID OptBitList '=' Value ';' {
|
} | LET ID OptBitList '=' Value ';' {
|
||||||
setValue(*$2, $3, $5);
|
setValue(*$2, $3, $5);
|
||||||
delete $2;
|
delete $2;
|
||||||
delete $3;
|
delete $3;
|
||||||
@ -399,11 +399,11 @@ ObjectBody : OptID {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process any variables on the set stack...
|
// Process any variables on the set stack...
|
||||||
for (unsigned i = 0, e = SetStack.size(); i != e; ++i)
|
for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
|
||||||
for (unsigned j = 0, e = SetStack[i].size(); j != e; ++j)
|
for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
|
||||||
setValue(SetStack[i][j].Name,
|
setValue(LetStack[i][j].Name,
|
||||||
SetStack[i][j].HasBits ? &SetStack[i][j].Bits : 0,
|
LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
|
||||||
SetStack[i][j].Value);
|
LetStack[i][j].Value);
|
||||||
} Body {
|
} Body {
|
||||||
CurRec->resolveReferences();
|
CurRec->resolveReferences();
|
||||||
|
|
||||||
@ -446,22 +446,22 @@ DefInst : DEF ObjectBody {
|
|||||||
|
|
||||||
Object : ClassInst | DefInst;
|
Object : ClassInst | DefInst;
|
||||||
|
|
||||||
SETItem : ID OptBitList '=' Value {
|
LETItem : ID OptBitList '=' Value {
|
||||||
SetStack.back().push_back(SetRecord(*$1, $2, $4));
|
LetStack.back().push_back(LetRecord(*$1, $2, $4));
|
||||||
delete $1; delete $2;
|
delete $1; delete $2;
|
||||||
};
|
};
|
||||||
|
|
||||||
SETList : SETItem | SETList ',' SETItem;
|
LETList : LETItem | LETList ',' LETItem;
|
||||||
|
|
||||||
// SETCommand - A 'SET' statement start...
|
// LETCommand - A 'LET' statement start...
|
||||||
SETCommand : SET { SetStack.push_back(std::vector<SetRecord>()); } SETList IN;
|
LETCommand : LET { LetStack.push_back(std::vector<LetRecord>()); } LETList IN;
|
||||||
|
|
||||||
// Support Set commands wrapping objects... both with and without braces.
|
// Support Set commands wrapping objects... both with and without braces.
|
||||||
Object : SETCommand '{' ObjectList '}' {
|
Object : LETCommand '{' ObjectList '}' {
|
||||||
SetStack.pop_back();
|
LetStack.pop_back();
|
||||||
}
|
}
|
||||||
| SETCommand Object {
|
| LETCommand Object {
|
||||||
SetStack.pop_back();
|
LetStack.pop_back();
|
||||||
};
|
};
|
||||||
|
|
||||||
ObjectList : Object {} | ObjectList Object {};
|
ObjectList : Object {} | ObjectList Object {};
|
||||||
|
@ -159,7 +159,8 @@ dag { return DAG; }
|
|||||||
class { return CLASS; }
|
class { return CLASS; }
|
||||||
def { return DEF; }
|
def { return DEF; }
|
||||||
field { return FIELD; }
|
field { return FIELD; }
|
||||||
set { return SET; }
|
let { return LET; }
|
||||||
|
set { return LET; }
|
||||||
in { return IN; }
|
in { return IN; }
|
||||||
|
|
||||||
{Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng);
|
{Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng);
|
||||||
|
@ -18,18 +18,18 @@ static Record *CurRec = 0;
|
|||||||
|
|
||||||
typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
|
typedef std::pair<Record*, std::vector<Init*>*> SubClassRefTy;
|
||||||
|
|
||||||
struct SetRecord {
|
struct LetRecord {
|
||||||
std::string Name;
|
std::string Name;
|
||||||
std::vector<unsigned> Bits;
|
std::vector<unsigned> Bits;
|
||||||
Init *Value;
|
Init *Value;
|
||||||
bool HasBits;
|
bool HasBits;
|
||||||
SetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
|
LetRecord(const std::string &N, std::vector<unsigned> *B, Init *V)
|
||||||
: Name(N), Value(V), HasBits(B != 0) {
|
: Name(N), Value(V), HasBits(B != 0) {
|
||||||
if (HasBits) Bits = *B;
|
if (HasBits) Bits = *B;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<std::vector<SetRecord> > SetStack;
|
static std::vector<std::vector<LetRecord> > LetStack;
|
||||||
|
|
||||||
|
|
||||||
extern std::ostream &err();
|
extern std::ostream &err();
|
||||||
@ -168,7 +168,7 @@ static void addSubClass(Record *SC, const std::vector<Init*> &TemplateArgs) {
|
|||||||
std::vector<SubClassRefTy> *SubClassList;
|
std::vector<SubClassRefTy> *SubClassList;
|
||||||
};
|
};
|
||||||
|
|
||||||
%token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD SET IN
|
%token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD LET IN
|
||||||
%token <IntVal> INTVAL
|
%token <IntVal> INTVAL
|
||||||
%token <StrVal> ID STRVAL CODEFRAGMENT
|
%token <StrVal> ID STRVAL CODEFRAGMENT
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ Declaration : OptPrefix Type ID OptValue {
|
|||||||
|
|
||||||
BodyItem : Declaration ';' {
|
BodyItem : Declaration ';' {
|
||||||
delete $1;
|
delete $1;
|
||||||
} | SET ID OptBitList '=' Value ';' {
|
} | LET ID OptBitList '=' Value ';' {
|
||||||
setValue(*$2, $3, $5);
|
setValue(*$2, $3, $5);
|
||||||
delete $2;
|
delete $2;
|
||||||
delete $3;
|
delete $3;
|
||||||
@ -399,11 +399,11 @@ ObjectBody : OptID {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process any variables on the set stack...
|
// Process any variables on the set stack...
|
||||||
for (unsigned i = 0, e = SetStack.size(); i != e; ++i)
|
for (unsigned i = 0, e = LetStack.size(); i != e; ++i)
|
||||||
for (unsigned j = 0, e = SetStack[i].size(); j != e; ++j)
|
for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j)
|
||||||
setValue(SetStack[i][j].Name,
|
setValue(LetStack[i][j].Name,
|
||||||
SetStack[i][j].HasBits ? &SetStack[i][j].Bits : 0,
|
LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0,
|
||||||
SetStack[i][j].Value);
|
LetStack[i][j].Value);
|
||||||
} Body {
|
} Body {
|
||||||
CurRec->resolveReferences();
|
CurRec->resolveReferences();
|
||||||
|
|
||||||
@ -446,22 +446,22 @@ DefInst : DEF ObjectBody {
|
|||||||
|
|
||||||
Object : ClassInst | DefInst;
|
Object : ClassInst | DefInst;
|
||||||
|
|
||||||
SETItem : ID OptBitList '=' Value {
|
LETItem : ID OptBitList '=' Value {
|
||||||
SetStack.back().push_back(SetRecord(*$1, $2, $4));
|
LetStack.back().push_back(LetRecord(*$1, $2, $4));
|
||||||
delete $1; delete $2;
|
delete $1; delete $2;
|
||||||
};
|
};
|
||||||
|
|
||||||
SETList : SETItem | SETList ',' SETItem;
|
LETList : LETItem | LETList ',' LETItem;
|
||||||
|
|
||||||
// SETCommand - A 'SET' statement start...
|
// LETCommand - A 'LET' statement start...
|
||||||
SETCommand : SET { SetStack.push_back(std::vector<SetRecord>()); } SETList IN;
|
LETCommand : LET { LetStack.push_back(std::vector<LetRecord>()); } LETList IN;
|
||||||
|
|
||||||
// Support Set commands wrapping objects... both with and without braces.
|
// Support Set commands wrapping objects... both with and without braces.
|
||||||
Object : SETCommand '{' ObjectList '}' {
|
Object : LETCommand '{' ObjectList '}' {
|
||||||
SetStack.pop_back();
|
LetStack.pop_back();
|
||||||
}
|
}
|
||||||
| SETCommand Object {
|
| LETCommand Object {
|
||||||
SetStack.pop_back();
|
LetStack.pop_back();
|
||||||
};
|
};
|
||||||
|
|
||||||
ObjectList : Object {} | ObjectList Object {};
|
ObjectList : Object {} | ObjectList Object {};
|
||||||
|
Loading…
Reference in New Issue
Block a user