Skip to content

Commit

Permalink
fix: handle prefix operator with newline (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanberg authored Apr 11, 2024
1 parent d39f91d commit 4a2fcb6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/spitfire.ex
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ defmodule Spitfire do
current_precedence(parser)
end

parser = next_token(parser)
parser = parser |> next_token() |> eat_eol()
{rhs, parser} = parse_expression(parser, precedence, false, false, false)

ast = {token, meta, [rhs]}
Expand Down
12 changes: 12 additions & 0 deletions test/spitfire_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ defmodule SpitfireTest do
'''

assert Spitfire.parse(code) == s2q(code)

code = ~S'''
^
foo
'''

assert Spitfire.parse(code) == s2q(code)
end

test "parses numbers" do
Expand Down Expand Up @@ -842,6 +849,11 @@ defmodule SpitfireTest do
@foo bar()
''',
~s'''
@
__cursor__()
''',
~s'''
@foo %{
foo: :bar
}
Expand Down

0 comments on commit 4a2fcb6

Please sign in to comment.