BjAlvestad / vscode-simatic-scl

VS Code extensions for the SCL language used in TIA Portal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parse quoteless string for Title attribute and REGION

BjAlvestad opened this issue · comments

In TIA Portal SCL the title is defined as a string without any quotes

TITLE = My description of this block

Presumably this can then NOT be spread over multiple lines, and is therefore parsed based on first newline.
However our grammar eats up all whitespaces (including newline) to simplify in situations where whitespace does not matter.

Need to find way to parse TIA Portal style block titles.

Note that same applies to REGION

Sort of solved by using the following terminals:

terminal REGION_TEXT: /REGION [^\r\n]*/;
terminal TITLE_TEXT: /TITLE = [^\r\n]*/;

Also tried solving with positive look-behind so that REGION could be a keyword, but ran into some weird issues with keyword clashes when doing so (ref. commit 625435f):

This is a workaround for the issue where parsing/lexing of a region would
fail if the region text started with a word that contained a keyword.
E.g. Interval ... would cause it to fail, since INT is a keyword
(and we have switched off case sensitivity).
Note that Some Interval ... would not cause it to fail, since it was
only an issue if it was the start of the terminal.

This commit makes REGION and TITLE = part of the terminal, instead
of using positive lookbehind.