From f19e68c714c20a6bd0d40efa876fd3a3ba565fed Mon Sep 17 00:00:00 2001 From: "John Hodge (bugs)" Date: Fri, 28 Nov 2014 21:46:17 +0800 Subject: Hacking up parser --- ast/ast.cpp | 13 +++ ast/ast.hpp | 11 ++- mrustc.cbp | 16 ++++ mrustc.depend | 10 +-- mrustc.layout | 74 +++++++++++++++ parse/common.hpp | 5 ++ parse/expr.cpp | 268 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ parse/root.cpp | 91 +++++++++++++++++-- 8 files changed, 474 insertions(+), 14 deletions(-) create mode 100644 mrustc.layout create mode 100644 parse/expr.cpp diff --git a/ast/ast.cpp b/ast/ast.cpp index 5c9c566e..4bba2b61 100644 --- a/ast/ast.cpp +++ b/ast/ast.cpp @@ -15,7 +15,20 @@ void Module::add_global(bool is_public, bool is_mut, ::std::string name, TypeRef { ::std::cout << "add_global()" << ::std::endl; } +void Module::add_struct(bool is_public, ::std::string name, TypeParams params, ::std::vector items) +{ +} +void Module::add_function(bool is_public, ::std::string name, TypeParams params, TypeRef ret_type, ::std::vector args, Expr code) +{ +} +ExprNode::ExprNode() +{ + +} +ExprNode::ExprNode(TagBlock, ::std::vector nodes) +{ +} ExprNode::ExprNode(TagInteger, uint64_t value, enum eCoreType datatype) { diff --git a/ast/ast.hpp b/ast/ast.hpp index f84f322f..c3bc549b 100644 --- a/ast/ast.hpp +++ b/ast/ast.hpp @@ -18,16 +18,22 @@ public: class ExprNode { public: + ExprNode(); + + struct TagBlock {}; + ExprNode(TagBlock, ::std::vector nodes); + struct TagAssign {}; ExprNode(TagAssign, ExprNode slot, ExprNode value) {} - struct TagInteger {}; + struct TagInteger {}; ExprNode(TagInteger, uint64_t value, enum eCoreType datatype); }; class Expr { public: + Expr() {} Expr(ExprNode node) {} }; @@ -40,6 +46,7 @@ public: }; typedef ::std::vector TypeParams; +typedef ::std::pair< ::std::string, TypeRef> StructItem; class Module { @@ -47,6 +54,8 @@ public: void add_alias(bool is_public, Path path) {} void add_constant(bool is_public, ::std::string name, TypeRef type, Expr val); void add_global(bool is_public, bool is_mut, ::std::string name, TypeRef type, Expr val); + void add_struct(bool is_public, ::std::string name, TypeParams params, ::std::vector items); + void add_function(bool is_public, ::std::string name, TypeParams params, TypeRef ret_type, ::std::vector args, Expr code); }; } diff --git a/mrustc.cbp b/mrustc.cbp index ab0a2104..edc901f1 100644 --- a/mrustc.cbp +++ b/mrustc.cbp @@ -13,6 +13,7 @@