go-thrift icon indicating copy to clipboard operation
go-thrift copied to clipboard

Support parsing c++ specific and other esoteric syntax

Open samuel opened this issue 10 years ago • 3 comments

For better compatibility with the standard parser should parse the rarer bits of the IDL.

https://thrift.apache.org/docs/idl

samuel avatar May 29 '15 14:05 samuel

We have this in most of our Thrift definitions and makes the parser crash:

namespace py.twisted txthrift.service.common

This is the error it generates.

$ generator common.thrift go
<reader>:5:1 (94): rule SyntaxError: parser: syntax error

Also, I'm not sure this was an appropriate issue for this.

lithammer avatar Jun 04 '15 20:06 lithammer

Interesting, I assume that's accepted by the official thrift tool? They're spec shows namespace scope as NamespaceScope ::= '*' | 'cpp' | 'java' | 'py' | 'perl' | 'rb' | 'cocoa' | 'csharp' but that's likely out of date. Following that the parser in this package just allows [a-z]+ . I'll change it to allow . in scopes.

samuel avatar Jun 04 '15 20:06 samuel

Interesting, I assume that's accepted by the official thrift tool?

Yes it is. The output is different as well from regular Python, not just the namespace/import path. So there's definitely support for it.

I'll change it to allow . in scopes.

Super! It seems https://github.com/samuel/go-thrift/commit/e7cab3d2c73a17194c9f5dc22eb2c4b441ed7254 fixed my issue. Thanks!

lithammer avatar Jun 04 '15 20:06 lithammer