parser.h 533 B

123456789101112131415161718192021
  1. #pragma once
  2. #include "lexer.h"
  3. #include "runtime.h"
  4. #include "utils.h"
  5. #include <string>
  6. #include <stdexcept>
  7. namespace jinja {
  8. // parse from a list of tokens into an AST (program)
  9. // may throw parser_exception on error
  10. program parse_from_tokens(const lexer_result & lexer_res);
  11. struct parser_exception : public std::runtime_error {
  12. parser_exception(const std::string & msg, const std::string & source, size_t pos)
  13. : std::runtime_error(fmt_error_with_source("parser", msg, source, pos)) {}
  14. };
  15. } // namespace jinja