epics-extensions / vscode-epics

VS Code colorization for EPICS database, templates and substitution files
MIT License
14 stars 6 forks source link

Create basic linter for .db files #48

Open vnadot opened 3 years ago

vnadot commented 3 years ago

The idea would be to create basic linter for .db files to see if it required a lot of work. For starter, the extension could detect the following error: DESC field > 41 in EPICS 3.15.

Some links:

gfrn commented 2 years ago

EPICS seems to already have a basic lexical analyzer structure going on (with yacc/lex) that is able to at provide (at least partially) a great starting point:

That being said, it'll require some additional work to mold the already existing tools to the desired state, but I'll try to look into it this week/weekend and come up with a basic viable linter based on that.

If anyone has any tips, ideas or ongoing work, I'd be glad to hear more!

gfrn commented 2 years ago

I was able to create a little something since yesterday, which I hope is in line with the overall vision for the linter:

https://github.com/cnpem-iot/epics-linter

Currently, it only supports .db files, but I believe the output pattern is fairly easy to parse, following this pattern: {error} at {line}:{column} or {error} at {line}:{column} to {line:column}. Here is an example:

record(ai, "test") {
    field(DESC, "a way too long description name that does not fit in the maximum limit")
    field(DTYP, "stream")
    field(EGU, "$(EGU)")
    [...]
}

Record description too long (maximum of 40) at 2:17 to 2:89

As for the amount of work required, it is all fairly simple and modular. Thanks to Lark, the grammar syntax was easily ported from the yacc/lex solution and it provides a fairly robust mechanism for detecting and describing syntax errors.

If there's another route that seems better, please let me know!

gfrn commented 2 years ago

@vnadot Hello! I've received a notification for this project and I wanted to make sure that interest for a linter still existed. Github tends to not notify people in issues they're in sometimes, so I just wanted to check.

vnadot commented 2 years ago

Hi @gfrn , yes it still exists ! However since several months I have no time to assign to vscode-epics. I hope to find some times in several monts but it is a bit crazy at work right now. Cheers, Victor