Roughed in Proto2 Spirit parser

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Roughed in Proto2 Spirit parser

Boost - Users mailing list
Hello,

I'm working on a Proto2 Spirit parser. Right now it's really roughed
in. There is no AST at the moment. That's TBD; right now I am focused
on just getting the build to work.

https://gcc.godbolt.org/z/_nBsKi

The code is there, but the compiler driving the web site is choking on Spirit.

I put the rules in up front; probably ambitious on my part, and am
finding an error on:

_range %= _int_lit >> -(lit("to") >> (_int_lit | lit("max"));

Severity Code Description Project File Line Suppression State
Error C1075 '{': no matching token found
Kingdom.OrTools.Sat.Params.Generator g:\source\kingdom
software\kingdom.ortools\standard\src\kingdom.ortools.sat.params.generator\proto_parser.cpp
205

The Proto2 grammar states:

range =  intLit [ "to" ( intLit | "max" ) ]

I'm considering pairing it back significantly and building the grammar
up gradually to make sure it all builds. That's probably a sounder
approach anyway.

Eventually I want to build up the AST in such a way as to facilitate
generating some boilerplate adapter code in my target language (C#).

Thoughts?

Best regards,

Michael Powell

https://developers.google.com/protocol-buffers/docs/reference/proto2-spec
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Roughed in Proto2 Spirit parser

Boost - Users mailing list
On 1/11/2018 08:05, Michael Powell wrote:
> I put the rules in up front; probably ambitious on my part, and am
> finding an error on:
>
> _range %= _int_lit >> -(lit("to") >> (_int_lit | lit("max"));

You're missing a closing parenthesis on that line.

> Eventually I want to build up the AST in such a way as to facilitate
> generating some boilerplate adapter code in my target language (C#).

There are some existing C# code generators for Proto2.

https://protogen.marcgravell.com/ springs to mind.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Roughed in Proto2 Spirit parser

Boost - Users mailing list
On Wed, Oct 31, 2018 at 6:40 PM Gavin Lambert via Boost-users
<[hidden email]> wrote:

>
> On 1/11/2018 08:05, Michael Powell wrote:
> > I put the rules in up front; probably ambitious on my part, and am
> > finding an error on:
> >
> > _range %= _int_lit >> -(lit("to") >> (_int_lit | lit("max"));
>
> You're missing a closing parenthesis on that line.
>
> > Eventually I want to build up the AST in such a way as to facilitate
> > generating some boilerplate adapter code in my target language (C#).
>
> There are some existing C# code generators for Proto2.
>
> https://protogen.marcgravell.com/ springs to mind.

I appreciate the feedback. If it was "just" the proto I was looking
for, sure, I might consider that.

I'm doing some work around Google.OrTools:

https://github.com/mwpowellhtx/Kingdom.OrTools/

Currently considering the CP SAT solver and finding that its
parameters are a naked string.

So I want my parser to extrapolate meta details about the CP SAT
parameters proto in order to generate some compile time boilerplate
adapter code. You might call it a DSL of sorts.

I could churn through it by hand, but the problem really lends itself
to this sort of solution.

> _______________________________________________
> Boost-users mailing list
> [hidden email]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users