RE/flex scanner generator class, a variation of the classic "lex" tool to generate scanners. More...
#include <reflex.h>
Classes | |
struct | Code |
Line of code fragment in lex specifications. More... | |
struct | Library |
A library entry to describe regex library properties. More... | |
struct | Rule |
A regex pattern and action pair that forms a rule. More... | |
Public Types | |
typedef std::map< std::string, Library > | LibraryMap |
Dictionary of regex libraries. More... | |
typedef std::vector< Code > | Codes |
Collection of ordered lines of code. More... | |
typedef std::vector< Rule > | Rules |
Collection of ordered rules. More... | |
typedef std::vector< std::string > | Strings |
Collection of ordered strings. More... | |
typedef std::map< std::string, std::string > | StringMap |
Dictionary (std::string) More... | |
typedef std::map< std::string, const char * > | Dictionary |
Dictionary (const char*) More... | |
typedef size_t | Start |
Start condition state type. More... | |
typedef std::set< Start > | Starts |
Set of start conditions. More... | |
typedef std::map< Start, Codes > | CodesMap |
Map of start conditions to lines of code. More... | |
typedef std::map< Start, Rules > | RulesMap |
Map of start conditions to rules. More... | |
Public Member Functions | |
void | main (int argc, char **argv) |
Main program. More... | |
Protected Attributes | |
StringMap | options |
maps option name (from the options_table) to its option value More... | |
LibraryMap | libraries |
maps regex library name ("reflex", "boost", etc) to library info More... | |
Library * | library |
the regex library selected More... | |
Strings | conditions |
"INITIAL" start condition etc. defined with x name More... | |
Strings | patterns |
regex patterns for each start condition More... | |
Starts | inclusive |
inclusive start conditions More... | |
StringMap | definitions |
map of {name} to regex More... | |
RulesMap | rules |
<Start_i>regex_j action for Start i Rule j More... | |
Codes | section_top |
top{ user code %} in section 1 container More... | |
Codes | section_class |
class{ class code %} in section 1 container More... | |
Codes | section_init |
init{ init code %} in section 1 container More... | |
Codes | section_begin |
begin{ begin scanning code %} in section 1 container More... | |
Codes | section_1 |
%{ user code %} in section 1 container More... | |
CodesMap | section_2 |
lexer user code in section 2 container More... | |
Codes | section_3 |
main user code in section 3 container More... | |
std::string | infile |
input file name More... | |
reflex::BufferedInput | in |
input lex spec More... | |
std::ostream * | out |
output stream More... | |
std::string | line |
current line read from input More... | |
size_t | lineno |
current line number at input More... | |
size_t | linelen |
current line length More... | |
bool | color_term |
terminal supports colors More... | |
Private Member Functions | |
void | init (int argc, char **argv) |
Reflex initialization. More... | |
void | version () |
Display version information and exit. More... | |
void | help (const char *message=NULL, const char *arg=NULL) |
Display help information with an optional diagnostic message and exit. More... | |
void | set_library () |
Set/reset regex library matcher. More... | |
void | parse () |
Parse lex specification input. More... | |
void | parse_section_1 () |
Parse section 1 of a lex specification. More... | |
void | parse_section_2 () |
Parse section 2 of a lex specification. More... | |
void | parse_section_3 () |
Parse section 3 of a lex specification. More... | |
void | include (const std::string &filename) |
Parse the specified %include file. More... | |
void | write () |
Write lex.yy.cpp. More... | |
void | write_banner (const char *title) |
Write a banner in lex.yy.cpp. More... | |
void | write_prelude () |
Write the prelude to lex.yy.cpp. More... | |
void | write_defines () |
Write Flex-compatible #defines to lex.yy.cpp. More... | |
void | write_class () |
Write the lexer class to lex.yy.cpp. More... | |
void | write_section_top () |
Write %top code to lex.yy.cpp. More... | |
void | write_section_class () |
Write %class code to lex.yy.cpp. More... | |
void | write_section_init () |
Write %init code to lex.yy.cpp. More... | |
void | write_section_begin () |
Write %begin code to lex.yy.cpp. More... | |
void | write_perf_report () |
Write perf_report code to lex.yy.cpp. More... | |
void | write_section_1 () |
Write section 1 user-defined code to lex.yy.cpp. More... | |
void | write_section_3 () |
Write section 3 user-defined code to lex.yy.cpp. More... | |
void | write_code (const Codes &codes) |
Write lines of code to lex.yy.cpp annotated with line source info. More... | |
void | write_code (const Code &code) |
Write a line(s) of code to lex.yy.cpp annotated with line source info. More... | |
void | write_lexer () |
Write lexer code and lex() method code. More... | |
void | write_main () |
Write main() to lex.yy.cpp. More... | |
void | write_regex (const std::string *condition, const std::string ®ex) |
Write regex string to lex.yy.cpp by escaping \ and ", prevent trigraphs, very long strings are represented by character arrays. More... | |
void | write_namespace_open () |
Write namespace openings NAME {. More... | |
void | write_namespace_close () |
Write namespace closing scope } // NAME. More... | |
void | write_namespace_scope () |
Write namespace scope NAME :: More... | |
void | undot_namespace (std::string &s) |
Replace all . by :: in namespace name. More... | |
void | write_final () |
Finalize and display usage report. More... | |
void | write_regexp_file () |
Save file with regex patterns when option –regexp-file is specified. More... | |
void | write_header_file () |
Save header file when option –header-file is specified. More... | |
bool | get_line () |
Fetch next line from the input, return true if ok. More... | |
bool | skip_comment (size_t &pos) |
Advance pos over white space and comments, return true if ok. More... | |
bool | is (const char *s) |
Match case-insensitive string s while ignoring the rest of the line, return true if OK. More... | |
bool | ins (const char *s) |
Match case-insensitive string s at any indent while ignoring the rest of the line, return true if OK. More... | |
bool | br (size_t pos, const char *s=NULL) |
Match s then look for a '{' at the end of the line (skipping whitespace) and return true, false otherwise (pos is unchanged) More... | |
bool | as (size_t &pos, const char *s) |
Advance pos to match case-insensitive initial part of the string s followed by white space, return true if OK. More... | |
bool | ws (size_t &pos) |
Advance pos over whitespace, returns true if whitespace was found. More... | |
bool | eq (size_t &pos) |
Advance pos over '=' and whitespace when present, return true if OK. More... | |
bool | nl (size_t &pos) |
Advance pos to end of line while skipping whitespace, return true if end of line. More... | |
bool | is_code () |
Check if current line starts a block of code or a comment. More... | |
bool | is_top_code () |
Check if current line starts a block of top code. More... | |
bool | is_class_code () |
Check if current line starts a block of class code. More... | |
bool | is_init_code () |
Check if current line starts a block of init code. More... | |
bool | is_begin_code () |
Check if current line starts a block of begin code. More... | |
std::string | get_name (size_t &pos) |
Advance pos over name (letters, digits, ., -, _ or any non-ASCII character > U+007F), return name. More... | |
std::string | get_option (size_t &pos) |
Advance pos over option name (letters, digits, +/hyphen/underscore), return name. More... | |
std::string | get_start (size_t &pos) |
Advance pos over start condition name (an ASCII C++ identifier or C++11 Unicode identifier), return name. More... | |
std::string | get_string (size_t &pos) |
Advance pos over quoted string, return string. More... | |
bool | get_pattern (size_t &pos, std::string &pattern, std::string ®ex) |
Get pattern and its regex form converted to a format understood by the selected regex engine library. More... | |
std::string | get_namespace (size_t &pos) |
Advance pos over option name or namespace (letters, digits, ::, ., -, _ or any non-ASCII character > U+007F), return name. More... | |
std::string | get_code (size_t &pos) |
Get line(s) of code, %{ %}, %top, %class, %init, and %begin. More... | |
std::string | escape_bs (const std::string &s) |
Returns string with all \ replaced by \ to stringify file paths. More... | |
std::string | upper_name (const std::string &s) |
Returns string in upper case as a name, replacing non-alphanum by underscore. More... | |
std::string | param_args (const std::string &s) |
Extract a list of argument names from function parameters. More... | |
bool | get_starts (size_t &pos, Starts &starts) |
Add start conditions <start1,start2,...> or subtract them with <-start1,-start2,...> More... | |
void | abort (const char *message, const char *arg=NULL) |
Abort with an error message. More... | |
void | error (const char *message, const char *arg=NULL, size_t at_lineno=0) |
Report an error and exit. More... | |
void | warning (const char *message, const char *arg=NULL, size_t at_lineno=0) |
Report a warning. More... | |
const char * | SGR (const char *code) |
RE/flex scanner generator class, a variation of the classic "lex" tool to generate scanners.
More info TODO
The Lex specification file extension is .l
, but also .lex
, .ll
, .l++
, .lxx
, and .lpp
are in use.
typedef std::vector<Code> Reflex::Codes |
Collection of ordered lines of code.
typedef std::map<Start,Codes> Reflex::CodesMap |
Map of start conditions to lines of code.
typedef std::map<std::string,const char*> Reflex::Dictionary |
Dictionary (const char*)
typedef std::map<std::string,Library> Reflex::LibraryMap |
Dictionary of regex libraries.
typedef std::vector<Rule> Reflex::Rules |
Collection of ordered rules.
typedef std::map<Start,Rules> Reflex::RulesMap |
Map of start conditions to rules.
typedef size_t Reflex::Start |
Start condition state type.
typedef std::set<Start> Reflex::Starts |
Set of start conditions.
typedef std::map<std::string,std::string> Reflex::StringMap |
Dictionary (std::string)
typedef std::vector<std::string> Reflex::Strings |
Collection of ordered strings.
|
private |
Abort with an error message.
|
private |
Advance pos to match case-insensitive initial part of the string s followed by white space, return true if OK.
|
private |
Match s then look for a '{' at the end of the line (skipping whitespace) and return true, false otherwise (pos is unchanged)
|
private |
Advance pos over '=' and whitespace when present, return true if OK.
|
private |
Report an error and exit.
|
private |
Returns string with all \ replaced by \ to stringify file paths.
|
private |
Get line(s) of code, %{ %}, %top, %class, %init, and %begin.
|
private |
Fetch next line from the input, return true if ok.
|
private |
Advance pos over name (letters, digits, ., -, _ or any non-ASCII character > U+007F), return name.
|
private |
Advance pos over option name or namespace (letters, digits, ::, ., -, _ or any non-ASCII character > U+007F), return name.
|
private |
Advance pos over option name (letters, digits, +/hyphen/underscore), return name.
|
private |
Get pattern and its regex form converted to a format understood by the selected regex engine library.
|
private |
Advance pos over start condition name (an ASCII C++ identifier or C++11 Unicode identifier), return name.
|
private |
Add start conditions <start1,start2,...> or subtract them with <-start1,-start2,...>
|
private |
Advance pos over quoted string, return string.
|
private |
Display help information with an optional diagnostic message and exit.
|
private |
Parse the specified %include file.
|
private |
Reflex initialization.
|
private |
Match case-insensitive string s at any indent while ignoring the rest of the line, return true if OK.
|
private |
Match case-insensitive string s while ignoring the rest of the line, return true if OK.
|
private |
Check if current line starts a block of begin code.
|
private |
Check if current line starts a block of class code.
|
private |
Check if current line starts a block of code or a comment.
|
private |
Check if current line starts a block of init code.
|
private |
Check if current line starts a block of top code.
void Reflex::main | ( | int | argc, |
char ** | argv | ||
) |
Main program.
|
private |
Advance pos to end of line while skipping whitespace, return true if end of line.
|
private |
Extract a list of argument names from function parameters.
|
private |
Parse lex specification input.
|
private |
Parse section 1 of a lex specification.
|
private |
Parse section 2 of a lex specification.
|
private |
Parse section 3 of a lex specification.
|
private |
Set/reset regex library matcher.
|
inlineprivate |
|
private |
Advance pos over white space and comments, return true if ok.
|
private |
Replace all . by :: in namespace name.
|
private |
Returns string in upper case as a name, replacing non-alphanum by underscore.
|
private |
Display version information and exit.
|
private |
Report a warning.
|
private |
Write lex.yy.cpp.
|
private |
Write a banner in lex.yy.cpp.
|
private |
Write the lexer class to lex.yy.cpp.
|
private |
Write lines of code to lex.yy.cpp annotated with line source info.
|
private |
Write a line(s) of code to lex.yy.cpp annotated with line source info.
|
private |
Write Flex-compatible #defines to lex.yy.cpp.
|
private |
Finalize and display usage report.
|
private |
Save header file when option –header-file is specified.
|
private |
Write lexer code and lex() method code.
|
private |
Write main() to lex.yy.cpp.
|
private |
Write namespace closing scope } // NAME.
|
private |
Write namespace openings NAME {.
|
private |
Write namespace scope NAME ::
|
private |
Write perf_report code to lex.yy.cpp.
|
private |
Write the prelude to lex.yy.cpp.
|
private |
Write regex string to lex.yy.cpp by escaping \ and ", prevent trigraphs, very long strings are represented by character arrays.
|
private |
Save file with regex patterns when option –regexp-file is specified.
|
private |
Write section 1 user-defined code to lex.yy.cpp.
|
private |
Write section 3 user-defined code to lex.yy.cpp.
|
private |
Write %begin code to lex.yy.cpp.
|
private |
Write %class code to lex.yy.cpp.
|
private |
Write %init code to lex.yy.cpp.
|
private |
Write %top code to lex.yy.cpp.
|
private |
Advance pos over whitespace, returns true if whitespace was found.
|
protected |
terminal supports colors
|
protected |
"INITIAL" start condition etc. defined with x name
|
protected |
map of {name} to regex
|
protected |
input lex spec
|
protected |
inclusive start conditions
|
protected |
input file name
|
protected |
maps regex library name ("reflex", "boost", etc) to library info
|
protected |
the regex library selected
|
protected |
current line read from input
|
protected |
current line length
|
protected |
current line number at input
|
protected |
maps option name (from the options_table) to its option value
|
protected |
output stream
|
protected |
regex patterns for each start condition
|
protected |
%{ user code %} in section 1 container
|
protected |
lexer user code in section 2 container
|
protected |
main user code in section 3 container
|
protected |
begin{ begin scanning code %} in section 1 container
|
protected |
class{ class code %} in section 1 container
|
protected |
init{ init code %} in section 1 container
|
protected |
top{ user code %} in section 1 container