Skip to content

Conversation

@lukaszsamson
Copy link
Contributor

Fixes crash 1 from #48

I tried to find all the places where :eol token was handled and by disabling that code discover tests that were affected. In a few places removing the code did not make any noticeable change so I left TODOs


# TODO Is anything needed here? Removing all of these tokens does not break any tests
# TODO Should we add :";" to the list?
@terminals MapSet.new([:eol, :eof, :"}", :")", :"]", :">>"])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests pass even with
@terminals MapSet.new([])

lib/spitfire.ex Outdated
if is_valid do
# TODO should we handle ; here?
# TODO removing peek_token(parser) != :eol does not break any tests
while is_nil(Map.get(parser, :stab_state)) and not MapSet.member?(terminals, peek_token(parser)) &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests pass with
(current_token(parser) != :do) &&

lib/spitfire.ex Outdated

# TODO should we add ; here?
# TODO is anything needed? Removing all tokens does not break any tests
terminals = [:eol, :eof, :"}", :")", :"]", :">>"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests pass with
terminals = []

end

# TODO this may be too greedy. Probably the better option would be to have distinct eat_eol/1 and eat_eol_or_semicolon/1
defp eat_eol(parser) do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eat_eol should be more context aware. Semicolons are not allowed in all contexts or change the meaning

:eof
end

defp peek_token_eat_eol(%{peek_token: {:eol, _token}} = parser) do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eat_eol should be more context aware. Semicolons are not allowed in all contexts or change the meaning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant