Repository navigation
Implement correct for loop behavior #316
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
31949c3
string: Rework display builtins
CohenArthur f3db4da
loop_block: Add proper implementation for for loop
CohenArthur a7de802
stdlib/iter: Add iter.value()
CohenArthur 513070e
error: Display more information in fmt::Display
CohenArthur 4a40704
stdlib/range: Fix range.current()
CohenArthur b064791
builtins: Fix tests
CohenArthur 404193c
loops: Add functional tests
CohenArthur dbe55bc
stdlib/range: Only iter up to end - 1 included
CohenArthur 42a65d1
loop_block: Remove test for now
CohenArthur cf5a706
loop_block: Add unit test for for loop
CohenArthur 56e6c11
builtins: Fix tests to improve coverage
CohenArthur 92f21be
loop_block: Cleanup debug code
CohenArthur e6095aa
for_loop: Add more functional tests
CohenArthur d2e0e25
loop_block: Add assertion in valid_for_block test
CohenArthur ba698fd
stdlib/string: Add FIXME for once newlines are handled correctly
CohenArthur 3becc43
loop_block: Remove fixed comment
CohenArthur 9b19269
loop_block: Add more precisions to FIXME
CohenArthur 663d019
stdlib/range: Add FIXME for bad code
CohenArthur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
10000
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
10BC8
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| for i in 0.range(3) { | ||
| "jk".print() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| for i in range(0, 1) { | ||
| { | ||
| print("jinko"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| for i in range(0, 0) { | ||
| println("This shouldn't be printed") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| tests: | ||
| - name: "Iterate over range 10 times" | ||
| binary: "target/debug/jinko" | ||
| args: | ||
| - "tests/ft/loops/for_loop.jk" | ||
| stdout: "jkjkjk" | ||
| - name: "Iterate over range 0 times" | ||
| binary: "target/debug/jinko" | ||
| args: | ||
| - "tests/ft/loops/for_loop_zero.jk" | ||
| stdout: "" | ||
| - name: "Iterate over range 1 time" | ||
| binary: "target/debug/jinko" | ||
| args: | ||
| - "tests/ft/loops/for_loop_one.jk" | ||
| stdout: "jinko" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| s = "jinko".concat(".jk") | ||
| s.display() | ||
| s.print() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be documented. The user needs to be aware that he is not allowed to use identifier starting with a '+' sign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it explicitly needs to be documented, as if the user tries to do it they will simply encounter a parse error (identifiers can only be comprised of underscores, digits and letters). Here, since we are creating them directly from the interpreter, we're allowed to, but it's an "edge case" and abusing the language since we're not going through the parser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documenting it to understand why there is a parser error is useful imao
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean in the parser or here? And do you mean by emitting an error or adding a comment? Because the user will never see those variables, ever. Think of them as the
__<ident>variables we were talking about in gcc