Skip to content

Commit

Permalink
Fix reserved words parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
edgurgel committed Jan 7, 2025
1 parent 3fd9d33 commit 02b9cf8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
20 changes: 0 additions & 20 deletions lib/solid/parser/literal.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,6 @@ defmodule Solid.Parser.Literal do
end

def value do
true_value =
string("true")
|> replace(true)

false_value =
string("false")
|> replace(false)

null =
string("nil")
|> replace(nil)

empty =
string("empty")
|> replace(:empty)

frac =
string(".")
|> concat(integer(min: 1))
Expand All @@ -73,10 +57,6 @@ defmodule Solid.Parser.Literal do
choice([
float,
int(),
true_value,
false_value,
null,
empty,
single_quoted_string(),
double_quoted_string()
])
Expand Down
10 changes: 10 additions & 0 deletions lib/solid/parser/variable.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,15 @@ defmodule Solid.Parser.Variable do
identifier()
|> repeat(choice([dot_access(), bracket_access()]))
|> tag(:field)
|> map({__MODULE__, :reserved_words, []})
end

@reserved_words ~w(true false nil empty)

def reserved_words(field) do
case field do
{:field, [word]} when word in @reserved_words -> {:value, String.to_atom(word)}
_ -> field
end
end
end

0 comments on commit 02b9cf8

Please sign in to comment.