Closed klauer closed 1 year ago
I was beginning to look at this item, to see if I might be able to help with it. I do feel a bit confused, so I want to check my understanding. Were you intending to support INTERFACE objects specifically, almost like FUNCTION_BLOCKs, but specifically with the appropriate interface syntax (i.e., no implementation sections). I think what might make sense (at least at the top level) would be to carve out unique interface_declaration
, interface_method_declaration
, and interface_property_declaration
to follow the similarly named FUNCTION_BLOCK items:
Am I following your train-of-thought here?
Yeah, sorry about the very terse "TODO"-style issue here.
It looks like I added FUNCTION_BLOCK ... IMPLEMENTS
at some point in the grammar (30bda8eb), so the core of this issue is then supporting library-element-level INTERFACE
declarations (just as you've laid out above). I'll tweak the original issue text.
There's a bit of investigation to do to properly implement this, I think. And pytmc
needs a bit of work to parse TcIO
files and dump out compatible code, too - but that shouldn't stop blark from implementing the INTERFACE
declaration grammar.
These INTERFACE
definitions will then be of the form:
INTERFACE I_Name [EXTENDS I_Base1, ...]
[METHOD ...]
[PROPERTY ...]
END_INTERFACE
From what I understand these can only include PROPERTY
and METHOD
(without implementation sections as you've noted).
Here's some code examples that might be of use while coming up with the grammar:
INTERFACE/END_INTERFACE
there)I'm not sure if any existing parsers work on INTERFACE
objects (a 5 minute glance at related projects https://github.com/klauer/blark/issues/27 indicates probably not)
https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/4262436875.html&id=
Also find a better reference for it.
TODO:
IMPLEMENTS
inFUNCTION_BLOCK
IMPLEMENTS
INTERFACE
declaration (interface_declaration
)interface_declaration
for supported grammar (methods, properties)INTERFACE
support in the transformersINTERFACE
test cases and ensure they round-trip from code->Python dataclasses->code.TcIO
files: https://github.com/pcdshub/pytmc/issues/276