Ooph! Thank you!! I wish I knew about your libparser before I started down the regex jungle trying to parse the protobuf structure. I will finish this as a v1 with caveman regex then port to libparser for a v2.
SearchResponseResult is a good idea as well. Thank you. - Igbanam On Sat, Mar 23, 2024 at 1:41 PM Lifepillar <lifepil...@lifepillar.me> wrote: > On 2024-03-22, Igbanam Ogbuluijah <xigba...@gmail.com> wrote: > > Hello community, > > > > I've been playing with some idea which has brought me to needing Nested > > Classes in Vim. I am curious what you think about this? Would this be too > > much for Vimscript? If not, what current workarounds would you suggest? > > I don't think Vim 9 script needs or would gain anything for such > extensions. > > > Context: I'm taking a stab at parsing protobuf definitions into Vim 9 > > classes. Nested messages in the protobuf demands > ><https://arc.net/l/quote/qfcssecm> nested structs/classes. > > Something like: > > message SearchResponse { > message Result { > string url = 1; > string title = 2; > repeated string snippets = 3; > } > repeated Result results = 1; > } > > becomes two classes/structs `SearchResponse` and `SearchResponse_Result` > in the target languages I've looked at. In Vim, you could do the same: > > interface Message > endinterface > > class SearchResponseResult implements Message > var url: string > var title: string > var snippets: list<string> > endclass > > class SearchResponse implements Message > var results: list<SearchResponseResult> > endclass > > That seems the most straightforward approach to me. > > If you don't care about typing (but wouldn't that defeat the purpose of > protobuf?), you may simply use dictionaries, which can be arbitrarily > nested. > > If your problem is parsing, libparser might help: > > https://github.com/lifepillar/vim-devel > > Protobuf's grammar seems simple enough. You might even go fancy and > generate parsers from messages, which would be able to parse the > corresponding messages. > > I don't see any reason to keep using Vim legacy script for new Vim > scripts. > > Hope this helps, > Life. > > -- > -- > You received this message from the "vim_use" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > > --- > You received this message because you are subscribed to the Google Groups > "vim_use" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to vim_use+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/vim_use/utmm5o%2412c1%241%40ciao.gmane.io > . > -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAOmRJrdJvbou%3Di0k6iWePH_uvzfVBsf1Wkbt5Jc0s%2BRTkbNjqA%40mail.gmail.com.