Commit Graph

5757 Commits

Author SHA1 Message Date
Qi Xiao
d9eb0928e3 Bind Alt-Enter to inserting "\n". 2022-01-01 23:52:34 +00:00
Qi Xiao
11de899040 Add fuzz test for (*eval.Evaler).Check. 2022-01-01 23:52:08 +00:00
Qi Xiao
04173ee8ab Actually fix the O(2^n) code path.
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.
2022-01-01 22:52:56 +00:00
Qi Xiao
9cda3f643e parse: Fix a O(2^n) code path when input is "(" repeated n times.
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.
2022-01-01 22:20:03 +00:00
Qi Xiao
1c1227324e website: Revamp the learn index page.
- Split articles into groups.

- Add notes besides the entry for fundamentals and quick tour.
2022-01-01 16:34:05 +00:00
Qi Xiao
a5bc536f4d website: Make the tool dependency for %.html more accurate.
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.
2022-01-01 15:59:56 +00:00
Qi Xiao
7a40cf1fea website: Rename the "genblog" tool to "gensite".
Also rename internal references to the "blog" to "site" when it refers to the site as the whole (instead of https://elv.sh/blog).
2022-01-01 12:10:26 +00:00
Qi Xiao
ae91cf7b1c Fix build on Go 1.16. 2021-12-31 21:13:41 +00:00
Qi Xiao
097e32b375 pkg/eval/vals: Add ReprPlain, Repr without pretty-printing.
Also de-export NoPretty now that it is no longer needed.
2021-12-31 21:05:07 +00:00
Qi Xiao
7ed71323fd Remove a now superfluous variable in tools/imports-graph.elv. 2021-12-31 18:51:19 +00:00
Qi Xiao
32a2c4c73d Use the flag module in tools/imports-graph.elv. 2021-12-31 18:49:59 +00:00
Qi Xiao
5bf688cf4d New flag module. 2021-12-31 18:03:24 +00:00
Qi Xiao
de3ac3166d Add a new conversion utility vals.ScanMapToGo. 2021-12-31 18:00:36 +00:00
Qi Xiao
e134ef51e3 Handle all-cap abbreviations in strutil.CamelToDashed.
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.
2021-12-31 16:54:32 +00:00
Qi Xiao
e01e5dd2f5 pkg/getopt: Revamp the API and implementation.
- 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.
2021-12-31 14:36:01 +00:00
Qi Xiao
d9e14da0db Export eval.Closure and (*eval.Frame).Fork. 2021-12-31 14:28:30 +00:00
Qi Xiao
4906c4aa28 Fix doc for the call builtin. 2021-12-31 12:46:47 +00:00
Qi Xiao
a8844a34f8 Check that blocks in control flows don't have arguments or options.
It is now a compile-time error if they do. This fixes #1456.
2021-12-30 13:49:48 +00:00
Qi Xiao
de5f0e0d32 Add new util vals.MakeListFromStrings. 2021-12-30 13:09:18 +00:00
Qi Xiao
c46fd60270 Properly clear the filter when ascending or descending in nav mode.
Also add regression tests for this behavior.
2021-12-30 12:58:34 +00:00
Qi Xiao
7da15f48fb pkg/eval/vals: Add more conversion helpers.
Also update the comment in conversion.go.
2021-12-29 22:32:25 +00:00
Qi Xiao
f7b5df5de5 Add a new "call" command. 2021-12-29 01:16:44 +00:00
Qi Xiao
46774d7078 Use (*Evaler).Chdir for changing directory in navigation mode.
This will run the hooks and update $E:PWD correctly.
2021-12-28 17:52:09 +00:00
Qi Xiao
1910948a86 edit.md: Upgrade syntax. 2021-12-28 17:11:59 +00:00
Qi Xiao
d95758fd29 website/template.html: Hide navbar after jumping to an anchor. 2021-12-28 15:56:52 +00:00
Qi Xiao
77897bdaa0 tour.md: Fix format of a key. 2021-12-28 13:36:32 +00:00
Ian Max Andolina
c8fce87de6
Small fixup for Function doc (#1458)
The chunk starting "There must be no space between ] and {; ..." is no longer relevant.
2021-12-28 13:32:30 +00:00
Qi Xiao
603421d8cc Update ttyshots with a comment on how to regenerate.
Also explain in ttyshot/README.md that the output of commands has to be manually appended.
2021-12-28 13:24:33 +00:00
Qi Xiao
71d885c4fa website/Makefile: add @ttyshot dependencies.
Also rename the ref-deps script to extra-deps now that its scope is a bit larger.
2021-12-28 13:13:43 +00:00
Qi Xiao
1ec9c95142 Fix the doc for ttyshots.
- Wrap the command in "print" to get byte output.

- Use global-binding to ensure that the key works in all modes.
2021-12-28 13:01:21 +00:00
Qi Xiao
1d36d299b8 Put flags for prettier in .prettierrc.
Also reformat tools/checkstyle-md.sh.
2021-12-28 12:54:30 +00:00
Qi Xiao
327d3e716b language.md: Revise the doc for escape sequences.
- Arrange all sequences into 3 groups.

- For escape sequences that contain variable characters, only put the leading
  marker in `code font`.
2021-12-28 12:43:36 +00:00
Qi Xiao
7da4b58f2f Revise doc for the builtin module.
- 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.
2021-12-28 12:01:35 +00:00
Qi Xiao
44e300095b website/learn/tour.md: Fix "\n". 2021-12-28 11:12:46 +00:00
Qi Xiao
a5ae894a5c website/ref/language.md: Fix the comment on "echo \*". 2021-12-28 11:12:26 +00:00
Qi Xiao
560bd17c17 pkg/eval: Break up builtin_fn_container.go.
- range -> builtin_fn_num.go

- all, one, take, drop, count, order -> new builtin_fn_stream.go

- repeat -> builtin_fn_io.go

- compare -> builtin_fn_pred.go
2021-12-26 12:22:14 +00:00
Christopher Loessl
bd76b46b8e
Doc update (#1457)
* 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
2021-12-26 12:02:00 +00:00
Qi Xiao
8ecac48251 More tweaks to the tour.
- Wording tweaks

- Retake all ttyshots
2021-12-24 01:56:41 +00:00
Qi Xiao
b1460e4269 Wording tweak for the doc of edit:add-var. 2021-12-24 01:40:26 +00:00
Kurtis Rader
9cf2cfffa6 Cleanups to rc.elv references 2021-12-24 01:40:01 +00:00
Christopher Loessl
95a0deae6f docs(effective-elvish): update to new lambda 2021-12-23 20:30:34 +00:00
Qi Xiao
3bdd7b49e8 Fixup for #1452 2021-12-20 13:31:53 +00:00
Kurtis Rader
91f21858ac More improvements to edit:add-var documentation
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.
2021-12-20 13:13:56 +00:00
Qi Xiao
db0cf05893 Expand the doc of edit:add-var. 2021-12-18 11:58:12 +00:00
Qi Xiao
c71f46642b Update eawk's doc.
* 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.
2021-12-17 19:53:30 +00:00
Qi Xiao
848b585b1c Document which characters can be used in variable names without quoting. 2021-12-17 19:31:49 +00:00
Qi Xiao
046e02869d pkg/eval/vals: Document the use of 0 in UnifyNums. 2021-12-17 10:52:44 +00:00
Qi Xiao
a42b29802a Update .codecov.yml with file rename. 2021-12-17 01:07:20 +00:00
Qi Xiao
51a388b9ec Add imports-graph.elv, a script to visualize package dependencies.
This script focuses on showing the dependencies between source packages in src.elv.sh. It outputs a DOT file.
2021-12-17 00:52:59 +00:00
Qi Xiao
7463203bda pkg/mods: Import pkg/mods/unix. 2021-12-17 00:50:53 +00:00