With the previous fix, the parsing algorithm could still backtrack without
making progress given slightly more sophisticated input (see added testdata for
an example).
Instead of trying to parse a temporary assignment when it *could* be one, only
parse it when we are sure that it is. This should now truly fix the issue.
The parsing function for Form first tries to parse a temp assignment, and
backtracks when an assignment cannot be parsed. When the input is "(" repeated n
times, each level of Form parsing will first try to parse the rest of the code
as an assignment and then backtrack, without making any progress. This results
in a call tree with a branching factor of 2, hence the O(2^n) complexity.
The fix is to first try to parse a head instead, and only try to parse it as a
temp assignment if it does contain "=". This fixes this particular pathological
case, although I'm not 100% sure it eliminates all possibilities of O(2^n) time
complexity.
With the introduction of the "tmp" special command, the current syntax for
temporary assignments will be deprecated and eventually go away, which will
eliminate all backtracking in the parser. In the meanwhile, this fix may be good
enough.
This case was discovered with fuzzing support in Go 1.18. Also add the fuzzing
test data.
Only depend on the tools referenced by tools/md-to-html. This uses "grep -o",
which is not part of POSIX but is supported by both GNU and BSD greps, so widely
enough.
Also remove support for the "name" field tag from eval.scanOptions - it's not
used anywhere and the use case it was intended for is handled by CamelToDashed.
- Don't require creating a Getopt object in the API.
- Add a new Parse function, and rename the existing method to Complete.
- Add an Unknown field to Option to indicate unknown options.
- Rewrite the tests.
- Numerous stylistic changes.
- Revise the introduction section.
- Link to the notes on commands taking value inputs from all such commands.
- Revise the doc on the "all" command.
- Revise references to the builtin module from the language reference.
* docs(effective-elvish): follow same style as other docs
e.g., https://elv.sh/ref/language.html
* docs(builtin): ref from take to drop
* docs(language): remove mention of :up and :down ns
* docs(fundamentals): update to new lambda format
* docs(tour): update to new lambda syntax
* docs(builtin): update to new lambda syntax
* docs(language): update to new lambda syntax
* docs(unique-semantics): update to new lambda syntax
* docs(tour): fix typo
* Revert "docs(effective-elvish): follow same style as other docs"
This reverts commit db4306a400c61f5f7b6acec7a1e1f39feb9b1ba0.
https://github.com/elves/elvish/pull/1457#discussion_r775102178
The existing `edit:add-var` documentation incorrectly implies the `$init`
value is optional. It also doesn't include any examples that are useful
in practice. This addresses both shortcomings.
* Remove a superfluous line break in the equivalent Elvish code.
* Keep code in transcripts on the same line to be correctly highlited.
* Add another example using digit-only argument names.