Zeilenverlängerung in Envision

Zeilenverlängerungen












Startseite » Ressourcen » Hier

Die Grammatik in Envision implizite, sowie explizite Mechanismen zur Zeilenverlängerung, also die Fähigkeit, Code zu schreiben, der sich über mehrere Zeilen verbreitet, as wenn es sich um eine Zeile handeln würde. The explicit line continuation leverage the\ symbol. However when a line ends with a token that is not allowed to be an end-of-line, then the grammar assumes that a line continuation in intended.

Overview

The line continuation rule is: if a sequence (newline, indent) is preceded by a token that cannot-be-at-end-of-line or followed by a token that cannot-be-at-start-of-line, then the (newline, indent) sequence is completely ignored. For example, & is not allowed at end of line, so it is possible to split:
where ThisIsAVeryLongConditionExpression & 
      ThisIsAnotherVeryLongConditionExpression
  A = sum(B)

This syntax is more compact and preferable to the alternative that uses the explicit continuation symbol:
where ThisIsAVeryLongConditionExpression & \
      ThisIsAnotherVeryLongConditionExpression
  A = sum(B)

Similarly, if and at cannot appear at the start of a line, so it is possible to write:
A = sum(B) by [Key, Key, Key]
           at [Key, Key, Key]
           if Condition

Continuation tokens

Only tokens that cannot appear at the end of line are eligible for line continuation. Those tokens are:

  • +, -, ~, not
  • ^, ^*, >>, <<
  • *, /., /, mod, **, +*, -*
  • <=, <, >=, >, ==, !=, ~~, !~
  • &, |
  • :=, =

At the same time, infix keyword tokens cannot-be-at-start-of-line:

  • by, at, if, or, cross, over, sort
  • into
  • as