tlaplus-community / tree-sitter-tlaplus

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

Fix interaction between jlists inside PlusCal block inside jlists #51

Closed ahelwer closed 2 years ago

ahelwer commented 2 years ago

There needs to be some kind of context stack where once you enter a PlusCal block all jlist state changes in the enclosing scope are neutralized until the PlusCal block ends. As-is, they conflict:

---- MODULE Test ----
op ==
  /\ 1
  /\ 2

(* --algorithm Test
begin assert
  /\ 3
  /\ 4 
end algorithm *)
===

The above will erroneously count the 3 and 4 jlist items as being part of the first jlist. A fix to this will probably be implemented by moving keywords like --algorithm and algorithm into the external scanner to notify it that we're entering & exiting a PlusCal block. The scanner will push & pop the current state onto a stack.