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 ()
Ptr< Moduleimport (std::string_view sv, Tok::Tag tag=Tok::Tag::K_import)
Ptr< Moduleimport (Dbg, std::ostream *md=nullptr, Tok::Tag tag=Tok::Tag::K_import)
Ptr< Moduleimport (std::istream &, Loc={}, const fs::path *=nullptr, std::ostream *md=nullptr)
Ptr< Moduleimport_main (std::string_view input, 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 std::string_view 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 std::string_view 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 std::string_view 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().

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

Definition at line 38 of file parser.h.

References ast(), and mim::ast::AST::driver().

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

◆ import() [1/3]

Ptr< Module > mim::ast::Parser::import ( Dbg dbg,
std::ostream * md = nullptr,
Tok::Tag tag = Tok::Tag::K_import )

Definition at line 123 of file parser.cpp.

References driver(), and mim::Driver::load().

◆ import() [2/3]

Ptr< Module > mim::ast::Parser::import ( std::istream & is,
Loc loc = {},
const fs::path * path = nullptr,
std::ostream * md = nullptr )

Definition at line 148 of file parser.cpp.

References ast(), driver(), and mim::ast::AST::error().

◆ import() [3/3]

Ptr< Module > 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()

Ptr< Module > mim::ast::Parser::import_main ( std::string_view input,
View< std::string > plugins,
std::ostream * md = nullptr )

Definition at line 164 of file parser.cpp.

References ast(), and driver().


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