Skip to content
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

Can you confirm that i am in s right place? #97

Open
Serhioromano opened this issue May 5, 2020 · 2 comments
Open

Can you confirm that i am in s right place? #97

Serhioromano opened this issue May 5, 2020 · 2 comments

Comments

@Serhioromano
Copy link

I am new to compiler creation.

I am building IDE for developing for PLC. As a PLC language Structured Text will be used standard IEC 61131-3. This is Pascal like language. PLC will run on Linux.

There are no compiler or parser for this language or any tool. Every vendor implement it themselves.

My original idea was to transpile ST cod to GO and compile GO. Then I've got across this tool. But few things are not clear to me.

  1. Will it generate GO app first am then compile or it will create binary right from ST?

  2. There will be ability to connect libraries in ST program. Those libs will be mirror of some GO libraries. Or written in GO as packages. Will I be able to inject those to final build?

  3. The ST program is only part that is executed periodically. But for final binary I need to add sorry of runtime environment. Wrap what developer created in ST to for cycle and call other staff to initialise I\O. Will that be possible?

@awalterschulze
Copy link
Collaborator

Sounds like a fun project.

gocc is a parser generator similar to yacc.
Once you have written a BNF you can pass it to gocc and it will generate a parser and scanner in Go. You will need to create the AST as Go structs yourself, write the interpreter or compiler, figure out how to connect libraries etc.

I hope this helps to clarify.
gocc is a good first step in your plan.

There might be a caveat, if your grammar requires more parsing power than LR(1), but gocc has a -a flag, which is sometimes useful to enable maximal munch. Or you can switch to https://github.com/goccmack/gogll

@Serhioromano
Copy link
Author

Thank you. That makes more sense. But still not absolutely clear.

I ask question so that people can answer Yes\No stile. You answer clear somethings and make new questions. Can you answer yes or no.

Can I use gocc to parse ST and generate Go project without compiling it?

Right now it is not important for me to understand how it works, I can figure that out later by reading through all documentation. Right now I just need to make a decision to use this tool or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants