Skip to content
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

Parser Refactoring, Unit Tests Added, & New Features #219

Merged
merged 6 commits into from
Mar 4, 2017
Merged

Parser Refactoring, Unit Tests Added, & New Features #219

merged 6 commits into from
Mar 4, 2017

Conversation

mmstick
Copy link
Contributor

@mmstick mmstick commented Mar 4, 2017

Refactoring

This will primarily refactor all the parsing-related content into a new parser module. The pipeline parsing logic was removed from the peg module and placed into it's own module.

Unit Tests

Unit tests were added for the new for grammar and statement splitter, so there's more coverage now. A number of tests were removed for the pipleline logic as it's no valid since landing the statement splitter.

StatementSplitter Improvements

The statement splitter was improved to now ignore comments, as it should. The following command:

echo $(echo one #two); echo three # four

Will thus split into:

echo $(echo one #two)
echo three

(Seems highlight.js doesn't properly parse comments)

The statement splitter is now also integrated with the rest of the shell's functionality (scripts, init script, source, etc.) instead of just the REPL shell alone.

Process Recursion

It's now possible to perform process recursion, like so:

echo $(echo $(echo one))

Context History Improvement

In addition, a small change was appended that improves the usefulness of navigating history when a previous command contained multiple statements, which also disables the context history for commands executed via scripts (as other shells do it).

This will merely refactor all the parsing-related content into a new
parser module. The pipeline parsing logic was removed from the peg
module and placed into it's own module. Unit tests were added for the
new `for` grammar and statement splitter.
Currently, the context history is being updated per statement, which is
not ideal when there are multiple statements supplied at the same time.
With this change, pressing the up key will give the full command with
all statements supplied, versus individual statements. IE: when pressing
the up key after the following expression, the context will display the
original command, rather than `end`:

for i in 1..5; echo $i; end
The StatementSplitter eliminates the need for logic tracking comments,
multiple statements, and newlines
@mmstick
Copy link
Contributor Author

mmstick commented Mar 4, 2017

Heads up: about to land support for process recursion

@mmstick mmstick changed the title Refactor Parsing Logic & Add Unit Tests Parser Refactoring, Unit Tests Added, & New Features Mar 4, 2017
@jackpot51
Copy link
Member

This is really cool - ion is becoming a shell I can use by default

@jackpot51 jackpot51 merged commit 1e31f15 into redox-os:master Mar 4, 2017
@mmstick
Copy link
Contributor Author

mmstick commented Mar 4, 2017

Later today I'll have a fix for single quotes within process expansions. Seems you can't write commands like so:

echo $(git branch | rg '[*]')

@mmstick
Copy link
Contributor Author

mmstick commented Mar 4, 2017

And then it seems work needs to be done to allow for nested for loops.

@jackpot51
Copy link
Member

Sounds good, thanks @mmstick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants