-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 30 #209
Issue 30 #209
Conversation
What's blocking this? Would be great to see it merged. |
@dmajda , what you think about this? Now also included testcases and, I think, it may be merged... |
… and handling in passes. Conflicts: src/parser.pegjs
…, optimized for speed.
…writing. Conflicts: src/parser.pegjs
Conflicts: spec/compiler/passes/generate-bytecode.spec.js
…o more elements. Example: start = 'a'|2..3, ','|; on input: a,a,a, now failed. If you need optional trailing delimiter, specify it explicitly in grammar: start = 'a'|2..3, ','| ','?;
Conflicts: spec/parser.spec.js
Conflicts: lib/parser.js
@lavelle This is a pull request for a feature I clearly labeled as post-1.0.0, so it wasn't a high priority for me.
@Mingun Sorry, I won't merge this, for several reasons:
|
…t syntax -- for this purpose there will be separate pull request. As the result -- doesn't contain tests, they will be together with syntax. However, all tests are passed. Introduce two new opcodes: * IF_ARRLEN_MIN min, then part length, else part length * IF_ARRLEN_MAX max, then part length, else part length Introduce new AST node -- `range`, that contains expression and the minimum and maximum number of its repetition. If `node.min` is `null` or isn't positive -- check of the minimum length isn't made. If `node.max` is `null`, check of the maximum length isn't made. Unlike previous pull request (pegjs#209), there are: * no logic for reduce range expression to `optional`, `zero or more` and `one or more` expressions -- this must be made by special compiler pass; * lengths are hardcoded in bytecode, instead of are read from a stack; * no support for delimiters -- they will be in next pull request.
Sorry fo my english, I hope, that it is not so bad...
I realize issue #30 -- feature for specify exact count an min-max range of repetitions of rule, optionally delimited by
delimiter
rule/expression. Delimiter not included in result. Syntax (, delimiter
may be omitted):Now all constraints -- a
int
in grammar, but bytecode not limited by this.I add 2 opcodes to abstract VM:
IF_ARRLEN_MIN
andIF_ARRLEN_MAX
.New
IF...
opcodes use stack to get constraint and array and compiled to: