Skip to content

Commit 963e981

Browse files
authored
Merge pull request #39 from fink-lang/upgrade-parser
feat(parser): upgrade to latest prattler
2 parents 34dc3a0 + 248665a commit 963e981

33 files changed

+211
-252
lines changed

package-lock.json

Lines changed: 45 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"release": "semantic-release"
3131
},
3232
"dependencies": {
33-
"@fink/prattler": "^2.0.0"
33+
"@fink/prattler": "^3.0.0"
3434
},
3535
"devDependencies": {
3636
"@fink/cli": "^2.3.0",

src/lang/arithmitic/index.fnk

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{add_operator_like} = import '@fink/prattler/symbols'
1+
{add_operator} = import '@fink/prattler/symbols'
22

33
{infix, infix_right} = import '../generic/infix'
44
{prefix} = import '../generic/prefix'
@@ -11,12 +11,12 @@ arithm_prefix = fn op: prefix:: op, 'arithm_prefix'
1111

1212
add_arithmetic_operators = fn ctx:
1313
pipe ctx:
14-
add_operator_like:: arithm:: '+'
15-
add_operator_like:: arithm:: '-'
14+
add_operator:: arithm:: '+'
15+
add_operator:: arithm:: '-'
1616

17-
add_operator_like:: arithm:: '*'
18-
add_operator_like:: arithm:: '/'
19-
add_operator_like:: arithm:: '%'
20-
add_operator_like:: arithm_right:: '^'
17+
add_operator:: arithm:: '*'
18+
add_operator:: arithm:: '/'
19+
add_operator:: arithm:: '%'
20+
add_operator:: arithm_right:: '^'
2121

22-
add_operator_like:: arithm_prefix:: '-'
22+
add_operator:: arithm_prefix:: '-'

src/lang/assignment/index.fnk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{add_non_binding, add_operator_like} = import '@fink/prattler/symbols'
1+
{add_operator} = import '@fink/prattler/symbols'
22
{infix_right} = import '../generic/infix'
33

44

@@ -7,4 +7,4 @@ assign = fn op: infix_right:: op, 'assign'
77

88
add_assignment_operators = fn ctx:
99
pipe ctx:
10-
add_operator_like:: assign:: '='
10+
add_operator:: assign:: '='

src/lang/call/call.fnk

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ call_no_parens = fn op:
4242
params:: ctx
4343
else:
4444
[{exprs, comments}, next_ctx] = get_block:: ctx
45-
# TODO: remove backward compatibility
46-
[...args] = pipe exprs:
47-
filter expr: expr.value != ','
48-
49-
[args, next_ctx, comments]
45+
[exprs, next_ctx, comments]
5046

5147
{start: end} = curr_loc:: next_ctx
5248

src/lang/call/call.test.fnk

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe:: 'call() - parsing failures', fn:
3333
1| foobar(
3434
^
3535

36-
Expected ')' but found Symbol(end).`
36+
Expected one of [ ')' ] but found Symbol(end).`
3737

3838

3939
it:: `throws when missing ')'`, fn:
@@ -44,7 +44,7 @@ describe:: 'call() - parsing failures', fn:
4444
1| foobar(1:)
4545
^
4646

47-
Expected ')' but found ':'.`
47+
Expected one of [ ')' ] but found ':'.`
4848

4949

5050
describe:: 'call:: ...', fn:
@@ -67,16 +67,6 @@ describe:: 'call:: ...', fn:
6767
`
6868
to_match_snapshot
6969

70-
it:: 'parses multiline with comma (TODO)', fn:
71-
expect::
72-
parse_expr:: `
73-
foo::
74-
bar,
75-
ni,
76-
shrub
77-
`
78-
to_match_snapshot
79-
8070

8171
describe:: 'pipe foo: ...', fn:
8272

src/lang/call/call.test.fnk.snap

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ call (1:0-6:20)
3333
# trailing comment
3434
`;
3535

36-
exports[`call:: ... parses multiline with comma (TODO) 1`] = `
37-
call (1:0-4:2)
38-
ident (1:0-1:3) foo
39-
ident (2:2-2:5) bar
40-
ident (3:2-3:4) ni
41-
ident (4:2-4:7) shrub
42-
43-
`;
44-
4536
exports[`call:: ... parses single line 1`] = `
4637
call (1:0-1:15)
4738
ident (1:0-1:6) foobar

src/lang/call/index.fnk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
add_operator_like, add_non_binding, add_non_separating
2+
add_operator, add_separator, add_non_separating
33
} = import '@fink/prattler/symbols'
44

55
{call, call_no_parens} = import './call'
@@ -9,8 +9,8 @@
99

1010
add_call_operators = fn ctx:
1111
pipe ctx:
12-
add_operator_like:: call:: '('
13-
add_non_binding:: symbol:: ','
14-
add_non_binding:: symbol:: ')'
15-
add_operator_like:: call_no_parens:: '::'
12+
add_operator:: call:: '('
13+
add_separator:: symbol:: ','
14+
add_separator:: symbol:: ')'
15+
add_operator:: call_no_parens:: '::'
1616
add_non_separating:: named_block:: 'pipe'

src/lang/colon/index.fnk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{add_operator_like} = import '@fink/prattler/symbols'
1+
{add_operator} = import '@fink/prattler/symbols'
22

33
{symbol} = import '../symbols'
44
{get_block} = import '../block'
@@ -17,6 +17,6 @@ colon = fn op, type:
1717

1818
add_colon = fn ctx:
1919
pipe ctx:
20-
add_operator_like:: colon:: ':', 'block'
20+
add_operator:: colon:: ':', 'block'
2121

2222

src/lang/comments/comment.fnk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
next_is_end, next_loc, collect_text, advance, expression
2+
next_is_end, next_is, next_loc, collect_text, advance, expression
33
} = import '@fink/prattler'
44

55
{next_is_unindented} = import '../indentation'
@@ -12,7 +12,7 @@ collect_comments = fn ctx, op:
1212
comment = {op, ...text}
1313

1414
match next_ctx:
15-
{next_token: {value: '#'}}:
15+
next_is:: ?, '#':
1616
[comments, final_ctx] = collect_comments::
1717
advance:: next_ctx
1818
op

src/lang/comments/index.fnk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{add_non_binding} = import '@fink/prattler/symbols'
1+
{add_separator} = import '@fink/prattler/symbols'
22

33
{comment} = import './comment'
44
{doc_comment} = import './doc-comment'
55

66

77
add_comments = fn ctx:
88
pipe ctx:
9-
add_non_binding:: comment:: '#'
10-
add_non_binding:: doc_comment:: '---'
9+
add_separator:: comment:: '#'
10+
add_separator:: doc_comment:: '---'

src/lang/comparison/index.fnk

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
{add_operator_like} = import '@fink/prattler/symbols'
1+
{add_operator} = import '@fink/prattler/symbols'
22
{infix} = import '../generic/infix'
33

44

55
comp = fn op: infix:: op, 'comp'
66

7-
7+
# TODO: support combining e.g. 0 < foo < 10
88
add_comparison_operators = fn ctx:
99
pipe ctx:
10-
add_operator_like:: comp:: '=='
11-
add_operator_like:: comp:: '!='
12-
add_operator_like:: comp:: '>='
13-
add_operator_like:: comp:: '<='
14-
add_operator_like:: comp:: '>'
15-
add_operator_like:: comp:: '<'
10+
add_operator:: comp:: '=='
11+
add_operator:: comp:: '!='
12+
add_operator:: comp:: '>='
13+
add_operator:: comp:: '<='
14+
add_operator:: comp:: '>'
15+
add_operator:: comp:: '<'

src/lang/group/index.fnk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{add_operator_like, add_non_binding} = import '@fink/prattler/symbols'
1+
{add_operator, add_separator} = import '@fink/prattler/symbols'
22
{next_is, curr_loc} = import '@fink/prattler'
33

44
{symbol} = import '../symbols'
@@ -21,6 +21,6 @@ group = fn op:
2121

2222
add_group = fn ctx:
2323
pipe ctx:
24-
add_operator_like:: group:: '('
25-
add_non_binding:: symbol:: ','
26-
add_non_binding:: symbol:: ')'
24+
add_operator:: group:: '('
25+
add_separator:: symbol:: ','
26+
add_separator:: symbol:: ')'

0 commit comments

Comments
 (0)