Zen
A cross-platform functional programming language
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

GrammarFileGenerator Class Reference

Class that generates a grammar file and calls the lexer and parser. More...

Inheritance diagram for GrammarFileGenerator:
GrammarStatement::Visitor

List of all members.

Public Member Functions

 GrammarFileGenerator (const Ast::GrammarImplItem &def)
 Default constructor.
void generate (const Build::Project &project, const z::fileinfo &fi)
 Generates the parser and lexer files.

Static Public Member Functions

static z::string getFilename (const z::fileinfo &fi, const Ast::FunctionDef &def)
 Returns the base filename for lexer and parser.

Private Member Functions

void enterLexer (const Build::Project &project, const z::string &filename)
 Initial code for the lexer file.
void leaveLexer (const Build::Project &project, const z::string &filename)
 Final code for the lexer file. Also runs the re2c compiler.
void enterParser (const Build::Project &project, const z::string &filename)
 Initial code for the parser file.
void leaveParser (const Build::Project &project, const z::string &filename)
 Final code for the parser file. Also runs the lemon parser.
virtual void visit (const Ast::GrammarRuleStatement &stmt)
 Abstract visitor function.
virtual void visit (const Ast::LexerStatement &stmt)
 Abstract visitor function.

Private Attributes

const Ast::GrammarImplItem_def
 Reference to grammar implementation item.
zbl::CppGen::OutFile _lex
 Lexer file.
zbl::CppGen::OutFile _lmn
 Parser file.

Detailed Description

Class that generates a grammar file and calls the lexer and parser.


Constructor & Destructor Documentation

GrammarFileGenerator ( const Ast::GrammarImplItem def) [inline]

Default constructor.

Parameters:
defThe grammar implementation item

Member Function Documentation

void enterLexer ( const Build::Project project,
const z::string filename 
) [inline, private]

Initial code for the lexer file.

Parameters:
projectThe project definition
filenameThe lexer filename
void enterParser ( const Build::Project project,
const z::string filename 
) [inline, private]

Initial code for the parser file.

Parameters:
projectThe project definition
filenameThe lexer filename
void generate ( const Build::Project project,
const z::fileinfo fi 
) [inline]

Generates the parser and lexer files.

Parameters:
projectThe project definition
fiFileInfo instance
static z::string getFilename ( const z::fileinfo fi,
const Ast::FunctionDef def 
) [inline, static]

Returns the base filename for lexer and parser.

Parameters:
fiFileInfo instance
defThe function definition for this grammar
Returns:
The base filename
void leaveLexer ( const Build::Project project,
const z::string filename 
) [inline, private]

Final code for the lexer file. Also runs the re2c compiler.

Parameters:
projectThe project definition
filenameThe lexer filename
void leaveParser ( const Build::Project project,
const z::string filename 
) [inline, private]

Final code for the parser file. Also runs the lemon parser.

Parameters:
projectThe project definition
filenameThe lexer filename
virtual void visit ( const Ast::GrammarRuleStatement stmt) [inline, private, virtual]

Abstract visitor function.

Parameters:
stmtThe grammar statement reference to handle

Implements GrammarStatement::Visitor.

virtual void visit ( const Ast::LexerStatement stmt) [inline, private, virtual]

Abstract visitor function.

Parameters:
stmtThe grammar statement reference to handle

Implements GrammarStatement::Visitor.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines