Parses Mim code as AST. More...
#include <mim/ast/parser.h>
Public Member Functions | |
| Parser (AST &ast) | |
| AST & | ast () |
| Driver & | driver () |
| fe::Parser's default diagnostics go to its Driver::error. | |
| const File * | import (std::string_view sv, Tok::Tag tag=Tok::Tag::K_import) |
| const File * | import (Dbg, bool is_path, Tok::Tag tag=Tok::Tag::K_import, std::ostream *md=nullptr, bool record=true) |
is_path selects the import "some/path.mim" form over the search-path lookup by name. | |
| const File * | import (const fe::Src &, std::ostream *md=nullptr, Loc={}) |
| Ptrs< UseDecl > | import_plugins (fe::View< std::string > plugins, Tok::Tag) |
Imports the plugins the Driver was told about via -p as anonymous, unaliased UseDecls. | |
| const File * | import (std::istream &is, fs::path path, Loc={}, std::ostream *md=nullptr) |
Slurps is, registers it in Driver::src under path, and parses it. | |
| const File * | import_main (std::string_view input, fe::View< std::string > plugins, std::ostream *md=nullptr) |
The logic behind the various parse methods is as follows:
The parse_* method does not have a fe::Cite ctxt parameter:
It's the caller's responsibility to first make appropriate FIRST/FOLLOW checks. Otherwise, an assertion will be triggered in the case of a syntax error.
The parse_* method does have a fe::Cite ctxt parameter:
The called method checks this and spits out an appropriate error message using ctxt in the case of a syntax error.
|
inline |
|
inline |
|
inline |
fe::Parser's default diagnostics go to its Driver::error.
Definition at line 38 of file parser.h.
References ast(), and mim::ast::AST::driver().
Referenced by import(), import(), import(), import(), import_main(), and import_plugins().
| const File * mim::ast::Parser::import | ( | const fe::Src & | src, |
| std::ostream * | md = nullptr, | ||
| Loc | loc = {} ) |
Definition at line 95 of file parser.cpp.
References ast(), driver(), mim::ast::AST::file(), mim::ast::Lexer::Lexer(), and mim::Driver::log().
| const File * mim::ast::Parser::import | ( | Dbg | dbg, |
| bool | is_path, | ||
| Tok::Tag | tag = Tok::Tag::K_import, | ||
| std::ostream * | md = nullptr, | ||
| bool | record = true ) |
is_path selects the import "some/path.mim" form over the search-path lookup by name.
record is false for the compilation root: it is not a directive that a dump should reproduce.
Definition at line 31 of file parser.cpp.
References mim::Driver::Imports::add(), driver(), mim::Driver::imports(), mim::Driver::load(), and mim::Driver::log().
| const File * mim::ast::Parser::import | ( | std::istream & | is, |
| fs::path | path, | ||
| Loc | loc = {}, | ||
| std::ostream * | md = nullptr ) |
Slurps is, registers it in Driver::src under path, and parses it.
Definition at line 86 of file parser.cpp.
References driver().
| const File * mim::ast::Parser::import_main | ( | std::string_view | input, |
| fe::View< std::string > | plugins, | ||
| std::ostream * | md = nullptr ) |
Definition at line 126 of file parser.cpp.
References ast(), driver(), and import_plugins().
Imports the plugins the Driver was told about via -p as anonymous, unaliased UseDecls.
Definition at line 116 of file parser.cpp.
References driver().
Referenced by import_main().