mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Added --packrat option to peglint
This commit is contained in:
parent
217d551744
commit
fcd0b277ab
@ -597,6 +597,7 @@ usage: grammar_file_path [source_file_path]
|
|||||||
|
|
||||||
options:
|
options:
|
||||||
--source: source text
|
--source: source text
|
||||||
|
--packrat: enable packrat memoise
|
||||||
--ast: show AST tree
|
--ast: show AST tree
|
||||||
--opt, --opt-all: optimaze all AST nodes except nodes selected with `no_ast_opt` instruction
|
--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
|
--opt-only: optimaze only AST nodes selected with `no_ast_opt` instruction
|
||||||
|
@ -8,6 +8,7 @@ usage: grammar_file_path [source_file_path]
|
|||||||
|
|
||||||
options:
|
options:
|
||||||
--ast: show AST tree
|
--ast: show AST tree
|
||||||
|
--packrat: enable packrat memoise
|
||||||
--opt, --opt-all: optimaze all AST nodes except nodes selected with `no_ast_opt` instruction
|
--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
|
--opt-only: optimaze only AST nodes selected with `no_ast_opt` instruction
|
||||||
--source: source text
|
--source: source text
|
||||||
|
@ -33,6 +33,7 @@ inline vector<string> split(const string &s, char delim) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
|
auto opt_packrat = false;
|
||||||
auto opt_ast = false;
|
auto opt_ast = false;
|
||||||
auto opt_optimize = false;
|
auto opt_optimize = false;
|
||||||
auto opt_mode = true;
|
auto opt_mode = true;
|
||||||
@ -47,6 +48,8 @@ int main(int argc, const char **argv) {
|
|||||||
auto arg = argv[argi++];
|
auto arg = argv[argi++];
|
||||||
if (string("--help") == arg) {
|
if (string("--help") == arg) {
|
||||||
opt_help = true;
|
opt_help = true;
|
||||||
|
} else if (string("--packrat") == arg) {
|
||||||
|
opt_packrat = true;
|
||||||
} else if (string("--ast") == arg) {
|
} else if (string("--ast") == arg) {
|
||||||
opt_ast = true;
|
opt_ast = true;
|
||||||
} else if (string("--opt") == arg || string("--opt-all") == arg) {
|
} else if (string("--opt") == arg || string("--opt-all") == arg) {
|
||||||
@ -73,6 +76,7 @@ int main(int argc, const char **argv) {
|
|||||||
|
|
||||||
options:
|
options:
|
||||||
--source: source text
|
--source: source text
|
||||||
|
--packrat: enable packrat memoise
|
||||||
--ast: show AST tree
|
--ast: show AST tree
|
||||||
--opt, --opt-all: optimaze all AST nodes except nodes selected with `no_ast_opt` instruction
|
--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
|
--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;
|
cerr << source_path << ":" << ln << ":" << col << ": " << msg << endl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (opt_packrat) {
|
||||||
|
parser.enable_packrat_parsing();
|
||||||
|
}
|
||||||
|
|
||||||
if (opt_trace) {
|
if (opt_trace) {
|
||||||
size_t prev_pos = 0;
|
size_t prev_pos = 0;
|
||||||
parser.enable_trace(
|
parser.enable_trace(
|
||||||
|
Loading…
Reference in New Issue
Block a user