klauer / blark

Beckhoff TwinCAT ST (IEC 61131-3) code parsing in Python using Lark (Earley)
https://klauer.github.io/blark/
GNU General Public License v2.0
42 stars 5 forks source link

Address Issue with Array-Initialization -- Other General Cleanup #63

Closed engineerjoe440 closed 1 year ago

engineerjoe440 commented 1 year ago

Related Issues

Changes

Closing Thoughts

TBD

klauer commented 1 year ago

I think I've got a fix for this. There's a bit of a loss of information when transforming array_initialization. Non-bracketed and bracketed versions are parsed/transformed into the same dataclass. Then round-tripping it to code results in brackets always being re-added - which can be undesirable.

This commit splits them up and tracks whether the original code had brackets or not: https://github.com/klauer/blark/commit/a17df30d00448f8c6f5bbaafff76e2291fa59ab0

If this works for you, feel free to just fast-forward your branch / cherry-pick the commit / etc

I haven't had a chance to test this on our full set of projects just yet. I did want to make it a possibility for others to reproduce my efforts, though, so there's a little script in our organization's "plc-summary" repository that allows you to parse the public code we have.

It'd be neat to one day make a GitHub Actions workflow that does this automatically. That said, it'd take a bit too long to do on each commit and probably frustrate us in the end...

engineerjoe440 commented 1 year ago

Yes!!!! This is great! Thanks for digging into this. I was actually just going to spin back up on some of this work, today.

I've got to say... that "plc-summary" is VERY cool!!!! That's terrific! 😲

klauer commented 1 year ago

Yes!!!! This is great! Thanks for digging into this. I was actually just going to spin back up on some of this work, today.

Feels good to close up another loose end!

I didn't mean to rush you, for what it's worth - I'll be away for a couple weeks after tomorrow, so I wanted to get this fixed up so blark can get a new tag.

I've got to say... that "plc-summary" is VERY cool!!!! That's terrific! 😲

Thanks! I'm pretty fond of it too 😁

Looking back at test_transformer, looks like we can remove 2 additional xfails! I'm going to push a commit, approve, merge, and tag.

engineerjoe440 commented 1 year ago

No rush at all, @klauer! I'm glad to get this "loose end" tied up too! :tada:

So excited to see this project keep moving forward! 😀