diff --git a/lib/makeup/lexers/erlang_lexer.ex b/lib/makeup/lexers/erlang_lexer.ex index fbe119b..a7789dd 100644 --- a/lib/makeup/lexers/erlang_lexer.ex +++ b/lib/makeup/lexers/erlang_lexer.ex @@ -155,9 +155,8 @@ defmodule Makeup.Lexers.ErlangLexer do character = string("$") |> choice([ - escape, - string("\\") |> ascii_char([?\s, ?%]), - ascii_char(not: ?\\) + string("\\") |> utf8_char([]), + utf8_char(not: ?\\) ]) |> token(:string_char) @@ -247,7 +246,7 @@ defmodule Makeup.Lexers.ErlangLexer do |> concat(token("/", :punctuation)) |> concat(number_integer) - # Erlang prompt + # Erlang prompt erl_prompt = string("\n") |> optional(string("(") |> concat(atom_name) |> string(")")) diff --git a/test/makeup/erlang_lexer/erlang_lexer_tokenizer_test.exs b/test/makeup/erlang_lexer/erlang_lexer_tokenizer_test.exs index a7b8242..f212995 100644 --- a/test/makeup/erlang_lexer/erlang_lexer_tokenizer_test.exs +++ b/test/makeup/erlang_lexer/erlang_lexer_tokenizer_test.exs @@ -6,6 +6,12 @@ defmodule ErlangLexerTokenizer do assert lex("") == [] end + test "character" do + assert lex("$a") == [{:string_char, %{}, "$a"}] + assert lex("$\\ ") == [{:string_char, %{}, "$\\ "}] + assert lex("$🫂") == [{:string_char, %{}, "$🫂"}] + end + test "comment" do assert lex("%abc") == [{:comment_single, %{}, "%abc"}] assert lex("% abc") == [{:comment_single, %{}, "% abc"}]