-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable with underscore #83
Comments
Hi @drehstromer, thanks for giving blark a try and reaching out. Identifiers in blark are allowed to start with underscores, so I think there may be something else that it's failing to recognize in your code. |
Hi @klauer |
Interestingly I'm unable to reproduce the issue. On blark v0.7.0, I see the following with your file:
Would you mind checking |
I tried yesterday the command: Thanks for your help! |
Ah, OK - Would you be OK if I included it as a test case in blark? (Or a modified version of it, if that's preferable?)
You've got the right idea. But you might be unhappy with blark's idea of "formatted" output - it's not exactly pretty just yet!
That's one of the goals! I have some of the basics done, but it's not quite ready for the general public just yet. If you're willing to drop into Python, you can generate any documentation format you prefer. import blark.parse
import blark.summary
parsed = list(blark.parse.parse("Logging/POU/LogFB/FB_Log.TcPOU"))
summary = blark.summary.CodeSummary.from_parse_results(parsed)
fb_log = summary.function_blocks["FB_Log"]
for name, decl in fb_log.declarations.items():
print(f"Declaration {name} is of type: {decl.type} and has comments={decl.comments} pragmas={decl.pragmas}") which outputs:
|
Thanks for fixing it. It works now.
Yes no problem. I can provide you in the future with new testmaterial if you could use it. My goal is to provide an easy documentation for all my code. As you mentioned in #80 code documentation isnt the favourite work of plc developers, but in my opinion it is something of the most important things. And if you can write your docs in code, its easier to do it.
Thanks for the example. I will try to work with Python and Blark. Would you be willing to help me if I have any questions about blark? I worked a bit with Python at school but haven't used it since. |
No problem! 👍
Definitely - if you can find things that blark fails at or doesn't do what you'd expect, I'd love to know about it.
I strongly agree with your opinion about documentation. Also, the more general interest there is in blark as a tool gives me an excuse to finish up that documentation-generation tooling. Maybe one day soon...
I'll help where I can! This is a fun side project for me, so having people actually poke around with the library is nice. |
I get an error if i want to parse a TcPou with vars inside which start with an underscore.
for example:
_eLocalSeverity : E_Severity;
I get the following error message:
Failed to parse D:\GIT\Logging\POU\LogFB\FB_LogBase.TcPOU FB_LogBase/declaration: Exception: UnexpectedCharacters: No terminal matches '_' in the current parser context, at line 9 col 2
Expected one of:
* __ANON_12
* DOT
* ASSIGNMENT
* __ANON_10
* SEMICOLON
* COLON
* DEREFERENCED
* __ANON_11
* LSQB
* LPAR
Failed to parse some source code files:
D:\GIT\Logging\POU\LogFB\FB_LogBase.TcPOU: FB_LogBase/declaration
I'm sorry but i dont understand python and lark well enough to find the error and the solution to that error myself.
I hope you can help me.
Thanks
The text was updated successfully, but these errors were encountered: