diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-02 23:22:51 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-02 23:22:51 +0000 |
commit | 446c2394ec8970198d645bbbb462c67b9e3f1b1e (patch) | |
tree | fc85d32c2b68efa80910d0a4ce4c1bed78ec4717 /c_compiler | |
parent | 34d69709e621b9609833a3d6bae31195b425f2f8 (diff) | |
download | Compiler-446c2394ec8970198d645bbbb462c67b9e3f1b1e.tar.gz Compiler-446c2394ec8970198d645bbbb462c67b9e3f1b1e.zip |
Changing ast structure again
Diffstat (limited to 'c_compiler')
102 files changed, 299 insertions, 935 deletions
diff --git a/c_compiler/include/ast.hpp b/c_compiler/include/ast.hpp index 9d51816..bb3e92f 100644 --- a/c_compiler/include/ast.hpp +++ b/c_compiler/include/ast.hpp @@ -1,14 +1,19 @@ #ifndef AST_HPP #define AST_HPP +#include <vector> +#include <string> +#include <iostream> + #include "base.hpp" #include "statement.hpp" #include "function.hpp" #include "declaration.hpp" #include "expression.hpp" #include "primitives.hpp" +#include "external.hpp" #include "ast_top.hpp" -ast_Top *parseAST(); +const BaseList* parseAST(); #endif diff --git a/c_compiler/include/base.hpp b/c_compiler/include/base.hpp index 9451609..ae7cfd7 100644 --- a/c_compiler/include/base.hpp +++ b/c_compiler/include/base.hpp @@ -1,16 +1,138 @@ #ifndef AST_BASE_HPP #define AST_BASE_HPP -#include <string> -#include <iostream> -#include <vector> +#include "ast.hpp" + class Base { public: virtual ~Base() {} virtual void print() const = 0; - virtual void push(const Base* _var) const = 0; + virtual void printxml() const = 0; + virtual void printasm() const = 0; +}; + + +class EmptyNode : public Base { +public: + EmptyNode() {} + + virtual void print() const {} + virtual void printxml() const {} + virtual void printasm() const {} +}; + + +class BaseList : public Base { +protected: + mutable std::vector<const Base*> list; + +public: + BaseList() {} + BaseList(const Base* _var) { + push(_var); + } + + virtual ~BaseList() { + for(auto& var : list) { + delete var; + } + } + + virtual void print() const { + for(auto&& declaration : list) { + declaration->print(); + } + } + + virtual void printxml() const { + for(auto&& declaration : list) { + declaration->printxml(); + } + } + + virtual void printasm() const { + for(auto&& declaration : list) { + declaration->printasm(); + } + } + + virtual void push(const Base* _var) const { + list.push_back(_var); + } +}; + + +class BaseNode : public Base { +protected: + const Base* leftNode; + const Base* rightNode; + +public: + BaseNode(const Base* _left = new EmptyNode, const Base* _right = new EmptyNode) + : leftNode(_left), rightNode(_right) {} + + virtual ~BaseNode() { + delete leftNode; + delete rightNode; + } + + virtual void print() const { + leftNode->print(); + rightNode->print(); + } + + virtual void printxml() const { + leftNode->printxml(); + rightNode->printxml(); + } + + virtual void printasm() const { + leftNode->printasm(); + rightNode->printasm(); + } + + virtual const Base* getLeft() const { + return leftNode; + } + + virtual const Base* getRight() const { + return rightNode; + } +}; + + +class BasePrimitive : public Base { +protected: + std::string id; + const Base* type; + +public: + BasePrimitive(const std::string& _id) + : id(_id), type(new EmptyNode) {} + + BasePrimitive(const std::string& _id, const Base* _type) + : id(_id), type(_type) {} + + virtual ~BasePrimitive() { + delete type; + } + + virtual void print() const {} + virtual void printxml() const {} + virtual void printasm() const {} +}; + + +class BaseType : public Base { +public: + BaseType() {} + + virtual void print() const {} + virtual void printxml() const {} + virtual void printasm() const {} }; + #endif diff --git a/c_compiler/include/declaration.hpp b/c_compiler/include/declaration.hpp index bfd3070..bf72f2d 100644 --- a/c_compiler/include/declaration.hpp +++ b/c_compiler/include/declaration.hpp @@ -3,48 +3,21 @@ #include "ast.hpp" -#include <vector> - // Declaration that holds a list of declarations -class DeclarationList : public Base { -private: - mutable std::vector<const Base*> dec_list; - +class Declaration : public BaseNode { public: - DeclarationList(const Base* _dec) { - dec_list.push_back(_dec); - } - - virtual void print() const { - for(size_t i = 0; i < dec_list.size(); ++i) { - dec_list[i]->print(); - } - } - - virtual void push(const Base* _dec) const { - dec_list.push_back(_dec); - } + Declaration(const Base* _var) : BaseNode(_var) {} }; -class VariableDeclaration : public Base { -private: - mutable std::vector<const Base*> var_list; - +class DeclarationList : public BaseList { public: - VariableDeclaration(const Base* _var) { - var_list.push_back(_var); - } - - virtual void print() const { - for(size_t i = 0; i < var_list.size(); ++i) { - var_list[i]->print(); - } - } + DeclarationList(const Base* _var) : BaseList(_var) {} +}; - virtual void push(const Base* _var) const { - var_list.push_back(_var); - } +class InitDeclaratorList : public BaseList { +public: + InitDeclaratorList(const Base* _var) : BaseList(_var) {} }; #endif diff --git a/c_compiler/include/expression.hpp b/c_compiler/include/expression.hpp index f67d2d7..9eb9efd 100644 --- a/c_compiler/include/expression.hpp +++ b/c_compiler/include/expression.hpp @@ -3,22 +3,14 @@ #include "ast.hpp" -#include <string> -#include <iostream> - -class Expression : public Base { +class Expression : public BaseNode { private: public: - Expression() {} - - virtual void print() const { - - } + Expression() : BaseNode() {} - virtual void push(const Base* _base) const { - std::cerr << "Can't call this function for this type" << std::endl; - (void)_base; - } + virtual void print() const override {} + virtual void printxml() const override {} + virtual void printasm() const override {} }; #endif diff --git a/c_compiler/include/external.hpp b/c_compiler/include/external.hpp new file mode 100644 index 0000000..866e18a --- /dev/null +++ b/c_compiler/include/external.hpp @@ -0,0 +1,13 @@ +#ifndef EXTERNAL_HPP +#define EXTERNAL_HPP + +#include "ast.hpp" + + +class ExternalDefinition : public BaseList { +public: + ExternalDefinition(const Base* _var) : BaseList(_var) {} +}; + + +#endif diff --git a/c_compiler/include/function.hpp b/c_compiler/include/function.hpp index 6fbcdee..955420d 100644 --- a/c_compiler/include/function.hpp +++ b/c_compiler/include/function.hpp @@ -3,51 +3,29 @@ #include "ast.hpp" -#include <string> -#include <iostream> -class Function : public Base { -private: +class Function : public BaseNode { +protected: std::string id; - const Base* param; - const Base* comp_statement; + public: - Function(const std::string& _id, const Base* _param, const Base* _comp_statement) : - id(_id), param(_param), comp_statement(_comp_statement) {} + Function(const std::string& _id, const BaseList* _param_list, const BaseNode* _comp_statement) + : BaseNode(_param_list, _comp_statement), id(_id) {} - virtual void print() const { + virtual void printxml() const override { std::cout << "<Function id=\"" << id << "\">" << std::endl; - param->print(); - comp_statement->print(); + leftNode->printxml(); + rightNode->printxml(); std::cout << "</Function>" << std::endl; } - - virtual void push(const Base* var) const { - std::cerr << "Error: Can't call this function on this class" << std::endl; - (void)var; - } }; -class ParamList : public Base { -private: - mutable std::vector<const Base*> param_list; +class ParamList : public BaseList { public: - ParamList() {} - - ParamList(const Base* param) { - param_list.push_back(param); - } - - virtual void print() const { - for(size_t i = 0; i < param_list.size(); ++i) { - param_list[i]->print(); - } - } - - virtual void push(const Base* _var) const { - param_list.push_back(_var); - } + ParamList() : BaseList() {} + ParamList(const Base* _param) : BaseList(_param) {} }; + #endif diff --git a/c_compiler/include/primitives.hpp b/c_compiler/include/primitives.hpp index 2eeaa19..f4c5087 100644 --- a/c_compiler/include/primitives.hpp +++ b/c_compiler/include/primitives.hpp @@ -3,38 +3,25 @@ #include "ast.hpp" -#include <string> -class Variable : public Base { -private: - std::string id; +class Declarator : public BasePrimitive { public: - Variable(const std::string& _id) : id(_id) {} + Declarator(const std::string& _id) : BasePrimitive(_id) {} - virtual void print() const { - std::cout << "<Variable id=\"" << id << "\" />" << std::endl; - } - - virtual void push(const Base* var) const { - std::cerr << "Error: Can't call this function on this class" << std::endl; - (void)var; + virtual void printxml() const { + std::cout << "<Variable id=\"" << id << "\" />" << std::endl; } }; -class Parameter : public Base { -private: - std::string id; + +class Parameter : public BasePrimitive { public: - Parameter(const std::string& _id) : id(_id) {} + Parameter(const std::string& _id) : BasePrimitive(_id) {} - virtual void print() const { + virtual void printxml() const { std::cout << "<Parameter id=\"" << id << "\" />" << std::endl; } - - virtual void push(const Base* var) const { - std::cerr << "Error: Can't call this function on this class" << std::endl; - (void)var; - } }; + #endif diff --git a/c_compiler/include/statement.hpp b/c_compiler/include/statement.hpp index 4761efb..451d368 100644 --- a/c_compiler/include/statement.hpp +++ b/c_compiler/include/statement.hpp @@ -3,49 +3,33 @@ #include "ast.hpp" -class Statement : public Base { -protected: - mutable std::vector<const Base*> list; - + +class Statement : public BaseNode { public: - Statement() {} + Statement() : BaseNode() {} - Statement(const Base* _el) { - list.push_back(_el); - } - - Statement(const Base* _dec, const Base* _statement) { - list.push_back(_dec); - list.push_back(_statement); - } - virtual void print() const { - for(size_t i = 0; i < list.size(); ++i) { - list[i]->print(); - } - } - - virtual void push(const Base* _var) const { - list.push_back(_var); - } + Statement(const Base* _el) : BaseNode(_el) {} }; -class StatementList : public Statement { +class StatementList : public BaseList { public: - StatementList(const Base* _statement) : Statement(_statement) {} + StatementList(const Base* _statement) : BaseList(_statement) {} }; class CompoundStatement : public Statement { public: CompoundStatement() : Statement() {} CompoundStatement(const Base* _el) : Statement(_el) {} - CompoundStatement(const Base* _dec, const Base* _statement) : - Statement(_dec, _statement) {} + + CompoundStatement(const Base* _dec, const Base* _statement) { + leftNode = _dec; + rightNode = _statement; + } - virtual void print() const override { + virtual void printxml() const override { std::cout << "<Scope>" << std::endl; - for(size_t i = 0; i < list.size(); ++i) { - list[i]->print(); - } + leftNode->printxml(); + rightNode->printxml(); std::cout << "</Scope>" << std::endl; } }; @@ -54,14 +38,17 @@ class SelectionStatement : public Statement { public: SelectionStatement() : Statement() {} SelectionStatement(const Base* _el) : Statement(_el) {} - SelectionStatement(const Base* _if, const Base* _else) : - Statement(_if, _else) {} + + SelectionStatement(const Base* _if, const Base* _else) { + leftNode = _if; + rightNode = _else; + } }; class ExpressionStatement : public Statement { public: ExpressionStatement() : Statement() {} - ExpressionStatement(const Base* _el) : Statement(_el) {} + ExpressionStatement(const Base* expr) : Statement(expr) {} }; class JumpStatement : public Statement { @@ -74,8 +61,6 @@ class IterationStatement : public Statement { public: IterationStatement() : Statement() {} IterationStatement(const Base* _el) : Statement(_el) {} - IterationStatement(const Base* _if, const Base* _else) : - Statement(_if, _else) {} }; #endif diff --git a/c_compiler/src/c_parser.y b/c_compiler/src/c_parser.y index 1fc4d4a..2f9f1b8 100644 --- a/c_compiler/src/c_parser.y +++ b/c_compiler/src/c_parser.y @@ -1,7 +1,8 @@ %code requires{ #include "ast.hpp" -extern ast_Top *g_root; // A way of getting the AST out + +extern const BaseList* g_root; // A way of getting the AST out //! This is to fix problems when generating C++ // We are declaring the functions provided by Flex, so @@ -14,48 +15,57 @@ void yyerror(const char *); // Represents the value associated with any kind of // AST node. %union{ - const Base *stmnt; + const BaseNode* base_node; + const BaseList* base_list; + const BasePrimitive* base_prim; + const BaseType* base_type; double number; std::string *string; } -%token T_TYPE_SPEC T_TYPE_QUAL T_STRG_SPEC T_IDENTIFIER -%token T_SC T_CMA T_LRB T_LCB T_RCB T_LSB T_RSB T_QU T_COL T_LOG_OR T_LOG_AND T_OR T_XOR T_AND T_EQUALITY_OP T_REL_OP T_SHIFT_OP T_MULT T_DIV T_REM T_TILDE T_NOT T_DOT T_ARROW T_INCDEC T_ADDSUB_OP T_ASSIGN_OPER T_EQ T_SIZEOF -%token T_INT_CONST -%token T_IF T_WHILE T_DO T_FOR T_RETURN -%nonassoc T_RRB -%nonassoc T_ELSE +%token T_TYPE_SPEC T_TYPE_QUAL T_STRG_SPEC T_IDENTIFIER T_SC T_CMA T_LRB T_LCB T_RCB + T_LSB T_RSB T_QU T_COL T_LOG_OR T_LOG_AND T_OR T_XOR T_AND T_EQUALITY_OP + T_REL_OP T_SHIFT_OP T_MULT T_DIV T_REM T_TILDE T_NOT T_DOT T_ARROW T_INCDEC + T_ADDSUB_OP T_ASSIGN_OPER T_EQ T_SIZEOF T_INT_CONST T_IF T_WHILE T_DO T_FOR + T_RETURN - -%type <stmnt> ExtDef ExtDeclaration - -%type <stmnt> FuncDef ParameterList Parameter ParamDeclarator - -%type <stmnt> DeclarationList Declaration DeclarationSpec DeclarationSpec_T InitDeclarator InitDeclaratorList Declarator +%nonassoc T_RRB +%nonassoc T_ELSE -%type <stmnt> StatementList Statement CompoundStatement CompoundStatement_2 SelectionStatement ExpressionStatement JumpStatement IterationStatement + +%type <base_list> ExtDef ParameterList DeclarationList InitDeclaratorList IdentifierList + StatementList ArgumentExpressionList + +%type <base_node> ExtDeclaration FuncDef Declaration DeclarationSpec DeclarationSpec_T + InitDeclarator Statement CompoundStatement CompoundStatement_2 + SelectionStatement ExpressionStatement JumpStatement IterationStatement + Expression AssignmentExpression ConditionalExpression LogicalOrExpression + LogicalAndExpression InclusiveOrExpression ExclusiveOrExpression + AndExpression EqualityExpression RelationalExpression ShiftExpression + AdditiveExpression MultiplicativeExpression CastExpression UnaryExpression + PostfixExpression PostfixExpression2 PrimaryExpression -%type <stmnt> Expression AssignmentExpression ConditionalExpression LogicalOrExpression LogicalAndExpression InclusiveOrExpression ExclusiveOrExpression AndExpression EqualityExpression RelationalExpression ShiftExpression AdditiveExpression MultiplicativeExpression CastExpression UnaryExpression PostfixExpression PostfixExpression2 ArgumentExpressionList PrimaryExpression - +%type <base_prim> Parameter ParamDeclarator Declarator DirectDeclarator -%type <number> Constant T_INT_CONST +%type <number> T_INT_CONST Constant -%type <string> T_IDENTIFIER MultDivRemOP UnaryOperator ASSIGN_OPER T_ASSIGN_OPER T_EQ T_AND T_ADDSUB_OP T_TILDE T_NOT T_MULT T_DIV T_REM //T_Operator +%type <string> T_IDENTIFIER ASSIGN_OPER T_ASSIGN_OPER T_EQ T_AND T_ADDSUB_OP T_TILDE T_NOT + T_MULT T_DIV T_REM MultDivRemOP UnaryOperator %start ROOT %% ROOT: - ExtDef { ; } + ExtDef { g_root = $1; } ; // EXTERNAL DEFINITION ExtDef: - ExtDeclaration { g_root->push($1); } - | ExtDef ExtDeclaration { g_root->push($2); } + ExtDeclaration { $$ = new ExternalDefinition($1); } + | ExtDef ExtDeclaration { $$->push($2); } ; ExtDeclaration: @@ -91,7 +101,7 @@ DeclarationList: ; Declaration: - DeclarationSpec InitDeclaratorList T_SC { $$ = $2; } + DeclarationSpec InitDeclaratorList T_SC { $$ = new Declaration($2); } ; DeclarationSpec: @@ -106,17 +116,32 @@ DeclarationSpec_T: ; InitDeclaratorList: - InitDeclarator { $$ = new VariableDeclaration($1); } + InitDeclarator { $$ = new InitDeclaratorList($1); } | InitDeclaratorList T_CMA InitDeclarator { $$->push($3); } ; InitDeclarator: - Declarator { ; } - | Declarator T_EQ AssignmentExpression { ; } + Declarator { $$ = $1; } + | Declarator T_EQ AssignmentExpression { $$ = $1; } ; Declarator: - T_IDENTIFIER {$$ = new Variable(*$1); } + DirectDeclarator { $$ = $1; } + | T_MULT DirectDeclarator { $$ = $2; } + ; + +DirectDeclarator: + T_IDENTIFIER { $$ = new Declarator(*$1); } + | T_LRB Declarator T_RRB { $$ = $2; } + | DirectDeclarator T_LSB ConditionalExpression T_RSB { $$ = $1; } + | DirectDeclarator T_LSB T_RSB { $$ = $1; } + | DirectDeclarator T_LRB ParameterList T_RRB { $$ = $1; } + | DirectDeclarator T_LRB IdentifierList T_RRB { $$ = $1; } + ; + +IdentifierList: + T_IDENTIFIER { $$ = new Declarator(*$1); } + | IdentifierList T_CMA T_IDENTIFIER { $$ = new Declarator(*$3); } ; // Statement @@ -147,7 +172,7 @@ CompoundStatement_2: SelectionStatement: T_IF T_LRB Expression T_RRB Statement { $$ = new SelectionStatement($5); } -| T_IF T_LRB Expression T_RRB Statement T_ELSE Statement { $$ = new SelectionStatement($5, $7); } + | T_IF T_LRB Expression T_RRB Statement T_ELSE Statement { $$ = new SelectionStatement($5, $7); } ; ExpressionStatement: @@ -294,10 +319,10 @@ Constant: %% -ast_Top *g_root; // Definition of variable (to match declaration earlier) +const BaseList* g_root; // Definition of variable (to match declaration earlier) -ast_Top *parseAST() { - g_root = new ast_Top; +const BaseList* parseAST() { + g_root = NULL; yyparse(); return g_root; } diff --git a/c_compiler/src/parser_main.cpp b/c_compiler/src/parser_main.cpp index 02dcfeb..8922417 100644 --- a/c_compiler/src/parser_main.cpp +++ b/c_compiler/src/parser_main.cpp @@ -3,7 +3,7 @@ #include <iostream> int main(int argc, char *argv[]) { - ast_Top *ast = parseAST(); + const Base *ast = parseAST(); ast->print(); diff --git a/c_compiler/test/in/01.c b/c_compiler/test/in/01.c index 76425b5..c362948 100644 --- a/c_compiler/test/in/01.c +++ b/c_compiler/test/in/01.c @@ -1,6 +1,3 @@ -int a; -int b = 0; -int c, d; - -int e, - f; +int main() { + return 13; +} diff --git a/c_compiler/test/in/02.c b/c_compiler/test/in/02.c deleted file mode 100644 index 45b1467..0000000 --- a/c_compiler/test/in/02.c +++ /dev/null @@ -1 +0,0 @@ -int f() {} diff --git a/c_compiler/test/in/03.c b/c_compiler/test/in/03.c deleted file mode 100644 index e57aaa9..0000000 --- a/c_compiler/test/in/03.c +++ /dev/null @@ -1 +0,0 @@ -int foo(int bar) {} diff --git a/c_compiler/test/in/04.c b/c_compiler/test/in/04.c deleted file mode 100644 index 2e3aa5d..0000000 --- a/c_compiler/test/in/04.c +++ /dev/null @@ -1,4 +0,0 @@ -int foo(int bar1, int bar2) { - int x; - int y, z; -} diff --git a/c_compiler/test/in/05.c b/c_compiler/test/in/05.c deleted file mode 100644 index 2317163..0000000 --- a/c_compiler/test/in/05.c +++ /dev/null @@ -1,3 +0,0 @@ -int foo(int x, int y) { - {} -} diff --git a/c_compiler/test/in/06.c b/c_compiler/test/in/06.c deleted file mode 100644 index 2dcdc2b..0000000 --- a/c_compiler/test/in/06.c +++ /dev/null @@ -1,6 +0,0 @@ -int f(int a, int b, int c) { - int d; - { - int e; - } -} diff --git a/c_compiler/test/in/07.c b/c_compiler/test/in/07.c deleted file mode 100644 index 80d8051..0000000 --- a/c_compiler/test/in/07.c +++ /dev/null @@ -1,5 +0,0 @@ -int foo(int a) { - if(x == y) { - int z; - } -} diff --git a/c_compiler/test/in/08.c b/c_compiler/test/in/08.c deleted file mode 100644 index c57a6ab..0000000 --- a/c_compiler/test/in/08.c +++ /dev/null @@ -1,10 +0,0 @@ -int func(int a, int b) { - int c = 0; - if(a == b) { - int d; - } else if(a == d) { - int e; - return d; - } - return c; -} diff --git a/c_compiler/test/in/09.c b/c_compiler/test/in/09.c deleted file mode 100644 index ae86bb1..0000000 --- a/c_compiler/test/in/09.c +++ /dev/null @@ -1,15 +0,0 @@ -int x() -{} - -int g; - -int zz(int a, int b, int c) -{ - if(a==b){ - int a; - return a; - }else{ - int fsdfsdfs; - return c; - } -} diff --git a/c_compiler/test/in/10.c b/c_compiler/test/in/10.c deleted file mode 100644 index 37a6ecc..0000000 --- a/c_compiler/test/in/10.c +++ /dev/null @@ -1,18 +0,0 @@ -int f() -{} - -int g = 2; - -int x(int y) { - int z = 3; - - if(y < z || g < z) { - int r; - ++y; - } else if(y == z) { - int f; - --y; - } else return y; - - return g; -} diff --git a/c_compiler/test/in/11.c b/c_compiler/test/in/11.c deleted file mode 100644 index 2d8cac6..0000000 --- a/c_compiler/test/in/11.c +++ /dev/null @@ -1,10 +0,0 @@ -int f() { - int x = 0; - - while(x < 5) { - int y = 0; - x++; - } - - return x; -} diff --git a/c_compiler/test/in/12.c b/c_compiler/test/in/12.c deleted file mode 100644 index 37b8b7e..0000000 --- a/c_compiler/test/in/12.c +++ /dev/null @@ -1,4 +0,0 @@ -int f(int b, int c) { - int a = b+c; - return a; -} diff --git a/c_compiler/test/in/13.c b/c_compiler/test/in/13.c deleted file mode 100644 index d912d70..0000000 --- a/c_compiler/test/in/13.c +++ /dev/null @@ -1,8 +0,0 @@ -int func(int x, int y) { - int i; - for(i = 0; i < 5; ++i) { - int z = 0; - z = x + y + i; - return x + y; - } -} diff --git a/c_compiler/test/in/14.c b/c_compiler/test/in/14.c deleted file mode 100644 index 94506d7..0000000 --- a/c_compiler/test/in/14.c +++ /dev/null @@ -1,12 +0,0 @@ -int function_1(int a, int b) { - int x = 0; - - do { - int c = a + b; - x += a; - x = x * b; - x -= c; - } while(x < 500); - - return x; -} diff --git a/c_compiler/test/in/15.c b/c_compiler/test/in/15.c deleted file mode 100644 index 3189b56..0000000 --- a/c_compiler/test/in/15.c +++ /dev/null @@ -1,28 +0,0 @@ -int add(int a, int b) -{ - int c = a + b; - return c; -} - -int sub(int a, int b) -{ - int c = a - b; - return c; -} - -int mult_by_5(int a) -{ - int b = 5; - return a * b; -} - -int add_5(int a) -{ - int i; - for(i = 0; i < 5; ++i) - { - int b = ++a; - } - - return a; -} diff --git a/c_compiler/test/out/01.pretty.xml b/c_compiler/test/out/01.pretty.xml index e0545e4..8b13789 100644 --- a/c_compiler/test/out/01.pretty.xml +++ b/c_compiler/test/out/01.pretty.xml @@ -1,9 +1 @@ -<?xml version="1.0"?> -<Program> - <Variable id="a" /> - <Variable id="b" /> - <Variable id="c" /> - <Variable id="d" /> - <Variable id="e" /> - <Variable id="f" /> -</Program> + diff --git a/c_compiler/test/out/01.stderr.txt b/c_compiler/test/out/01.stderr.txt index e69de29..37006dc 100644 --- a/c_compiler/test/out/01.stderr.txt +++ b/c_compiler/test/out/01.stderr.txt @@ -0,0 +1 @@ +./test_compiler.sh: line 28: ./bin/c_compiler: No such file or directory diff --git a/c_compiler/test/out/02.diff.txt b/c_compiler/test/out/01.stdout.s index e69de29..e69de29 100644 --- a/c_compiler/test/out/02.diff.txt +++ b/c_compiler/test/out/01.stdout.s diff --git a/c_compiler/test/out/01.stdout.txt b/c_compiler/test/out/01.stdout.txt deleted file mode 100644 index bd7cd1f..0000000 --- a/c_compiler/test/out/01.stdout.txt +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Variable id="a" /> -<Variable id="b" /> -<Variable id="c" /> -<Variable id="d" /> -<Variable id="e" /> -<Variable id="f" /> -</Program> diff --git a/c_compiler/test/out/01.stdout.xml b/c_compiler/test/out/01.stdout.xml index bd7cd1f..e69de29 100644 --- a/c_compiler/test/out/01.stdout.xml +++ b/c_compiler/test/out/01.stdout.xml @@ -1,9 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Variable id="a" /> -<Variable id="b" /> -<Variable id="c" /> -<Variable id="d" /> -<Variable id="e" /> -<Variable id="f" /> -</Program> diff --git a/c_compiler/test/out/02.pretty.xml b/c_compiler/test/out/02.pretty.xml deleted file mode 100644 index 1f73bca..0000000 --- a/c_compiler/test/out/02.pretty.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="f"> - <Scope></Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/02.stderr.txt b/c_compiler/test/out/02.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/02.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/02.stdout.xml b/c_compiler/test/out/02.stdout.xml deleted file mode 100644 index bc37d7a..0000000 --- a/c_compiler/test/out/02.stdout.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="f"> -<Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/03.diff.txt b/c_compiler/test/out/03.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/03.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/03.pretty.xml b/c_compiler/test/out/03.pretty.xml deleted file mode 100644 index 6ab6ab3..0000000 --- a/c_compiler/test/out/03.pretty.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="foo"> - <Parameter id="bar" /> - <Scope></Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/03.stderr.txt b/c_compiler/test/out/03.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/03.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/03.stdout.xml b/c_compiler/test/out/03.stdout.xml deleted file mode 100644 index 6ca0ab2..0000000 --- a/c_compiler/test/out/03.stdout.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="foo"> -<Parameter id="bar" /> -<Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/04.diff.txt b/c_compiler/test/out/04.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/04.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/04.pretty.xml b/c_compiler/test/out/04.pretty.xml deleted file mode 100644 index caae53b..0000000 --- a/c_compiler/test/out/04.pretty.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="foo"> - <Parameter id="bar1" /> - <Parameter id="bar2" /> - <Scope> - <Variable id="x" /> - <Variable id="y" /> - <Variable id="z" /> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/04.stderr.txt b/c_compiler/test/out/04.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/04.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/04.stdout.xml b/c_compiler/test/out/04.stdout.xml deleted file mode 100644 index 9257eac..0000000 --- a/c_compiler/test/out/04.stdout.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="foo"> -<Parameter id="bar1" /> -<Parameter id="bar2" /> -<Scope> -<Variable id="x" /> -<Variable id="y" /> -<Variable id="z" /> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/05.diff.txt b/c_compiler/test/out/05.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/05.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/05.pretty.xml b/c_compiler/test/out/05.pretty.xml deleted file mode 100644 index 944d950..0000000 --- a/c_compiler/test/out/05.pretty.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="foo"> - <Parameter id="x" /> - <Parameter id="y" /> - <Scope> - <Scope></Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/05.stderr.txt b/c_compiler/test/out/05.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/05.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/05.stdout.xml b/c_compiler/test/out/05.stdout.xml deleted file mode 100644 index 7381e51..0000000 --- a/c_compiler/test/out/05.stdout.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="foo"> -<Parameter id="x" /> -<Parameter id="y" /> -<Scope> -<Scope> -</Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/06.diff.txt b/c_compiler/test/out/06.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/06.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/06.pretty.xml b/c_compiler/test/out/06.pretty.xml deleted file mode 100644 index 6422001..0000000 --- a/c_compiler/test/out/06.pretty.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="f"> - <Parameter id="a" /> - <Parameter id="b" /> - <Parameter id="c" /> - <Scope> - <Variable id="d" /> - <Scope> - <Variable id="e" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/06.stderr.txt b/c_compiler/test/out/06.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/06.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/06.stdout.xml b/c_compiler/test/out/06.stdout.xml deleted file mode 100644 index fbcbebd..0000000 --- a/c_compiler/test/out/06.stdout.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="f"> -<Parameter id="a" /> -<Parameter id="b" /> -<Parameter id="c" /> -<Scope> -<Variable id="d" /> -<Scope> -<Variable id="e" /> -</Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/07.diff.txt b/c_compiler/test/out/07.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/07.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/07.pretty.xml b/c_compiler/test/out/07.pretty.xml deleted file mode 100644 index 11c3b77..0000000 --- a/c_compiler/test/out/07.pretty.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="foo"> - <Parameter id="a" /> - <Scope> - <Scope> - <Variable id="z" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/07.stderr.txt b/c_compiler/test/out/07.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/07.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/07.stdout.xml b/c_compiler/test/out/07.stdout.xml deleted file mode 100644 index ff0efb2..0000000 --- a/c_compiler/test/out/07.stdout.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="foo"> -<Parameter id="a" /> -<Scope> -<Scope> -<Variable id="z" /> -</Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/08.diff.txt b/c_compiler/test/out/08.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/08.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/08.pretty.xml b/c_compiler/test/out/08.pretty.xml deleted file mode 100644 index 6cf0f8e..0000000 --- a/c_compiler/test/out/08.pretty.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="func"> - <Parameter id="a" /> - <Parameter id="b" /> - <Scope> - <Variable id="c" /> - <Scope> - <Variable id="d" /> - </Scope> - <Scope> - <Variable id="e" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/08.stderr.txt b/c_compiler/test/out/08.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/08.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/08.stdout.xml b/c_compiler/test/out/08.stdout.xml deleted file mode 100644 index 7929e75..0000000 --- a/c_compiler/test/out/08.stdout.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="func"> -<Parameter id="a" /> -<Parameter id="b" /> -<Scope> -<Variable id="c" /> -<Scope> -<Variable id="d" /> -</Scope> -<Scope> -<Variable id="e" /> -</Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/09.diff.txt b/c_compiler/test/out/09.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/09.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/09.pretty.xml b/c_compiler/test/out/09.pretty.xml deleted file mode 100644 index 6c137df..0000000 --- a/c_compiler/test/out/09.pretty.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="x"> - <Scope></Scope> - </Function> - <Variable id="g" /> - <Function id="zz"> - <Parameter id="a" /> - <Parameter id="b" /> - <Parameter id="c" /> - <Scope> - <Scope> - <Variable id="a" /> - </Scope> - <Scope> - <Variable id="fsdfsdfs" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/09.stderr.txt b/c_compiler/test/out/09.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/09.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/09.stdout.xml b/c_compiler/test/out/09.stdout.xml deleted file mode 100644 index 7a7a770..0000000 --- a/c_compiler/test/out/09.stdout.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="x"> -<Scope> -</Scope> -</Function> -<Variable id="g" /> -<Function id="zz"> -<Parameter id="a" /> -<Parameter id="b" /> -<Parameter id="c" /> -<Scope> -<Scope> -<Variable id="a" /> -</Scope> -<Scope> -<Variable id="fsdfsdfs" /> -</Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/10.diff.txt b/c_compiler/test/out/10.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/10.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/10.pretty.xml b/c_compiler/test/out/10.pretty.xml deleted file mode 100644 index 89a6292..0000000 --- a/c_compiler/test/out/10.pretty.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="f"> - <Scope></Scope> - </Function> - <Variable id="g" /> - <Function id="x"> - <Parameter id="y" /> - <Scope> - <Variable id="z" /> - <Scope> - <Variable id="r" /> - </Scope> - <Scope> - <Variable id="f" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/10.stderr.txt b/c_compiler/test/out/10.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/10.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/10.stdout.xml b/c_compiler/test/out/10.stdout.xml deleted file mode 100644 index b07997e..0000000 --- a/c_compiler/test/out/10.stdout.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="f"> -<Scope> -</Scope> -</Function> -<Variable id="g" /> -<Function id="x"> -<Parameter id="y" /> -<Scope> -<Variable id="z" /> -<Scope> -<Variable id="r" /> -</Scope> -<Scope> -<Variable id="f" /> -</Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/11.diff.txt b/c_compiler/test/out/11.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/11.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/11.pretty.xml b/c_compiler/test/out/11.pretty.xml deleted file mode 100644 index b9779d7..0000000 --- a/c_compiler/test/out/11.pretty.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="f"> - <Scope> - <Variable id="x" /> - <Scope> - <Variable id="y" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/11.stderr.txt b/c_compiler/test/out/11.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/11.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/11.stdout.xml b/c_compiler/test/out/11.stdout.xml deleted file mode 100644 index 0822742..0000000 --- a/c_compiler/test/out/11.stdout.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="f"> -<Scope> -<Variable id="x" /> -<Scope> -<Variable id="y" /> -</Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/12.diff.txt b/c_compiler/test/out/12.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/12.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/12.pretty.xml b/c_compiler/test/out/12.pretty.xml deleted file mode 100644 index 9f49265..0000000 --- a/c_compiler/test/out/12.pretty.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="f"> - <Parameter id="b" /> - <Parameter id="c" /> - <Scope> - <Variable id="a" /> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/12.stderr.txt b/c_compiler/test/out/12.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/12.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/12.stdout.xml b/c_compiler/test/out/12.stdout.xml deleted file mode 100644 index 471f225..0000000 --- a/c_compiler/test/out/12.stdout.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="f"> -<Parameter id="b" /> -<Parameter id="c" /> -<Scope> -<Variable id="a" /> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/13.diff.txt b/c_compiler/test/out/13.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/13.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/13.pretty.xml b/c_compiler/test/out/13.pretty.xml deleted file mode 100644 index a604ecd..0000000 --- a/c_compiler/test/out/13.pretty.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="func"> - <Parameter id="x" /> - <Parameter id="y" /> - <Scope> - <Variable id="i" /> - <Scope> - <Variable id="z" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/13.stderr.txt b/c_compiler/test/out/13.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/13.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/13.stdout.xml b/c_compiler/test/out/13.stdout.xml deleted file mode 100644 index 511d93b..0000000 --- a/c_compiler/test/out/13.stdout.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="func"> -<Parameter id="x" /> -<Parameter id="y" /> -<Scope> -<Variable id="i" /> -<Scope> -<Variable id="z" /> -</Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/14.diff.txt b/c_compiler/test/out/14.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/14.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/14.pretty.xml b/c_compiler/test/out/14.pretty.xml deleted file mode 100644 index 866d44e..0000000 --- a/c_compiler/test/out/14.pretty.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="function_1"> - <Parameter id="a" /> - <Parameter id="b" /> - <Scope> - <Variable id="x" /> - <Scope> - <Variable id="c" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/14.stderr.txt b/c_compiler/test/out/14.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/14.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/14.stdout.xml b/c_compiler/test/out/14.stdout.xml deleted file mode 100644 index 1b412d3..0000000 --- a/c_compiler/test/out/14.stdout.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="function_1"> -<Parameter id="a" /> -<Parameter id="b" /> -<Scope> -<Variable id="x" /> -<Scope> -<Variable id="c" /> -</Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/out/15.diff.txt b/c_compiler/test/out/15.diff.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/15.diff.txt +++ /dev/null diff --git a/c_compiler/test/out/15.pretty.xml b/c_compiler/test/out/15.pretty.xml deleted file mode 100644 index b06dde0..0000000 --- a/c_compiler/test/out/15.pretty.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="add"> - <Parameter id="a" /> - <Parameter id="b" /> - <Scope> - <Variable id="c" /> - </Scope> - </Function> - <Function id="sub"> - <Parameter id="a" /> - <Parameter id="b" /> - <Scope> - <Variable id="c" /> - </Scope> - </Function> - <Function id="mult_by_5"> - <Parameter id="a" /> - <Scope> - <Variable id="b" /> - </Scope> - </Function> - <Function id="add_5"> - <Parameter id="a" /> - <Scope> - <Variable id="i" /> - <Scope> - <Variable id="b" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/out/15.stderr.txt b/c_compiler/test/out/15.stderr.txt deleted file mode 100644 index e69de29..0000000 --- a/c_compiler/test/out/15.stderr.txt +++ /dev/null diff --git a/c_compiler/test/out/15.stdout.xml b/c_compiler/test/out/15.stdout.xml deleted file mode 100644 index d4c29b2..0000000 --- a/c_compiler/test/out/15.stdout.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> -<Program> -<Function id="add"> -<Parameter id="a" /> -<Parameter id="b" /> -<Scope> -<Variable id="c" /> -</Scope> -</Function> -<Function id="sub"> -<Parameter id="a" /> -<Parameter id="b" /> -<Scope> -<Variable id="c" /> -</Scope> -</Function> -<Function id="mult_by_5"> -<Parameter id="a" /> -<Scope> -<Variable id="b" /> -</Scope> -</Function> -<Function id="add_5"> -<Parameter id="a" /> -<Scope> -<Variable id="i" /> -<Scope> -<Variable id="b" /> -</Scope> -</Scope> -</Function> -</Program> diff --git a/c_compiler/test/ref/01 b/c_compiler/test/ref/01 Binary files differnew file mode 100755 index 0000000..9655601 --- /dev/null +++ b/c_compiler/test/ref/01 diff --git a/c_compiler/test/ref/01.s b/c_compiler/test/ref/01.s new file mode 100644 index 0000000..db5d0b4 --- /dev/null +++ b/c_compiler/test/ref/01.s @@ -0,0 +1,38 @@ + .file 1 "01.c" + .section .mdebug.abi32 + .previous + .nan legacy + .module fp=xx + .module nooddspreg + .abicalls + .option pic0 + .text + .align 2 + .globl main + .set nomips16 + .set nomicromips + .ent main + .type main, @function +main: + .frame $fp,24,$31 # vars= 8, regs= 1/0, args= 0, gp= 8 + .mask 0x40000000,-4 + .fmask 0x00000000,0 + .set noreorder + .set nomacro + addiu $sp,$sp,-24 + sw $fp,20($sp) + move $fp,$sp + li $2,13 # 0xd + sw $2,8($fp) + lw $2,8($fp) + move $sp,$fp + lw $fp,20($sp) + addiu $sp,$sp,24 + jr $31 + nop + + .set macro + .set reorder + .end main + .size main, .-main + .ident "GCC: (Codescape GNU Tools 2016.05-03 for MIPS MTI Linux) 4.9.2" diff --git a/c_compiler/test/ref/01.stdout.xml b/c_compiler/test/ref/01.stdout.xml deleted file mode 100644 index e0545e4..0000000 --- a/c_compiler/test/ref/01.stdout.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Variable id="a" /> - <Variable id="b" /> - <Variable id="c" /> - <Variable id="d" /> - <Variable id="e" /> - <Variable id="f" /> -</Program> diff --git a/c_compiler/test/ref/02.stdout.xml b/c_compiler/test/ref/02.stdout.xml deleted file mode 100644 index 6caf2fc..0000000 --- a/c_compiler/test/ref/02.stdout.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="f"> - <Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/03.stdout.xml b/c_compiler/test/ref/03.stdout.xml deleted file mode 100644 index 2c29a50..0000000 --- a/c_compiler/test/ref/03.stdout.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="foo"> - <Parameter id="bar" /> - <Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/04.stdout.xml b/c_compiler/test/ref/04.stdout.xml deleted file mode 100644 index caae53b..0000000 --- a/c_compiler/test/ref/04.stdout.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="foo"> - <Parameter id="bar1" /> - <Parameter id="bar2" /> - <Scope> - <Variable id="x" /> - <Variable id="y" /> - <Variable id="z" /> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/05.stdout.xml b/c_compiler/test/ref/05.stdout.xml deleted file mode 100644 index f4b306f..0000000 --- a/c_compiler/test/ref/05.stdout.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="foo"> - <Parameter id="x" /> - <Parameter id="y" /> - <Scope> - <Scope> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/06.stdout.xml b/c_compiler/test/ref/06.stdout.xml deleted file mode 100644 index 3526139..0000000 --- a/c_compiler/test/ref/06.stdout.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="f"> - <Parameter id="a" /> - <Parameter id="b" /> - <Parameter id="c" /> - <Scope> - <Variable id="d" /> - <Scope> - <Variable id="e" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/07.stdout.xml b/c_compiler/test/ref/07.stdout.xml deleted file mode 100644 index 17c7c1b..0000000 --- a/c_compiler/test/ref/07.stdout.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="foo"> - <Parameter id="a" /> - <Scope> - <Scope> - <Variable id="z" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/08.stdout.xml b/c_compiler/test/ref/08.stdout.xml deleted file mode 100644 index 0838fe5..0000000 --- a/c_compiler/test/ref/08.stdout.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="func"> - <Parameter id="a" /> - <Parameter id="b" /> - <Scope> - <Variable id="c" /> - <Scope> - <Variable id="d" /> - </Scope> - <Scope> - <Variable id="e" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/09.stdout.xml b/c_compiler/test/ref/09.stdout.xml deleted file mode 100644 index 646cd98..0000000 --- a/c_compiler/test/ref/09.stdout.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="x"> - <Scope> - </Scope> - </Function> - <Variable id="g" /> - <Function id="zz"> - <Parameter id="a" /> - <Parameter id="b" /> - <Parameter id="c" /> - <Scope> - <Scope> - <Variable id="a" /> - </Scope> - <Scope> - <Variable id="fsdfsdfs" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/10.stdout.xml b/c_compiler/test/ref/10.stdout.xml deleted file mode 100644 index 21cadeb..0000000 --- a/c_compiler/test/ref/10.stdout.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="f"> - <Scope> - </Scope> - </Function> - <Variable id="g" /> - <Function id="x"> - <Parameter id="y" /> - <Scope> - <Variable id="z" /> - <Scope> - <Variable id="r" /> - </Scope> - <Scope> - <Variable id="f" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/11.stdout.xml b/c_compiler/test/ref/11.stdout.xml deleted file mode 100644 index ad96d6c..0000000 --- a/c_compiler/test/ref/11.stdout.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="f"> - <Scope> - <Variable id="x" /> - <Scope> - <Variable id="y" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/12.stdout.xml b/c_compiler/test/ref/12.stdout.xml deleted file mode 100644 index 9f49265..0000000 --- a/c_compiler/test/ref/12.stdout.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="f"> - <Parameter id="b" /> - <Parameter id="c" /> - <Scope> - <Variable id="a" /> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/13.stdout.xml b/c_compiler/test/ref/13.stdout.xml deleted file mode 100644 index f0385cb..0000000 --- a/c_compiler/test/ref/13.stdout.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="func"> - <Parameter id="x" /> - <Parameter id="y" /> - <Scope> - <Variable id="i" /> - <Scope> - <Variable id="z" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/14.stdout.xml b/c_compiler/test/ref/14.stdout.xml deleted file mode 100644 index 63aec85..0000000 --- a/c_compiler/test/ref/14.stdout.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="function_1"> - <Parameter id="a" /> - <Parameter id="b" /> - <Scope> - <Variable id="x" /> - <Scope> - <Variable id="c" /> - </Scope> - </Scope> - </Function> -</Program> diff --git a/c_compiler/test/ref/15.stdout.xml b/c_compiler/test/ref/15.stdout.xml deleted file mode 100644 index 029ccb8..0000000 --- a/c_compiler/test/ref/15.stdout.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> -<Program> - <Function id="add"> - <Parameter id="a" /> - <Parameter id="b" /> - <Scope> - <Variable id="c" /> - </Scope> - </Function> - <Function id="sub"> - <Parameter id="a" /> - <Parameter id="b" /> - <Scope> - <Variable id="c" /> - </Scope> - </Function> - <Function id="mult_by_5"> - <Parameter id="a" /> - <Scope> - <Variable id="b" /> - </Scope> - </Function> - <Function id="add_5"> - <Parameter id="a" /> - <Scope> - <Variable id="i" /> - <Scope> - <Variable id="b" /> - </Scope> - </Scope> - </Function> -</Program> |