If you are using Go, you can use this protoparse package to parse proto
source:
https://pkg.go.dev/github.com/jhump/protoreflect/desc/protoparse

It provides functions for parsing and linking into descriptors. But it also
provides an option to parse into a richer AST. The descriptor format is not
a particularly good AST because it is lossy. So if you wanted to write a
formatter, for example, the descriptor loses a lot of token position and
comment information, which may prevent you from perfectly reconstructing
the original source text. The ast sub-package of protoparse is not lossy
and includes position information, including whitespace and comments, for
everything lexed token.
https://pkg.go.dev/github.com/jhump/protoreflect/desc/protoparse/ast

----
*Josh Humphries*
[email protected]


On Tue, Feb 16, 2021 at 7:34 PM Gerardo Mora <[email protected]> wrote:

> I'm gonna use golang for my project, and will be open source, so
> eventually I will show you the software if you guys are interested!
> I would like that the parser will run in the same thread of the request,
> when a microservice registers itself.
>
> I'm gonna read all approaches and see, thanks guys!
>
> PS
> if there are more ideas all are welcomed.
>
>
> El mar, 16 de feb. de 2021 a la(s) 18:28, Derek Perez ([email protected])
> escribió:
>
>> It sounds like you may wanna build a protoc plugin like so:
>>
>> https://expobrain.net/2015/09/13/create-a-plugin-for-google-protocol-buffer/
>>
>> The AST for protobuf is actually in protobuf itself! It's very easy to
>> work with, and is the backbone of all the code generators.
>>
>> On Tue, Feb 16, 2021 at 4:24 PM Marc Gravell <[email protected]>
>> wrote:
>>
>>> You can use protoc to output the compiled schema (one of the
>>> command-line-options - something "file descriptor set"), and deserialize
>>> the resultant binary file as a FileDescriptorSet instance, deserializing
>>> via your choice of language via descriptor.proto - any use?
>>>
>>> As an aside, I also have a separate implementation of a .proto parser,
>>> implemented in C#/.NET (so it can be used in 100% managed .NET code). Not
>>> sure if that is any use to you, but if so: let me know.
>>>
>>> On Wed, 17 Feb 2021, 00:12 Gerardo Mora, <[email protected]> wrote:
>>>
>>>> Hello everyone, I would like to create an application that analyzes a
>>>> .proto file and dynamically creates GraphQL queries, I don't want to parse
>>>> the .proto files because it will outdated and probably buggy at some point,
>>>> but I was reading the source code and the only available thing is create a
>>>> plugin that ouputs a file after the processing which is not idea.
>>>>
>>>> Is there an API/SDK available for it?
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Protocol Buffers" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/protobuf/f78681b8-47f2-44ac-955a-73b828f1b08dn%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/protobuf/f78681b8-47f2-44ac-955a-73b828f1b08dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Protocol Buffers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/protobuf/CAF95VAz3nWGiqsHRQNaEBgWN5VvnXtvP-W6SsjekDHhzFt6Ctg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/protobuf/CAF95VAz3nWGiqsHRQNaEBgWN5VvnXtvP-W6SsjekDHhzFt6Ctg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>
> --
> May the source be with you!!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/CAP88TbchGtuKaek38TU5JOByJBm7rTX-fr9TLtf%3DM_WoDYMbAg%40mail.gmail.com
> <https://groups.google.com/d/msgid/protobuf/CAP88TbchGtuKaek38TU5JOByJBm7rTX-fr9TLtf%3DM_WoDYMbAg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CAO78j%2BL%3D%2BafvkuT_6630WPPPka2ikH3YDaVzUc7GBmsr0oCu5Q%40mail.gmail.com.

Reply via email to