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

support for <expr> by <expr> loops #837

Merged
merged 2 commits into from
Feb 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/ast.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions lib/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/lexer.ls
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ exports <<<
id = []
@fset 'for' true
@fset 'to' false
@fset 'by' true
case 'then'
@fset 'for' false
@fset 'to' false
Expand Down Expand Up @@ -264,7 +265,7 @@ exports <<<
then tag = 'RANGE_BY'
else if ']' in @closes
tag = 'BY'
else if @fget 'by'
else if @fget 'by' and last.0 is not 'FOR'
tag = 'BY'
@fset 'by' false
case 'ever' then if last.0 is 'FOR'
Expand Down
7 changes: 7 additions & 0 deletions test/loop.ls
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,13 @@ eq '0 1 2 3' [f! for til 4].join ' '
i = 0
eq '2 4 6' [f! for til 4 when f!].join ' '

x = []
for <[one two three]> by -1 then x.push ..
eq 'three two one' x.join ' '

x = [.. for <[one two three]> by -1]
eq 'three two one' x.join ' '

# index var outside loop
for v, k in [1]
void
Expand Down