-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from fink-lang/partial
partials
- Loading branch information
Showing
10 changed files
with
435 additions
and
342 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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,19 @@ | ||
{curr_value, curr_loc} = import '@fink/prattler' | ||
{add_non_separating} = import '@fink/prattler/symbols' | ||
|
||
{symbol} = import '../symbols' | ||
|
||
|
||
partial = fn op: | ||
{ | ||
...symbol(op), | ||
|
||
nud: fn: fn ctx: | ||
loc = curr_loc(ctx) | ||
[{type: 'partial', value: '?', loc}, ctx] | ||
} | ||
|
||
|
||
add_partial = fn ctx: | ||
pipe ctx: | ||
add_non_separating(partial('?')) |
This file contains 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,25 @@ | ||
{decribe, it, eq, to_throw, snapshot} = import '../../testing/jest' | ||
|
||
{parse_expr} = import '../../' | ||
|
||
|
||
describe:: 'partial', fn: | ||
|
||
it:: 'parses call', fn: | ||
parse_expr(`foo(?)`) eq snapshot | ||
parse_expr(`foo.bar(?)`) eq snapshot | ||
|
||
|
||
it:: 'parses member', fn: | ||
parse_expr(`?.bar()`) eq snapshot | ||
|
||
|
||
it:: 'parses binary', fn: | ||
parse_expr(`? > 1`) eq snapshot | ||
parse_expr(`1 < ?`) eq snapshot | ||
parse_expr(`1 + ? * 3`) eq snapshot | ||
|
||
|
||
it:: 'parses str', fn: | ||
parse_expr(`'foo \${?} bar'`) eq snapshot | ||
|
This file contains 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,46 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`partial parses binary 1`] = ` | ||
comp > (1:0-1:5) | ||
partial (1:0-1:1) ? | ||
number (1:4-1:5) 1 | ||
`; | ||
|
||
exports[`partial parses binary 2`] = ` | ||
comp < (1:0-1:5) | ||
number (1:0-1:1) 1 | ||
partial (1:4-1:5) ? | ||
`; | ||
|
||
exports[`partial parses binary 3`] = ` | ||
arithm + (1:0-1:9) | ||
number (1:0-1:1) 1 | ||
arithm * (1:4-1:9) | ||
partial (1:4-1:5) ? | ||
number (1:8-1:9) 3 | ||
`; | ||
|
||
exports[`partial parses call 1`] = ` | ||
call (1:0-1:6) | ||
ident (1:0-1:3) foo | ||
partial (1:4-1:5) ? | ||
`; | ||
|
||
exports[`partial parses call 2`] = ` | ||
call (1:0-1:10) | ||
member . (1:0-1:7) | ||
ident (1:0-1:3) foo | ||
ident (1:4-1:7) bar | ||
partial (1:8-1:9) ? | ||
`; | ||
|
||
exports[`partial parses member 1`] = `partial (1:0-1:1) ?`; | ||
|
||
exports[`partial parses str 1`] = ` | ||
string ' (1:0-1:14) | ||
\`foo \` | ||
partial (1:7-1:8) ? | ||
\` bar\` | ||
`; |