MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::ast::Parser Class Reference

Parses Mim code as AST. More...

#include <mim/ast/parser.h>

Inheritance diagram for mim::ast::Parser:
[legend]

Public Member Functions

 Parser (AST &ast)
ASTast ()
Driverdriver ()
 fe::Parser's default diagnostics go to its Driver::error.
const Fileimport (std::string_view sv, Tok::Tag tag=Tok::Tag::K_import)
const Fileimport (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 Fileimport (const fe::Src &, std::ostream *md=nullptr, Loc={})
Ptrs< UseDeclimport_plugins (fe::View< std::string > plugins, Tok::Tag)
 Imports the plugins the Driver was told about via -p as anonymous, unaliased UseDecls.
const Fileimport (std::istream &is, fs::path path, Loc={}, std::ostream *md=nullptr)
 Slurps is, registers it in Driver::src under path, and parses it.
const Fileimport_main (std::string_view input, fe::View< std::string > plugins, std::ostream *md=nullptr)

Detailed Description

Parses Mim code as AST.

The logic behind the various parse methods is as follows:

  1. 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.

  2. 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.

  3. The parse_* method does have a fe::Cite ctxt = {} parameter with default argument:
    • If default argument is elided we have the same behavior as in 1.
    • If default argument is provided we have the same behavior as in 2.

Definition at line 30 of file parser.h.

Constructor & Destructor Documentation

◆ Parser()

mim::ast::Parser::Parser ( AST & ast)
inline

Definition at line 34 of file parser.h.

References ast().

Referenced by mim::ast::load_plugins().

Member Function Documentation

◆ ast()

AST & mim::ast::Parser::ast ( )
inline

Definition at line 37 of file parser.h.

Referenced by driver(), import(), import_main(), and Parser().

◆ driver()

Driver & mim::ast::Parser::driver ( )
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().

◆ import() [1/4]

const File * mim::ast::Parser::import ( const fe::Src & src,
std::ostream * md = nullptr,
Loc loc = {} )

◆ import() [2/4]

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().

◆ import() [3/4]

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().

◆ import() [4/4]

const File * mim::ast::Parser::import ( std::string_view sv,
Tok::Tag tag = Tok::Tag::K_import )
inline

Definition at line 39 of file parser.h.

References driver().

◆ import_main()

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().

◆ import_plugins()

Ptrs< UseDecl > mim::ast::Parser::import_plugins ( fe::View< std::string > plugins,
Tok::Tag tag )

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().


The documentation for this class was generated from the following files: