From 42aa89eeb11c2add73211f9cb54c85a9d59bb6ce Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 4 Aug 2003 04:56:53 +0000 Subject: 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 --- utils/TableGen/FileLexer.l | 3 ++- utils/TableGen/FileParser.y | 38 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 20 deletions(-) (limited to 'utils') diff --git a/utils/TableGen/FileLexer.l b/utils/TableGen/FileLexer.l index 8ab400610d..63cb155146 100644 --- a/utils/TableGen/FileLexer.l +++ b/utils/TableGen/FileLexer.l @@ -159,7 +159,8 @@ dag { return DAG; } class { return CLASS; } def { return DEF; } field { return FIELD; } -set { return SET; } +let { return LET; } +set { return LET; } in { return IN; } {Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng); diff --git a/utils/TableGen/FileParser.y b/utils/TableGen/FileParser.y index 0c5b240d30..95dfb42ca9 100644 --- a/utils/TableGen/FileParser.y +++ b/utils/TableGen/FileParser.y @@ -18,18 +18,18 @@ static Record *CurRec = 0; typedef std::pair*> SubClassRefTy; -struct SetRecord { +struct LetRecord { std::string Name; std::vector Bits; Init *Value; bool HasBits; - SetRecord(const std::string &N, std::vector *B, Init *V) + LetRecord(const std::string &N, std::vector *B, Init *V) : Name(N), Value(V), HasBits(B != 0) { if (HasBits) Bits = *B; } }; -static std::vector > SetStack; +static std::vector > LetStack; extern std::ostream &err(); @@ -168,7 +168,7 @@ static void addSubClass(Record *SC, const std::vector &TemplateArgs) { std::vector *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 %token ID STRVAL CODEFRAGMENT @@ -340,7 +340,7 @@ Declaration : OptPrefix Type ID OptValue { BodyItem : Declaration ';' { delete $1; -} | SET ID OptBitList '=' Value ';' { +} | LET ID OptBitList '=' Value ';' { setValue(*$2, $3, $5); delete $2; delete $3; @@ -399,11 +399,11 @@ ObjectBody : OptID { } // Process any variables on the set stack... - for (unsigned i = 0, e = SetStack.size(); i != e; ++i) - for (unsigned j = 0, e = SetStack[i].size(); j != e; ++j) - setValue(SetStack[i][j].Name, - SetStack[i][j].HasBits ? &SetStack[i][j].Bits : 0, - SetStack[i][j].Value); + for (unsigned i = 0, e = LetStack.size(); i != e; ++i) + for (unsigned j = 0, e = LetStack[i].size(); j != e; ++j) + setValue(LetStack[i][j].Name, + LetStack[i][j].HasBits ? &LetStack[i][j].Bits : 0, + LetStack[i][j].Value); } Body { CurRec->resolveReferences(); @@ -446,22 +446,22 @@ DefInst : DEF ObjectBody { Object : ClassInst | DefInst; -SETItem : ID OptBitList '=' Value { - SetStack.back().push_back(SetRecord(*$1, $2, $4)); +LETItem : ID OptBitList '=' Value { + LetStack.back().push_back(LetRecord(*$1, $2, $4)); delete $1; delete $2; }; -SETList : SETItem | SETList ',' SETItem; +LETList : LETItem | LETList ',' LETItem; -// SETCommand - A 'SET' statement start... -SETCommand : SET { SetStack.push_back(std::vector()); } SETList IN; +// LETCommand - A 'LET' statement start... +LETCommand : LET { LetStack.push_back(std::vector()); } LETList IN; // Support Set commands wrapping objects... both with and without braces. -Object : SETCommand '{' ObjectList '}' { - SetStack.pop_back(); +Object : LETCommand '{' ObjectList '}' { + LetStack.pop_back(); } - | SETCommand Object { - SetStack.pop_back(); + | LETCommand Object { + LetStack.pop_back(); }; ObjectList : Object {} | ObjectList Object {}; -- cgit v1.2.3