-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SmaCC_Elixir: Identifier misfires #32
Comments
After investigating a bit, I've found a possible explanation: Let us look at the parser on the following examples both in f[:a]
f [:a] In SmaCC I see these are the same These are expressions 4 and 5. However when looking at it via iex(10)> quote do f[:a] end
{{:., [from_brackets: true], [Access, :get]}, [from_brackets: true],
[{:f, [], Elixir}, :a]}
iex(11)> quote do f [:a] end
{:f, [], [[:a]]} Which the first corresponds to their rule on bracket_expr -> access_expr bracket_arg : build_access('$1', meta_with_from_brackets('$2')).
...
Erlang code .
...
build_access(Expr, {List, Meta}) ->
{{'.', Meta, ['Elixir.Access', get]}, Meta, [Expr, List]}.
I believe this is relevant due to how the with parses, as with this finding, I got the following to parse |
To give a few more examples of identifiers improperly ignoring spaces: iex(mariari@Gensokyo)9> quote do f (1,2,3) end
** (SyntaxError) invalid syntax found on iex:9:12:
error: unexpected parentheses. If you are making a function call, do not insert spaces between the function name and the opening parentheses. Syntax error before: '('
│
9 │ quote do f (1,2,3) end
│ ^
│
└─ iex:9:12
(iex 1.17.3) lib/iex/evaluator.ex:295: IEx.Evaluator.parse_eval_inspect/4
(iex 1.17.3) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
(iex 1.17.3) lib/iex/evaluator.ex:32: IEx.Evaluator.init/5
(stdlib 6.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
iex(mariari@Gensokyo)9> quote do f(1,2,3) end
{:f, [], [1, 2, 3]} |
EDIT
See my followup comment in this thread, I've identified the real issue, which is bracket_identifiers etc apply even when they should not.
This applies to the other
Identifier
rules in general.To give another example:
Fails to parse as I believe it's parsing as a
paren_identifier
Original Message
I'm unsure where the grammar goes wrong on this one.
Picture below is a few code examples.
Namely it has issues parsing the last one, where you have a list followed with a comma, this is true for both improper and normal lists, however structs and maps seem to parse fine.
The text was updated successfully, but these errors were encountered: