Added --packrat option to peglint

This commit is contained in:
yhirose 2021-01-23 22:58:23 -05:00
parent 217d551744
commit fcd0b277ab
3 changed files with 10 additions and 0 deletions

View File

@ -597,6 +597,7 @@ usage: grammar_file_path [source_file_path]
options:
--source: source text
--packrat: enable packrat memoise
--ast: show AST tree
--opt, --opt-all: optimaze all AST nodes except nodes selected with `no_ast_opt` instruction
--opt-only: optimaze only AST nodes selected with `no_ast_opt` instruction

View File

@ -8,6 +8,7 @@ usage: grammar_file_path [source_file_path]
options:
--ast: show AST tree
--packrat: enable packrat memoise
--opt, --opt-all: optimaze all AST nodes except nodes selected with `no_ast_opt` instruction
--opt-only: optimaze only AST nodes selected with `no_ast_opt` instruction
--source: source text

View File

@ -33,6 +33,7 @@ inline vector<string> split(const string &s, char delim) {
}
int main(int argc, const char **argv) {
auto opt_packrat = false;
auto opt_ast = false;
auto opt_optimize = false;
auto opt_mode = true;
@ -47,6 +48,8 @@ int main(int argc, const char **argv) {
auto arg = argv[argi++];
if (string("--help") == arg) {
opt_help = true;
} else if (string("--packrat") == arg) {
opt_packrat = true;
} else if (string("--ast") == arg) {
opt_ast = true;
} else if (string("--opt") == arg || string("--opt-all") == arg) {
@ -73,6 +76,7 @@ int main(int argc, const char **argv) {
options:
--source: source text
--packrat: enable packrat memoise
--ast: show AST tree
--opt, --opt-all: optimaze all AST nodes except nodes selected with `no_ast_opt` instruction
--opt-only: optimaze only AST nodes selected with `no_ast_opt` instruction
@ -115,6 +119,10 @@ int main(int argc, const char **argv) {
cerr << source_path << ":" << ln << ":" << col << ": " << msg << endl;
};
if (opt_packrat) {
parser.enable_packrat_parsing();
}
if (opt_trace) {
size_t prev_pos = 0;
parser.enable_trace(