Zen
A cross-platform functional programming language
|
Class that generates a grammar file and calls the lexer and parser. More...
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. |
Class that generates a grammar file and calls the lexer and parser.
GrammarFileGenerator | ( | const Ast::GrammarImplItem & | def | ) | [inline] |
Default constructor.
def | The grammar implementation item |
void enterLexer | ( | const Build::Project & | project, |
const z::string & | filename | ||
) | [inline, private] |
Initial code for the lexer file.
project | The project definition |
filename | The lexer filename |
void enterParser | ( | const Build::Project & | project, |
const z::string & | filename | ||
) | [inline, private] |
Initial code for the parser file.
project | The project definition |
filename | The lexer filename |
void generate | ( | const Build::Project & | project, |
const z::fileinfo & | fi | ||
) | [inline] |
Generates the parser and lexer files.
project | The project definition |
fi | FileInfo instance |
static z::string getFilename | ( | const z::fileinfo & | fi, |
const Ast::FunctionDef & | def | ||
) | [inline, static] |
Returns the base filename for lexer and parser.
fi | FileInfo instance |
def | The function definition for this grammar |
void leaveLexer | ( | const Build::Project & | project, |
const z::string & | filename | ||
) | [inline, private] |
Final code for the lexer file. Also runs the re2c compiler.
project | The project definition |
filename | The 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.
project | The project definition |
filename | The lexer filename |
virtual void visit | ( | const Ast::GrammarRuleStatement & | stmt | ) | [inline, private, virtual] |
Abstract visitor function.
stmt | The grammar statement reference to handle |
Implements GrammarStatement::Visitor.
virtual void visit | ( | const Ast::LexerStatement & | stmt | ) | [inline, private, virtual] |
Abstract visitor function.
stmt | The grammar statement reference to handle |
Implements GrammarStatement::Visitor.