diff options
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/vespa/eval/eval/value_type_spec.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/eval/src/vespa/eval/eval/value_type_spec.cpp b/eval/src/vespa/eval/eval/value_type_spec.cpp index 9bd0e54882f..6076988ad50 100644 --- a/eval/src/vespa/eval/eval/value_type_spec.cpp +++ b/eval/src/vespa/eval/eval/value_type_spec.cpp @@ -12,6 +12,14 @@ namespace { class ParseContext { +public: + struct Mark { + const char *pos; + char curr; + bool failed; + Mark(const char *pos_in, char curr_in, bool failed_in) + : pos(pos_in), curr(curr_in), failed(failed_in) {} + }; private: const char *_pos; const char *_end; @@ -34,6 +42,14 @@ public: _pos_after = nullptr; } } + Mark mark() const { + return Mark(_pos, _curr, _failed); + } + void revert(Mark mark) { + _pos = mark.pos; + _curr = mark.curr; + _failed = mark.failed; + } void fail() { _failed = true; _curr = 0; @@ -131,13 +147,15 @@ std::vector<ValueType::Dimension> parse_dimension_list(ParseContext &ctx) { } vespalib::string parse_cell_type(ParseContext &ctx) { - vespalib::string cell_type = "double"; + auto mark = ctx.mark(); ctx.skip_spaces(); - if (ctx.get() == '<') { - ctx.eat('<'); - cell_type = parse_ident(ctx); - ctx.skip_spaces(); - ctx.eat('>'); + ctx.eat('<'); + auto cell_type = parse_ident(ctx); + ctx.skip_spaces(); + ctx.eat('>'); + if (ctx.failed()) { + ctx.revert(mark); + cell_type = "double"; } return cell_type; } |