tlaplus-community / tree-sitter-tlaplus

A tree-sitter grammar for TLA⁺ and PlusCal
MIT License
57 stars 10 forks source link

PlusCal parser appears to treat `:=` as an infix operator sometimes #109

Open ahelwer opened 5 months ago

ahelwer commented 5 months ago

See neovim highlighting on this line.

ahelwer commented 5 months ago

Failing test:

=============|||
Multiple Assignments in Single Step
=============|||

---- MODULE Test ----
(*
--algorithm Test {
  variables x, y, z;
  {
    x := 0 || y := 0 || z := 0
  }
}
*)
====

--------------|||

(source_file (module (header_line) name: (identifier) (header_line)
  (block_comment (pcal_algorithm name: (identifier)
    (pcal_var_decls
      (pcal_var_decl (identifier))
      (pcal_var_decl (identifier))
      (pcal_var_decl (identifier))
    )
    (pcal_algorithm_body (pcal_assign
      (pcal_lhs (identifier_ref)) (assign) (nat_number)
      (vertvert) (pcal_lhs (identifier_ref)) (assign) (nat_number)
      (vertvert) (pcal_lhs (identifier_ref)) (assign) (nat_number)
    ))
  ))
(double_line)))

The first := is parsed as a pluscal assign operator but all subsequent || and := tokens are parsed as infix operators in an expression.

Work currently lives in pcal-multiassign branch.