Current section
11 Versions
Jump to
Current section
11 Versions
Compare versions
6
files changed
+5
additions
-47
deletions
| @@ -9,7 +9,7 @@ The package can be installed by adding `jsonc` to your list of dependencies in ` | |
| 9 9 | ```elixir |
| 10 10 | def deps do |
| 11 11 | [ |
| 12 | - {:jsonc, "~> 0.5.0"} |
| 12 | + {:jsonc, "~> 0.6.0"} |
| 13 13 | ] |
| 14 14 | end |
| 15 15 | ``` |
| @@ -12,4 +12,4 @@ | |
| 12 12 | {<<"jsonc">>,<<"https://komkom.github.io/jsonc-playground">>}]}. |
| 13 13 | {<<"name">>,<<"jsonc">>}. |
| 14 14 | {<<"requirements">>,[]}. |
| 15 | - {<<"version">>,<<"0.5.0">>}. |
| 15 | + {<<"version">>,<<"0.6.0">>}. |
| @@ -39,7 +39,7 @@ defmodule JSONC do | |
| 39 39 | ``` |
| 40 40 | defp deps do |
| 41 41 | [ |
| 42 | - {:jsonc, "~> 0.5.0"} |
| 42 | + {:jsonc, "~> 0.6.0"} |
| 43 43 | ] |
| 44 44 | end |
| 45 45 | ``` |
| @@ -187,33 +187,6 @@ defmodule JSONC.Parser do | |
| 187 187 | comments = comments ++ new_comments |
| 188 188 | |
| 189 189 | case current do |
| 190 | - {{:key, key}, _, _} -> |
| 191 | - current = next() |
| 192 | - |
| 193 | - case parse_comments() do |
| 194 | - new_comments when is_list(new_comments) -> |
| 195 | - comments = comments ++ new_comments |
| 196 | - |
| 197 | - case current do |
| 198 | - {{:delimiter, :colon}, _, _} -> |
| 199 | - case parse_value() do |
| 200 | - {:error, reason} -> |
| 201 | - {:error, reason} |
| 202 | - |
| 203 | - {current, value_comments} -> |
| 204 | - map = map |> Map.put(key, current) |
| 205 | - parse_object(start, map, comments ++ value_comments) |
| 206 | - end |
| 207 | - |
| 208 | - {token, line, column} -> |
| 209 | - {:error, |
| 210 | - "unexpected token `#{token |> inspect()}` at line #{line} column #{column}"} |
| 211 | - end |
| 212 | - |
| 213 | - {:error, reason} -> |
| 214 | - {:error, reason} |
| 215 | - end |
| 216 | - |
| 217 190 | {{:string, {subtype, key}}, _, _} when subtype in [:single, :free] -> |
| 218 191 | case peek() do |
| 219 192 | {{:delimiter, :colon}, _, _} -> |
| @@ -171,11 +171,7 @@ defmodule JSONC.Tokenizer do | |
| 171 171 | {{handle_generic("#{storage}"), token |> elem(0), token |> elem(1)}, |
| 172 172 | {rest, cursor: {line, column + 1}, token: nil}} |
| 173 173 | |
| 174 | - <<peeked::utf8>> == ":" -> |
| 175 | - {{{:key, "#{storage}#{<<current::utf8>>}"}, token |> elem(0), token |> elem(1)}, |
| 176 | - {rest, cursor: {line, column + 1}, token: nil}} |
| 177 | - |
| 178 | - <<peeked::utf8>> in [",", "}", "]"] -> |
| 174 | + <<peeked::utf8>> in [",", "}", "]", ":"] -> |
| 179 175 | { |
| 180 176 | { |
| 181 177 | handle_generic("#{storage}#{<<current::utf8>>}"), |
| @@ -211,17 +207,6 @@ defmodule JSONC.Tokenizer do | |
| 211 207 | <<peeked::utf8, _peeked_rest::binary>> = rest |
| 212 208 | |
| 213 209 | case <<current::utf8>> do |
| 214 | - "\"" when subtype == :single and <<peeked::utf8>> == ":" -> |
| 215 | - cond do |
| 216 | - String.contains?(storage, "\\") -> |
| 217 | - {{:error, "invalid key #{storage} at line #{line} column #{column}"}, |
| 218 | - {rest, cursor: {line, column}, token: nil}} |
| 219 | - |
| 220 | - true -> |
| 221 | - {{{:key, storage}, token |> elem(0), token |> elem(1)}, |
| 222 | - {rest, cursor: {line, column + 1}, token: nil}} |
| 223 | - end |
| 224 | - |
| 225 210 | "\"" when subtype == :single -> |
| 226 211 | {{{:string, {:single, storage}}, token |> elem(0), token |> elem(1)}, |
| 227 212 | {rest, cursor: {line, column + 1}, token: nil}} |
Loading more files…