diff options
Diffstat (limited to 'Parser.cpp')
-rw-r--r-- | Parser.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -56,6 +56,7 @@ void eth::debugOutAST(ostream& _out, sp::utree const& _this) case 3: _out << "[ "; debugOutAST(_out, _this.front()); _out << " ] "; debugOutAST(_out, _this.back()); break; case 4: _out << "[[ "; debugOutAST(_out, _this.front()); _out << " ]] "; debugOutAST(_out, _this.back()); break; case 5: _out << "{ "; for (auto const& i: _this) { debugOutAST(_out, i); _out << " "; } _out << "}"; break; + case 6: _out << "$ "; debugOutAST(_out, _this.front()); break; default:; } @@ -80,8 +81,8 @@ void eth::parseTreeLLL(string const& _s, sp::utree& o_out) qi::rule<it, qi::ascii::space_type, sp::utree()> element; qi::rule<it, string()> str = '"' > qi::lexeme[+(~qi::char_(std::string("\"") + '\0'))] > '"'; - qi::rule<it, string()> strsh = '\'' > qi::lexeme[+(~qi::char_(std::string(" ;@()[]{}:") + '\0'))]; - qi::rule<it, symbol_type()> symbol = qi::lexeme[+(~qi::char_(std::string(" @[]{}:();\"\x01-\x1f\x7f") + '\0'))]; + qi::rule<it, string()> strsh = '\'' > qi::lexeme[+(~qi::char_(std::string(" ;$@()[]{}:\n\t") + '\0'))]; + qi::rule<it, symbol_type()> symbol = qi::lexeme[+(~qi::char_(std::string(" $@[]{}:();\"\x01-\x1f\x7f") + '\0'))]; qi::rule<it, string()> intstr = qi::lexeme[ qi::no_case["0x"][qi::_val = "0x"] >> *qi::char_("0-9a-fA-F")[qi::_val += qi::_1]] | qi::lexeme[+qi::char_("0-9")[qi::_val += qi::_1]]; qi::rule<it, bigint()> integer = intstr; qi::rule<it, bigint()> multiplier = qi::lit("wei")[qi::_val = 1] | qi::lit("szabo")[qi::_val = szabo] | qi::lit("finney")[qi::_val = finney] | qi::lit("ether")[qi::_val = ether]; @@ -92,10 +93,11 @@ void eth::parseTreeLLL(string const& _s, sp::utree& o_out) qi::rule<it, qi::ascii::space_type, sp::utree::list_type()> sload = qi::lit("@@") > element; qi::rule<it, qi::ascii::space_type, sp::utree::list_type()> mstore = '[' > element > ']' > -qi::lit(":") > element; qi::rule<it, qi::ascii::space_type, sp::utree::list_type()> sstore = qi::lit("[[") > element > qi::lit("]]") > -qi::lit(":") > element; + qi::rule<it, qi::ascii::space_type, sp::utree::list_type()> calldataload = qi::lit("$") > element; qi::rule<it, qi::ascii::space_type, sp::utree::list_type()> list = '(' > *element > ')'; auto x = [](int a) { return [=](sp::utree& n, typename qi::rule<it, qi::ascii::space_type, sp::utree()>::context_type& c) { (boost::fusion::at_c<0>(c.attributes) = n).tag(a); }; }; - qi::rule<it, qi::ascii::space_type, sp::utree()> extra = sload[x(2)] | mload[x(1)] | sstore[x(4)] | mstore[x(3)] | seq[x(5)]; + qi::rule<it, qi::ascii::space_type, sp::utree()> extra = sload[x(2)] | mload[x(1)] | sstore[x(4)] | mstore[x(3)] | seq[x(5)] | calldataload[x(6)]; element = atom | list | extra; string s; @@ -120,7 +122,8 @@ void eth::parseTreeLLL(string const& _s, sp::utree& o_out) } auto ret = s.cbegin(); qi::phrase_parse(ret, s.cend(), element, space, qi::skip_flag::dont_postskip, o_out); - if (ret != s.cend()) - throw std::exception(); + for (auto i = ret; i != s.cend(); ++i) + if (!isspace(*i)) + throw std::exception(); } |