Serhioromano / vscode-st

Extension for VS Code to support Structured Text language.
https://marketplace.visualstudio.com/items?itemName=Serhioromano.vscode-st#overview
MIT License
142 stars 28 forks source link

Langium rules for structured text #50

Closed rempAut closed 1 year ago

rempAut commented 1 year ago

WIP langium rules

Serhioromano commented 1 year ago

Thank you. I have not yet tested it but please update upstream. I deleted .gitignore since generated files have to be commited to github in order for action that builds extensions automatically works. Also syntax JSON file was lost, I have restored it.

rempAut commented 1 year ago

Had no intetions to merge yet, still want to finish the ST statements part at least.

Serhioromano commented 1 year ago

Had no intetions to merge yet, still want to finish the ST statements part at least.

No worries. Continue to develop and submit new PRs along the way for review. This is feature branch anyway. Just upstream from this branch to you to have updates I am working on this branch.

Serhioromano commented 1 year ago

Example

Integer_type_name returns number:
    Unsigned_integer_type_name | Signed_integer_type_name;

Signed_integer_type_name returns number:
    'SINT'|'INT'|'DINT'|'LINT';

I think return number should not be there. It is TS type and in fact it is not it is string. It is number for ST but not for the parser it will attempt to convert output to number but that is string.

Serhioromano commented 1 year ago
Signed_Integer returns number:
    ('+'|'-')? Integer;

This is the same as

Unsigned_Integer returns number:
    Integer;

Because it allows only Integer to be there without sign as (+|-) have ? modifier with is optional. I think there should be no ? it means that sign is there.

rempAut commented 1 year ago

There is a lot of mistakes.

Signed_Integer returns number:
    ('+'|'-')? Integer;

You are correct, the integers could produce the same - its just there because I copied the rules 1:1 from the ST grammar rules.

I'll fix it eventually, yesterday I sort of "finished" the structured text part of the grammar. Now I need to review the generated AST.