Gyoji Compiler
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
Gyoji::frontend::Parser Class Reference

#include <parser.hpp>

Static Public Member Functions

static Gyoji::owned< ParseResultparse (Gyoji::context::CompilerContext &_compiler_context, Gyoji::misc::InputSource &_input_source)
 
static Gyoji::owned< Gyoji::mir::MIRparse_to_mir (Gyoji::context::CompilerContext &_compiler_context, Gyoji::misc::InputSource &_input_source)
 

Detailed Description

This is the main interface to the front-end parsing system. It contains only static methods to invoke the parser and retrieve the syntax tree. No state is held by this class and it exists only to organize the namespace of the interface.

Member Function Documentation

◆ parse()

Gyoji::owned< ParseResult > Parser::parse ( Gyoji::context::CompilerContext _compiler_context,
Gyoji::misc::InputSource _input_source 
)
static

This is the main interface to the front-end for the parser. The purpose is to wrap all of the lex/parse/syntax tree components of the front-end into a common and simple to use interface.

The parser is responsible for reading data from the input and passing it to the tokenizer (Flex-based lexical analyzer) and then to the parser (Bison-based LALR(1) parser). From there, the resulting data is built into a syntax tree and is available in the parse result.

Once the parse result is returned, the caller takes ownership of all of the resulting data and the parser itself is free to leave scope having done its job.

Parameters
_namespace_contextThis is the namespace context containing the initial set of primitive types.
_input_sourceThis is the source from which to read data.

◆ parse_to_mir()

Gyoji::owned< MIR > Parser::parse_to_mir ( Gyoji::context::CompilerContext _compiler_context,
Gyoji::misc::InputSource _input_source 
)
static

This function parses the input code and produces an MIR representation of the result that can be passed directly to the analysis and later, the code-generation systems to generate code. This is the ultimate result of the front-end. Any alternative front-end syntax layers should also parse using the context and produce an MIR as a result. The caller will take ownership of the resulting MIR and make it available to downstream consumers.


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