elixir-tools / spitfire

Error tolerant parser for Elixir
https://www.elixir-tools.dev
MIT License
54 stars 7 forks source link

bug: peek_token #30

Open mhanberg opened 2 months ago

mhanberg commented 2 months ago
** (FunctionClauseError) no function clause matching in Spitfire.peek_token/1
    (spitfire 0.1.0) lib/spitfire.ex:2167: Spitfire.peek_token(%{tokens: [nil | :eot], literal_encoder: #Function<49.133785804/2 in NextLS.handle_request/2>, errors: [{[line: 4, column: 13], "missing closing bracket for list"}], current_token: {:fake_closing_bracket, nil}, fuel: 150, peek_token: nil, nesting: 1})
    (spitfire 0.1.0) lib/spitfire.ex:295: anonymous fn/7 in Spitfire.parse_expression/6
    (spitfire 0.1.0) lib/spitfire/while.ex:49: Spitfire.While.do_while/2
    (spitfire 0.1.0) lib/spitfire.ex:1875: Spitfire.parse_identifier/1
    (spitfire 0.1.0) lib/spitfire.ex:283: Spitfire.parse_expression/6
    (spitfire 0.1.0) lib/spitfire.ex:936: anonymous fn/1 in Spitfire.parse_do_block/2
    (spitfire 0.1.0) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
    (spitfire 0.1.0) lib/spitfire/while.ex:10: Spitfire.While2.recurse/3
mhanberg commented 2 months ago

I believe this is related to the tokenizer not handling the follow type of code

iex(5)> :elixir_tokenizer.tokenize(~c"[foo:]", 1, 1, [])
{:error,
 {[line: 1, column: 2], ~c"keyword argument must be followed by space after: ",
  ~c"foo:"}, ~c"foo:]", [], ["[": {1, 1, nil}]}
mhanberg commented 2 months ago

Related to #31