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/map/magic-v2.cpp | |
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/map/magic-v2.cpp')
-rw-r--r-- | src/map/magic-v2.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/map/magic-v2.cpp b/src/map/magic-v2.cpp index eeeb989..26c1a19 100644 --- a/src/map/magic-v2.cpp +++ b/src/map/magic-v2.cpp @@ -36,6 +36,8 @@ #include "../sexpr/parser.hpp" +#include "../ast/script.hpp" + #include "itemdb.hpp" #include "magic-expr.hpp" #include "magic-interpreter.hpp" @@ -785,7 +787,20 @@ namespace magic_v2 if (s._list[1]._type != sexpr::STRING) return fail(s._list[1], "not string"_s); ZString body = s._list[1]._str; - std::unique_ptr<const ScriptBuffer> script = parse_script(body, s._list[1]._span.begin.line, true); + auto begin = s._list[1]._span.begin; + io::LineCharReader lr(io::from_string, begin.filename, body, begin.line, begin.column); + ast::script::ScriptOptions opt; + opt.implicit_start = true; + opt.implicit_end = true; + opt.no_event = true; + auto code_res = ast::script::parse_script_body(lr, opt); + if (code_res.get_failure()) + { + PRINTF("%s\n"_fmt, code_res.get_failure()); + } + auto code = TRY_UNWRAP(code_res.get_success(), + return fail(s._list[1], "script does not compile"_s)); + std::unique_ptr<const ScriptBuffer> script = compile_script(code, true); if (!script) return fail(s._list[1], "script does not compile"_s); EffectScript e; |