32 lines
688 B
C++
32 lines
688 B
C++
#include <pslang/parser/parser.hpp>
|
|
#include <pslang/parser/context.hpp>
|
|
#include <pslang/parser/indented_statement.hpp>
|
|
#include <pslang/ast/location.hpp>
|
|
#include "gen_parser.hpp"
|
|
#include "gen_lexer.hpp"
|
|
|
|
namespace pslang::parser
|
|
{
|
|
|
|
ast::statement_list_ptr parse(std::filesystem::path const & file)
|
|
{
|
|
auto filename = file.string();
|
|
|
|
yyin = fopen(filename.c_str(), "r");
|
|
if (!yyin)
|
|
throw std::system_error(std::make_error_code(static_cast<std::errc>(errno)));
|
|
|
|
ast::location location{filename};
|
|
indented_statement_list result;
|
|
context ctx{location, result};
|
|
|
|
bison::parser parser(ctx);
|
|
|
|
parser.parse();
|
|
|
|
fclose(yyin);
|
|
|
|
return finilize(std::move(result));
|
|
}
|
|
|
|
}
|