4 #define INCLUDED_FLEXLEXER_H
5 #include "grammar/joos1w_lexer_internal.h"
6 #undef INCLUDED_FLEXLEXER_H
9 #include <memory_resource>
13 #include "diagnostics/Diagnostics.h"
14 #include "diagnostics/SourceManager.h"
15 #include "utils/BumpAllocator.h"
17 class Joos1WParser
final {
19 Joos1WParser(std::string
const& in, BumpAllocator& alloc,
21 : lexer{alloc, diag}, iss{in} {
22 buffer = lexer.yy_create_buffer(iss, in.size());
23 lexer.yy_switch_to_buffer(buffer);
26 Joos1WParser(std::string
const& in,
28 : mbr{}, alloc{&mbr}, lexer{alloc, diag}, iss{in} {
29 buffer = lexer.yy_create_buffer(iss, in.size());
30 lexer.yy_switch_to_buffer(buffer);
33 Joos1WParser(
SourceFile file, BumpAllocator& alloc,
37 lexer{alloc, diag, file},
40 lexer.yy_switch_to_buffer(buffer);
43 int yylex() {
return lexer.yylex(); }
45 int parse(parsetree::
Node*& ret) {
47 return yyparse(&ret, lexer);
51 if(buffer) lexer.yy_delete_buffer(buffer);
55 std::pmr::monotonic_buffer_resource mbr;
58 yy_buffer_state* buffer;
59 std::istringstream iss;