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

Create DSL for specification declaration #4

Open
PMunch opened this issue Mar 29, 2018 · 2 comments
Open

Create DSL for specification declaration #4

PMunch opened this issue Mar 29, 2018 · 2 comments

Comments

@PMunch
Copy link
Owner

PMunch commented Mar 29, 2018

This currently parses the official protobuf specification. However if you only plan to use it for Nim -> Nim communication there is no need to specify your protobuf format in it's own file only to parse it every time you want to compile. It would be nice to have a Nim DSL for creating these specifications, the data structure is already there, so it's mostly deciding on a grammar and implementing a simple AST to internal representation macro.

@oskaritimperi
Copy link

With Nim a lot of stuff is possible. At some point I was thinking something along the lines of:

protobuf:
  message Test1:
    repeated sint64 value1 = 1
    string value2 = 2

  enumeration Enum1:
    Value1 = 0
    Value2 = 1

The example passes some data to protobuf macro, which could then transform this to whatever is needed. Amazing what magic you can do with this :-)

@PMunch
Copy link
Owner Author

PMunch commented Apr 3, 2018

Yeah I know, I've written plenty of macros like this by now if you look at my repositories 😃. Your example is pretty much exactly what I was thinking about, since my solution revolves around an internal node representation of the protobuf syntax it should be a fairly simple task to write a macro that just converts to a call to generator procedure and a node initialisation.

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