diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-11-03 13:35:54 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-11-04 20:10:50 -0800 |
commit | 1853e964e96c41e762ca0ab97259ee4e79d86ec7 (patch) | |
tree | edc76f58ed786263a28da79564786f4d75400092 /src/ast/item.hpp | |
parent | 1a00fe4ea75924bfe594c4d92073cc95eaa2f32d (diff) | |
download | tmwa-1853e964e96c41e762ca0ab97259ee4e79d86ec7.tar.gz tmwa-1853e964e96c41e762ca0ab97259ee4e79d86ec7.tar.bz2 tmwa-1853e964e96c41e762ca0ab97259ee4e79d86ec7.tar.xz tmwa-1853e964e96c41e762ca0ab97259ee4e79d86ec7.zip |
Use the new ASTs
Diffstat (limited to 'src/ast/item.hpp')
-rw-r--r-- | src/ast/item.hpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/ast/item.hpp b/src/ast/item.hpp index b54e55c..a8fe908 100644 --- a/src/ast/item.hpp +++ b/src/ast/item.hpp @@ -20,12 +20,12 @@ #include "fwd.hpp" -#include <memory> - #include "../compat/result.hpp" #include "../io/span.hpp" +#include "../sexpr/variant.hpp" + #include "../mmo/clif.t.hpp" #include "../mmo/ids.hpp" #include "../mmo/strs.hpp" @@ -41,17 +41,11 @@ namespace item { using io::Spanned; - struct ItemOrComment - { - io::LineSpan span; - - virtual ~ItemOrComment(); - }; - struct Comment : ItemOrComment + struct Comment { RString comment; }; - struct Item : ItemOrComment + struct Item { Spanned<ItemNameId> id; Spanned<ItemName> name; @@ -74,7 +68,15 @@ namespace item ast::script::ScriptBody equip_script; }; - Result<std::unique_ptr<ItemOrComment>> parse_item(io::LineCharReader& lr); + using ItemOrCommentBase = Variant<Comment, Item>; + struct ItemOrComment : ItemOrCommentBase + { + ItemOrComment(Comment o) : ItemOrCommentBase(std::move(o)) {} + ItemOrComment(Item o) : ItemOrCommentBase(std::move(o)) {} + io::LineSpan span; + }; + + Option<Result<ItemOrComment>> parse_item(io::LineCharReader& lr); } // namespace item } // namespace ast } // namespace tmwa |