From 51f7c139b65788947180d8b63a5aa42d528e4b46 Mon Sep 17 00:00:00 2001 From: Thomas Timmer Date: Wed, 8 Jan 2025 16:16:28 +0100 Subject: [PATCH 1/4] fix: pull unicode character checks from guard to a function --- .github/workflows/elixir.yml | 3 +++ lib/json5/ecma.ex | 30 ++++++++++++++++-------------- mix.exs | 4 ++-- mix.lock | 4 ++-- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 7cb614c..8e91a60 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -14,6 +14,9 @@ jobs: matrix: otp: ["24.2", "25.3", "26.2"] elixir: ["1.14.5", "1.15.6", "1.16.1"] + include: + - otp: "27.2" + elixir: "1.18.1" steps: - uses: actions/checkout@v4 - uses: erlef/setup-beam@v1 diff --git a/lib/json5/ecma.ex b/lib/json5/ecma.ex index 55d8fdb..9e9e6ec 100644 --- a/lib/json5/ecma.ex +++ b/lib/json5/ecma.ex @@ -52,18 +52,6 @@ defmodule Json5.ECMA do defguard is_reserved_word(input) when input in @reserved_names - defguard is_unicode_identifier_letter(x) - when Unicode.Set.match?( - x, - "[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:][:Mn:][:Mc:][:Nd:][:Pc:]]" - ) - - defguard is_unicode_letter(x) - when Unicode.Set.match?( - x, - "[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:]]" - ) - def reserved_words do @reserved_names end @@ -101,14 +89,28 @@ defmodule Json5.ECMA do defp ecma_identifier_part do either( ecma_identifier_start(), - satisfy(char(), &is_unicode_identifier_letter/1) + satisfy(char(), &unicode_identifier_letter?/1) ) end defp ecma_unicode_letter do satisfy(char(), fn - <> when is_unicode_letter(ch) -> true + <> -> unicode_letter?(ch) _ -> false end) end + + defp unicode_identifier_letter?(x) do + Unicode.Set.match?( + x, + "[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:][:Mn:][:Mc:][:Nd:][:Pc:]]" + ) + end + + defp unicode_letter?(x) do + Unicode.Set.match?( + x, + "[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:]]" + ) + end end diff --git a/mix.exs b/mix.exs index 97f7c68..31e6c6f 100644 --- a/mix.exs +++ b/mix.exs @@ -4,8 +4,8 @@ defmodule Json5.MixProject do def project do [ app: :json5, - version: "0.3.1", - elixir: "~> 1.10", + version: "0.3.2", + elixir: "~> 1.14", description: "Json5 in Elixir", start_permanent: Mix.env() == :prod, deps: deps(), diff --git a/mix.lock b/mix.lock index 8b232bd..e8e87d2 100644 --- a/mix.lock +++ b/mix.lock @@ -19,6 +19,6 @@ "makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"}, - "unicode": {:hex, :unicode, "1.19.0", "264191eacb1d44039d0dbb9fd936c557431825373b6e7b18d77e80cb0cc344bd", [:mix], [], "hexpm", "ae83bbf54429a67bc6fa9c941a6e9f0ec38dd9c2a32b21583ad511d3b6555631"}, - "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"}, + "unicode": {:hex, :unicode, "1.20.0", "10189cfe98b03ebb8be6efd00df0936c1c94d75bfbd62cba2bdf958fef3ee4a7", [:mix], [], "hexpm", "fa581cf80b3b1b7f42e4d24a69109dfac465cec27a62c661306c81f4ab35894c"}, + "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"}, } From 4eead49ed07f20b6f47e423585428442218d7557 Mon Sep 17 00:00:00 2001 From: Thomas Timmer Date: Wed, 8 Jan 2025 16:22:49 +0100 Subject: [PATCH 2/4] chore: bump erlang 24 github ci version --- .github/workflows/elixir.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 8e91a60..82144ab 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -12,7 +12,7 @@ jobs: name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} strategy: matrix: - otp: ["24.2", "25.3", "26.2"] + otp: ["24.3", "25.3", "26.2"] elixir: ["1.14.5", "1.15.6", "1.16.1"] include: - otp: "27.2" From aadb08af94e6da3766bfe5aaabe75d54c1930d54 Mon Sep 17 00:00:00 2001 From: Thomas Timmer Date: Wed, 8 Jan 2025 16:34:25 +0100 Subject: [PATCH 3/4] chore: format --- lib/json5/ecma.ex | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/json5/ecma.ex b/lib/json5/ecma.ex index 9e9e6ec..229e068 100644 --- a/lib/json5/ecma.ex +++ b/lib/json5/ecma.ex @@ -102,15 +102,12 @@ defmodule Json5.ECMA do defp unicode_identifier_letter?(x) do Unicode.Set.match?( - x, - "[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:][:Mn:][:Mc:][:Nd:][:Pc:]]" - ) + x, + "[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:][:Mn:][:Mc:][:Nd:][:Pc:]]" + ) end defp unicode_letter?(x) do - Unicode.Set.match?( - x, - "[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:]]" - ) + Unicode.Set.match?(x, "[[:Lu:][:Ll:][:Lt:][:Lm:][:Lo:][:Nl:]]") end end From bb381949ec53071c92d7945f57bba67bccb9c30d Mon Sep 17 00:00:00 2001 From: Thomas Timmer Date: Fri, 17 Jan 2025 16:16:31 +0100 Subject: [PATCH 4/4] feat: bump version to 0.4.0 --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 31e6c6f..227cd80 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Json5.MixProject do def project do [ app: :json5, - version: "0.3.2", + version: "0.4.0", elixir: "~> 1.14", description: "Json5 in Elixir", start_permanent: Mix.env() == :prod,