Comments (5)
FWIW, I've been using the method of "constructing" properties in this way, and it seems to be working for the most part.
from blark.
Glad it's at least mostly worked. I'm honestly not entirely convinced of the method, as I think the above comment touched on.
It's been on the back of my mind to look back into maybe natively supporting .TcPOU
(and related) files here without any pytmc translation. I think it'd likely be cleaner in the end, even if it means the grammar has to get restructured to support it. (Don't hold me to this statement, though 😁 )
from blark.
#64 aims to address this without custom grammar.
Properties from TwinCAT source code files can be parsed piece-by-piece getter/setter declaration/implementation (for a total of 4 different code blocks). Then it's up to you to keep track of which corresponds to the getter and which corresponds to the setter.
Writing a custom blark input handler can be an option here. That PR also tries to make it easier to parse arbitrary individual code sections more easily (even without the input handler) in blark.parse.parse_source_code
- starting_source
can be specified to a grammar rule such as data_type_declaration
or program_declaration
(or any other library declarations). new_parser
still lets you dig deeper into non-top-level rules.
from blark.
Properties are reasonably well-supported now (as of v0.7.0) - some tweaks may come down the line. Closing for now
from blark.
It's a good question - one I waffled back and forth with for a bit before settling on what's in blark right now. There's a longer discussion - more a monologue perhaps? - here: pcdshub/pytmc#274
The current state is that the grammar allows for this for the getter:
PROPERTY PUBLIC LogToVisualStudio : BOOL
VAR
END_VAR
LogToVisualStudio := bLogToVisualStudio;
END_PROPERTY
And this for the setter:
PROPERTY PUBLIC LogToVisualStudio
VAR
bValue : BOOL;
END_VAR
THIS^.bLogToVisualStudio := bValue;
END_PROPERTY
Note the return type in the getter and not on the setter.
Now you might then wonder "how do you associate a method or a property or an action with a function block?"
The best I could come up with is that it's parsed-order-dependent. Properties/methods/actions defined as part of of a larger set of source code would implicitly apply to the most-recently-seen function block. That's what this first pass at the summary module does:
Lines 789 to 889 in e572219
None of this is set in stone, though, and I'm definitely open to better suggestions!
from blark.
Related Issues (20)
- Support TwinCAT solutions/project/source code files directly HOT 2
- Add Support for Multi-Line Object Oriented Function-Block Usage HOT 2
- Dereferenced Variables in Function Calls Not Parsing Correctly HOT 1
- Explicit support for base 10/decimal literals HOT 1
- Array Initialization with Zero HOT 3
- Remove `method_statement` from grammar HOT 1
- Fail to Parse Array of Arrays
- Variables Containing the word "Return" Incorrectly Identified as `RETURN` Statements. HOT 3
- Array of Pointer to Structure using Addresses Dereferencing by Index Failing to Parse HOT 1
- `POINTER TO STRING(c_Size - 1);` Not Parsing Correctly HOT 7
- Language features in upcoming TwinCAT 4026 release HOT 1
- Double-asterisk (`**`) exponential operator is not supported by TwinCAT
- Need Support for `JMP` Statements
- Variable with underscore HOT 7
- Failure to Parse POINTER TO Object using FB_Init HOT 8
- Add GitHub Actions job to deploy API documentation HOT 1
- apischema as a non-optional requirement? HOT 1
- Syntax Parsing Failure - Accessing an Attribute on a Dereferenced Pointer Returned from a Method Doesn't Work HOT 1
- Comments in output tree?
- Repeated Variable Declaration in Structure with a Single Structured Data Type Fails to Parse
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blark.