Skip to content

Attempt to fix IecST numeric literals#2282

Open
jneen wants to merge 1 commit into
mainfrom
bugfix.iecst-numeric-literals
Open

Attempt to fix IecST numeric literals#2282
jneen wants to merge 1 commit into
mainfrom
bugfix.iecst-numeric-literals

Conversation

@jneen
Copy link
Copy Markdown
Member

@jneen jneen commented Apr 24, 2026

Before:
image

After:
image

@tali @bufferoverflow, are these changes correct? The sample file seems to indicate that these are valid literals, but the current lexer renders them as Error tokens.

Also, is there publicly available documentation on this syntax? I could only find this: https://webstore.iec.ch/en/publication/68533

which costs nearly CAD$900, far out of my budget for this project.

@bufferoverflow
Copy link
Copy Markdown

@jneen Thanks for the mention, I will double check with my in-house experts and will provide insights as soon as I have them.

@bufferoverflow
Copy link
Copy Markdown

@sjuergen Could you help here regarding numeric literals?

@fgreinacher
Copy link
Copy Markdown

fgreinacher commented May 12, 2026

@jneen I got this information from a colleague who is deep into ST:

Yes, single underscores between digits are allowed, so 1_000 should be parsed as a valid literal.

Additional things I noticed:
they might want to check if combination of _ and . work as intended, e.g. 1_000.000_1 because in the image there is no such example
in the after image the highlighting of the BYTE#prefix disappeared and I'm not sure that was intentional

And also this hint might be relevant, but probably obvious to you :)

They are semantically incorrect, but as far as I could tell this is a syntax highlighter project and 1_000_000_000 is a valid literal token, even if the type system does not allow you to actually assign it to a REAL.

Does that help?

@bufferoverflow
Copy link
Copy Markdown

@jneen got some feedback from a team mate:

the IEC61131-3 allows to spread underscores _ in between digits.

Chapter 6.3.2 in Ed4 "Single underscore characters “_” inserted between the digits of a numeric literal shall not be significant."

One -- but not more. And you can use them where ever you want. This is valid decimal integer: 1_23_456_7890.

@jneen
Copy link
Copy Markdown
Member Author

jneen commented May 14, 2026

Thank you this is helpful! I think I can manage that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants