This commit is contained in:
2023-04-08 16:54:22 -07:00
parent c221dc9bf2
commit b4e2592c81
6 changed files with 165 additions and 0 deletions

View File

@@ -66,6 +66,15 @@ auto operator-=(Coord &, Coord) -> Coord &;
/// Write a coordinate to a string "(x,y)"
auto operator<<(std::ostream &, Coord) -> std::ostream &;
/// Scale a coordinate
auto operator*(std::int64_t, Coord) -> Coord;
/// Scale a coordinate
auto operator*(Coord, std::int64_t) -> Coord;
/// Scale a coordinate
auto operator*=(Coord &, std::int64_t) -> Coord &;
} // namespace
template<>

View File

@@ -30,6 +30,22 @@ auto ParseGrammar(G const& grammar, std::istream & in) -> typename G::start_type
return result;
}
template <typename G>
auto ParseGrammar_(G const& grammar, std::istream & in) -> typename G::start_type::attr_type
{
namespace qi = boost::spirit::qi;
auto result = typename G::start_type::attr_type {};
auto const content = std::string{std::istreambuf_iterator{in}, {}};
auto b = content.begin(); // updated on successful parse
auto const e = content.end();
if (!qi::phrase_parse(b, e, grammar, qi::ascii::space, result) || b != e) {
throw std::runtime_error{"Bad input file: " + content};
}
return result;
}
}
#endif