Skip to content

Commit dfb2ba0

Browse files
authored
Merge pull request #7 from thomas9911/fix/allow-on-elixir-1-18
feat: pull unicode character checks from guard to a function
2 parents 7706628 + bb38194 commit dfb2ba0

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

.github/workflows/elixir.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ jobs:
1212
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
1313
strategy:
1414
matrix:
15-
otp: ["24.2", "25.3", "26.2"]
15+
otp: ["24.3", "25.3", "26.2"]
1616
elixir: ["1.14.5", "1.15.6", "1.16.1"]
17+
include:
18+
- otp: "27.2"
19+
elixir: "1.18.1"
1720
steps:
1821
- uses: actions/checkout@v4
1922
- uses: erlef/setup-beam@v1

lib/json5/ecma.ex

+13-14
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,6 @@ defmodule Json5.ECMA do
5252

5353
defguard is_reserved_word(input) when input in @reserved_names
5454

55-
defguard is_unicode_identifier_letter(x)
56-
when Unicode.Set.match?(
57-
x,
58-
"[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:][:Mn:][:Mc:][:Nd:][:Pc:]]"
59-
)
60-
61-
defguard is_unicode_letter(x)
62-
when Unicode.Set.match?(
63-
x,
64-
"[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:]]"
65-
)
66-
6755
def reserved_words do
6856
@reserved_names
6957
end
@@ -101,14 +89,25 @@ defmodule Json5.ECMA do
10189
defp ecma_identifier_part do
10290
either(
10391
ecma_identifier_start(),
104-
satisfy(char(), &is_unicode_identifier_letter/1)
92+
satisfy(char(), &unicode_identifier_letter?/1)
10593
)
10694
end
10795

10896
defp ecma_unicode_letter do
10997
satisfy(char(), fn
110-
<<ch>> when is_unicode_letter(ch) -> true
98+
<<ch>> -> unicode_letter?(ch)
11199
_ -> false
112100
end)
113101
end
102+
103+
defp unicode_identifier_letter?(x) do
104+
Unicode.Set.match?(
105+
x,
106+
"[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:][:Mn:][:Mc:][:Nd:][:Pc:]]"
107+
)
108+
end
109+
110+
defp unicode_letter?(x) do
111+
Unicode.Set.match?(x, "[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:]]")
112+
end
114113
end

mix.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ defmodule Json5.MixProject do
44
def project do
55
[
66
app: :json5,
7-
version: "0.3.2",
8-
elixir: "~> 1.10",
7+
version: "0.4.0",
8+
elixir: "~> 1.14",
99
description: "Json5 in Elixir",
1010
start_permanent: Mix.env() == :prod,
1111
deps: deps(),

mix.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
"makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"},
2020
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
2121
"statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"},
22-
"unicode": {:hex, :unicode, "1.19.0", "264191eacb1d44039d0dbb9fd936c557431825373b6e7b18d77e80cb0cc344bd", [:mix], [], "hexpm", "ae83bbf54429a67bc6fa9c941a6e9f0ec38dd9c2a32b21583ad511d3b6555631"},
23-
"unicode_set": {:hex, :unicode_set, "1.4.0", "d7f005d5227768fb13a507433925b685be76acfbe6e5a25323c8231b54f59a96", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:unicode, "~> 1.13", [hex: :unicode, repo: "hexpm", optional: false]}], "hexpm", "096d84ecd1f7965b0f0073f00a51bdc9c8d400f085730fcee6f735f1c2d676ef"},
22+
"unicode": {:hex, :unicode, "1.20.0", "10189cfe98b03ebb8be6efd00df0936c1c94d75bfbd62cba2bdf958fef3ee4a7", [:mix], [], "hexpm", "fa581cf80b3b1b7f42e4d24a69109dfac465cec27a62c661306c81f4ab35894c"},
23+
"unicode_set": {:hex, :unicode_set, "1.4.1", "0c5b7498e05acc3104a3fa10d99c0ec9dfa8acd5c9cbfb65b4ae0cc7f210e2e2", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:unicode, "~> 1.13", [hex: :unicode, repo: "hexpm", optional: false]}], "hexpm", "349e38d2843eaa7ea8e6dbded7ffcbb9d54d74ee7524adb7d5c575d468daac3f"},
2424
}

0 commit comments

Comments
 (0)