PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::Parser Class Reference

#include <Puma/Parser.h>

+ Inheritance diagram for Puma::Parser:

Description

Generic parser abstraction.

Setups the parser components ready to be used for parsing an input file (see class Puma::Syntax, Puma::Builder, and Puma::Semantic).

The result of parsing a source file is the so-called translation unit (see class Puma::CTranslationUnit). It encapsulates the result of the syntactic and semantic analyses (syntax tree, semantic information database, preprocessor tree).

Public Member Functions

 Parser (Syntax &x, Builder &b, Semantic &s)
 Constructor.
 
CTranslationUnitparse (Unit &file, CProject &p, int pre_mode=0, std::ostream &os=std::cout)
 Parse the given input file.
 
void configure (Config &c)
 Configure the parser components.
 

Constructor & Destructor Documentation

◆ Parser()

Puma::Parser::Parser ( Syntax & x,
Builder & b,
Semantic & s )
inline

Constructor.

Parameters
xThe syntax analysis component.
bThe syntax tree builder.
sThe semantic analysis component.

Member Function Documentation

◆ configure()

void Puma::Parser::configure ( Config & c)

Configure the parser components.

Calls the corresponding configure methods of the parser components.

Parameters
cThe configuration settings.

◆ parse()

CTranslationUnit * Puma::Parser::parse ( Unit & file,
CProject & p,
int pre_mode = 0,
std::ostream & os = std::cout )

Parse the given input file.

Supports different preprocessing modes. 0 means to pass the preprocessed tokens to the parser. 1 means to print the preprocessed tokens on stdout and to not parse at all. Mode 2 means the same as mode 1 except that the preprocessed tokens are not printed to stdout.

Parameters
fileThe input file.
pThe source project information.
pre_modeThe preprocessing mode (0-2).
osPreprocessor output stream if mode is 1.
Returns
A newly created object containing the parse results. To be destroyed by the caller.