Skip to content

Commit

Permalink
Add support for strict generators
Browse files Browse the repository at this point in the history
  • Loading branch information
garazdawi authored and josevalim committed Jan 28, 2025
1 parent 7ad4baa commit c1206fb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/makeup/lexers/erlang_lexer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ defmodule Makeup.Lexers.ErlangLexer do

syntax_operators =
word_from_list(
~W[+ - +? ++ = == -- * / < > /= =:= =/= =< >= ==? <- <= ! ? ?!],
~W[+ - +? ++ = == -- * / < > /= =:= =/= =< >= ==? <- <:- <= <:= ! ? ?!],
:operator
)

Expand Down
24 changes: 24 additions & 0 deletions test/makeup/erlang_lexer/erlang_lexer_tokenizer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,28 @@ defmodule ErlangLexerTokenizer do
]
end

test "strict" do
assert lex("[A||A<:-B]") == [
{:punctuation, %{group_id: "group-1"}, "["},
{:name, %{}, "A"},
{:punctuation, %{}, "||"},
{:name, %{}, "A"},
{:operator, %{}, "<:-"},
{:name, %{}, "B"},
{:punctuation, %{group_id: "group-1"}, "]"}
]

assert lex("[A||A<:=B]") == [
{:punctuation, %{group_id: "group-1"}, "["},
{:name, %{}, "A"},
{:punctuation, %{}, "||"},
{:name, %{}, "A"},
{:operator, %{}, "<:="},
{:name, %{}, "B"},
{:punctuation, %{group_id: "group-1"}, "]"}
]
end

test "parallel" do
assert lex("[A||A<-B&&C<-D]") == [
{:punctuation, %{group_id: "group-1"}, "["},
Expand Down Expand Up @@ -379,7 +401,9 @@ defmodule ErlangLexerTokenizer do
assert lex("=") == [{:operator, %{}, "="}]
assert lex("!") == [{:operator, %{}, "!"}]
assert lex("<-") == [{:operator, %{}, "<-"}]
assert lex("<:-") == [{:operator, %{}, "<:-"}]
assert lex("<=") == [{:operator, %{}, "<="}]
assert lex("<:=") == [{:operator, %{}, "<:="}]
end

test "word operators are tokenized as operator" do
Expand Down

0 comments on commit c1206fb

Please sign in to comment.