Jsonnet BNF?

33 views
Skip to first unread message

Eugene Berman

unread,
Jul 6, 2023, 10:42:07 AM7/6/23
to jso...@googlegroups.com
I’m not sure if this has been asked before, but I’m wondering if BNF exists for Jsonnet, something I can use to generate a parser code, say, using a Knife parser generator.
I’m trying to build a Java implementation of the language server for jsonnet and the lack of Java parser seems to be the showstopper.

Many thanks!

E.
---

AIorK4xFjgCa8iJ5-ACzLOMCaeFSO-_xI_b0OkflhTkVs43sJed7TIzkVSDTcOjHCGkM3TDt5_s-BXQ.png

Eugene Berman
Principal Architect

7525 SE 24th St, Suite 510
Mercer Island WA 98040

Dave Cunningham

unread,
Jul 6, 2023, 2:05:43 PM7/6/23
to Eugene Berman, jso...@googlegroups.com
There is nothing official because implementations have just had handwritten recursive descent parsers.  

Maybe this post from a while ago might be useful? https://groups.google.com/g/jsonnet/c/jOMepyno6ag/m/4kv_OnIjCAAJ

--
You received this message because you are subscribed to the Google Groups "Jsonnet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsonnet+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsonnet/456BFFDA-6A0C-4AB6-B036-32155460A6CE%40modusbox.com.

Dave Cunningham

unread,
Jul 6, 2023, 2:27:38 PM7/6/23
to Eugene Berman, jso...@googlegroups.com
Also there is a scala version and a rust version that may have a parser you can use.  A long time ago there was an attempt to reimplement jsonnet in raw java but I'm not sure how far it got.

BTW are you aware of https://github.com/grafana/jsonnet-language-server and if so why do you want to write a new one in java?

Eugene Berman

unread,
Jul 6, 2023, 2:29:50 PM7/6/23
to jso...@googlegroups.com
Yes, I’m familiar with sjsonnet but I found it very difficult to use from the java code.

The reason I want to write my own is because the language is not really jsonnet, it’s datasonnet, it is based on jsonnet but has additional features and ultimately serves a different purpose, so unfortunately I cannot reuse Grafana language server implementation. 

---

AIorK4xFjgCa8iJ5-ACzLOMCaeFSO-_xI_b0OkflhTkVs43sJed7TIzkVSDTcOjHCGkM3TDt5_s-BXQ.png

Eugene Berman
Principal Architect

7525 SE 24th St, Suite 510
Mercer Island WA 98040
On Jul 6, 2023, at 11:27 AM, Dave Cunningham <dcu...@google.com> wrote:

Also there is a scala version and a rust version that may have a parser you can use.  A long time ago there was an attempt to reimplement jsonnet in raw java but I'm not sure how far it got.

BTW are you aware of https://github.com/grafana/jsonnet-language-server and if so why do you want to write a new one in java?

On Thu, 6 Jul 2023 at 19:05, Dave Cunningham <dcu...@google.com> wrote:
There is nothing official because implementations have just had handwritten recursive descent parsers.  

Maybe this post from a while ago might be useful? https://groups.google.com/g/jsonnet/c/jOMepyno6ag/m/4kv_OnIjCAAJ

On Thu, 6 Jul 2023 at 15:42, 'Eugene Berman' via Jsonnet <jso...@googlegroups.com> wrote:
I’m not sure if this has been asked before, but I’m wondering if BNF exists for Jsonnet, something I can use to generate a parser code, say, using a Knife parser generator.
I’m trying to build a Java implementation of the language server for jsonnet and the lack of Java parser seems to be the showstopper.

Many thanks!

E.
---

<AIorK4xFjgCa8iJ5-ACzLOMCaeFSO-_xI_b0OkflhTkVs43sJed7TIzkVSDTcOjHCGkM3TDt5_s-BXQ.png>

Eugene Berman
Principal Architect

7525 SE 24th St, Suite 510
Mercer Island WA 98040

Dave Cunningham

unread,
Jul 6, 2023, 3:30:40 PM7/6/23
to Eugene Berman, jso...@googlegroups.com
I'd not heard of datasonnet before.  It sounds interesting!  Is it a totally fresh implementation of a language based on jsonnet?

yoann padioleau

unread,
Jul 20, 2023, 1:12:12 AM7/20/23
to Jsonnet
There is a tree-sitter grammar for jsonnet, which is quite close to BNF:

There's also some java bindings to tree-sitter: https://github.com/serenadeai/java-tree-sitter
so in theory you could reuse the tree-sitter-jsonnet parser from Java.
Reply all
Reply to author
Forward
0 new messages