LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
parse Namespace Reference

Parsing the input, delivering an ast::Ast. More...

Namespaces

namespace  tasks
 Tasks of the parse module.

Classes

class  MetavarMap
 A generic map of metavariables. More...
class  TigerParser
 Conduct the scanner and the parser. More...
class  Tweast
 TWEAST stands for ``Text With Embedded Abstract Syntax Trees''. More...

Typedefs

typedef misc::variant
< ast::Exp *, ast::DecsList * > 
ast_type
 Result of a parse: an Exp (*.tig) or a DecsList (*.tih).

Functions

std::pair< ast::DecsList
*, misc::error
parse (const std::string &prelude, const std::string &fname, misc::file_library &l, bool scan_trace_p, bool parse_trace_p, bool enable_object_extensions_p=false)
 Parse a Tiger file, return the corresponding abstract syntax tree.
ast_type parse (Tweast &input)
 Parse a Tweast.
ast::Expparse (const std::string &str, bool enable_object_extensions_p=false)
 Parse a std::string. Used for unit tests.
ast::DecsListparse_unit (const std::string &str, bool enable_object_extensions_p)
ast::Decsparse_decs (Tweast &in)
 Parse a set of declarations.
std::ostream & operator<< (std::ostream &ostr, const Tweast &in)
 Display the content of the tweast.

Detailed Description

Parsing the input, delivering an ast::Ast.

Typedef Documentation

Result of a parse: an Exp (*.tig) or a DecsList (*.tih).

Function Documentation

std::ostream & parse::operator<< ( std::ostream &  ostr,
const Tweast &  in 
)

Display the content of the tweast.

References parse::Tweast::dump().

std::pair< ast::DecsList *, misc::error > parse::parse ( const std::string &  prelude,
const std::string &  fname,
misc::file_library l,
bool  scan_trace_p,
bool  parse_trace_p,
bool  enable_object_extensions_p = false 
)

Parse a Tiger file, return the corresponding abstract syntax tree.

Parameters
preludename of the prelude file.
fnamepath and name of the tiger file.
file_librarylibrary for managing search path.
scan_trace_pdisplay informations on scan step.
parse_trace_pdisplay informations on parse step.
enable_object_extensions_penable object constructions
Returns
a pair the first element of which is a pointer to an abstract parse tree upon success, `nullptr' otherwise; and the second element of which is the error status. This function is the only interface available between the scanner/parser and the rest of the program.

References misc::basedir(), parse::TigerParser::enable_object_extensions(), parse::TigerParser::error_get(), misc::make_pair(), parse::TigerParser::parse(), parse::TigerParser::parse_file(), parse::TigerParser::parse_import(), parse::TigerParser::parse_trace(), misc::file_library::pop_current_directory(), parse::TigerParser::prelude(), misc::file_library::push_current_directory(), and parse::TigerParser::scan_trace().

Referenced by object::DesugarVisitor::adapt_type(), object::DesugarVisitor::dispatch_switch(), object::DesugarVisitor::operator()(), parse_decs(), and object::DesugarVisitor::variant_exp().

ast_type parse::parse ( Tweast &  input)
ast::Exp * parse::parse ( const std::string &  str,
bool  enable_object_extensions_p 
)
ast::Decs * parse::parse_decs ( Tweast &  in)

Parse a set of declarations.

Wrapper around parse::parse to return the single ast::Decs to be found in the input (expected to contain decs_listdecs).

Used by desugar::BoundCheckingVisitor and object::ObjectDesugarVisitor.

References assertion, ast::DecsList::decs_get(), and parse().

ast::DecsList * parse::parse_unit ( const std::string &  str,
bool  enable_object_extensions_p = false 
)

Parse a std::string. Used for unit tests. The declaration of the _main function is automatically added.

References parse::TigerParser::enable_object_extensions(), parse::TigerParser::error_get(), and parse::TigerParser::parse().