clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
vlaaad 2020-10-06T05:48:22.025500Z

Expectations for tools.build keep growing 😂

kwrooijen 2020-10-06T08:41:01.026500Z

Anyone know of a good Clojure(not script) TUI library? Bonus points for GraalVM compatibility

kwrooijen 2020-10-07T08:26:29.098Z

Seems like it. I had some trouble getting it to work. Also I'm not sure why they need to open a port (I guess for remote sessions). I'm going to build a project using membrane for now and see how well it works

borkdude 2020-10-07T08:31:32.098200Z

I asked in #lambdaisland. It's far from ready, it's more like a hobby status and no release on the horizon

borkdude 2020-10-07T08:31:42.098400Z

trikl

borkdude 2020-10-07T08:32:01.098600Z

probably forking lanterna and updating it might be a worthwhile effort

borkdude 2020-10-07T08:32:07.098800Z

(clojure-lanterna)

kwrooijen 2020-10-07T08:35:43.099Z

Yeah that would be beneficial for sure. But contributing back might be a problem https://github.com/MultiMUD/clojure-lanterna/issues/24

kwrooijen 2020-10-07T08:36:47.099400Z

We could have a graalvm compatible fork possibly. Then provide clojure-lanterna with bb, which I think would be a nice balance between low / high level functionality

kwrooijen 2020-10-07T08:37:53.099600Z

Possibly fork to the babashka github org?

borkdude 2020-10-07T08:38:51.099800Z

Yes

borkdude 2020-10-07T08:40:41.100Z

forked here: https://github.com/babashka/clojure-lanterna and invited you

kwrooijen 2020-10-07T09:15:18.102100Z

Thanks 👍

kwrooijen 2020-10-07T09:24:53.102400Z

I'll update my bb branch to use this version, then create a WIP PR

kwrooijen 2020-10-07T12:11:40.108600Z

Having trouble compiling a simple example with 3.0.3. I keep getting undefined reference to Java_java_util_prefs_FileSystemPreferences_chmod. Which might be related to this issue: https://github.com/mabe02/lanterna/issues/499

kwrooijen 2020-10-07T12:12:19.109Z

And possibly fixed in Graal recently https://github.com/oracle/graal/issues/2063

kwrooijen 2020-10-07T12:16:00.109400Z

oh, hm. compiling with java8 graalvm does work :thinking_face:

borkdude 2020-10-07T12:17:01.109600Z

@kevin.van.rooijen I also had this issue with 20.2.0 JDK 11 with the tetris repo, but it started working when I avoided the Swing stuff

borkdude 2020-10-07T12:17:24.109800Z

So avoid all awt references

borkdude 2020-10-07T12:17:46.110Z

See https://github.com/oracle/graal/issues/2898

kwrooijen 2020-10-07T12:19:04.110400Z

Ah I guess the DefaultTerminal class is automatically including swing stuff

kwrooijen 2020-10-07T12:19:16.110600Z

That's a pain

borkdude 2020-10-07T12:19:30.110800Z

Ah really, then maybe not use that class?

kwrooijen 2020-10-07T12:20:13.111Z

Yeah I'd have to look into it. Basically it does all the heavy lifting in terms of OS / terminal / capabilities

kwrooijen 2020-10-07T12:20:40.111200Z

It figures out what you need related to your platform

borkdude 2020-10-07T12:20:50.111400Z

OK, you can try to compile with 20.3.0-dev and see what happens

kwrooijen 2020-10-07T12:22:40.111800Z

Cool thanks, installing now

kwrooijen 2020-10-07T12:27:19.112Z

Sadly that crashes with something new.

Fatal error:com.oracle.svm.core.util.VMError$HostedError: Option name "TruffleMultiThreaded" has multiple definitions: com.oracle.svm.truffle.api.SubstrateTruffleOptions.TruffleMultiThreaded and com.oracle.svm.truffle.api.SubstateTruffleOptions.TruffleMultiThreaded
	at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:68)
	at com.oracle.svm.hosted.option.HostedOptionParser.collectOptions(HostedOptionParser.java:89)
	at com.oracle.svm.hosted.option.HostedOptionParser.<init>(HostedOptionParser.java:62)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:238)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:509)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:115)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:541)
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
	at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1632)
	at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1382)
	at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1343)
	at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1302)
	at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1814)

kwrooijen 2020-10-07T12:27:47.112200Z

Can't find much about this

borkdude 2020-10-07T12:29:11.112400Z

Are you using the reflector fix library?

borkdude 2020-10-07T12:29:20.112600Z

That only works for a specific version

borkdude 2020-10-07T12:29:56.112800Z

I'm not sure what you're compiling here

borkdude 2020-10-07T12:36:11.113100Z

are you compiling bb or the fork of the lib?

borkdude 2020-10-07T12:36:15.113300Z

or some other thing?

kwrooijen 2020-10-07T12:37:42.113500Z

Compiling my own project, and yeah that was the problem. Still no results though. I'm just trying to get a minimal build going

kwrooijen 2020-10-07T12:37:51.113700Z

I can host the code

borkdude 2020-10-07T12:38:07.113900Z

OK. I'll be out for an hour and then I can take a look

kwrooijen 2020-10-07T13:24:21.117500Z

https://github.com/kwrooijen/test-lanterna If getting defaultterminal to work then maybe it is a good idea to avoid it and all swing stuff (For now)

borkdude 2020-10-07T19:32:06.128200Z

Sorry, had something else on my mind.

borkdude 2020-10-07T19:35:53.130Z

So you are trying to use lanterna 3 directly. Why not try to update the clojure-lanterna lib and e.g. build the tetris one?

borkdude 2020-10-07T19:39:16.131200Z

It seems clojure-lanterna isn't using that class directly: https://github.com/MultiMUD/clojure-lanterna/blob/master/src/lanterna/terminal.clj#L1-L10 so maybe this is why compiling does work with that code

kwrooijen 2020-10-07T19:45:47.133Z

While trying to port clojure-laterna I noticed a lot of things are either renamed / deprecated. e.g. the Facade no longer exists. It felt a bit like a rabbit hole so I decided to first get a minimal snippet working

borkdude 2020-10-07T20:04:28.134600Z

:thumbsup:

borkdude 2020-10-07T20:04:46.135Z

Is it possible to not use the DefaultTerminal but something like a TextTerminal instead?

kwrooijen 2020-10-07T20:56:28.147400Z

Yeah that's probably the best option for now. Building my app right now so I'll get to it eventually, then move it to the babashka repo

kwrooijen 2020-10-08T19:11:01.203700Z

Haven't tested Windows though

kwrooijen 2020-10-08T19:13:54.203900Z

Hacking in the clojure-lanterna fork to get it to compile with bb

kwrooijen 2020-10-08T19:33:33.209900Z

https://github.com/babashka/clojure-lanterna/pull/1

borkdude 2020-10-08T19:35:21.212Z

I think you have write access yourself, or do you want me to look at it?

kwrooijen 2020-10-08T19:43:15.215600Z

It's just a WIP at the moment, but just to let you know. Going to make a PR for bb to include this (turned off by default)

borkdude 2020-10-08T19:45:42.215800Z

excellent :)

borkdude 2020-10-08T20:08:22.218300Z

Je kunt alvast wat CircleCI config neerzetten in die babashka lanterna repo. Ik kan dan een token aanmaken en zo wordt het automatisch gedeployed naar clojars.

kwrooijen 2020-10-08T20:08:41.218500Z

👍

borkdude 2020-10-08T20:08:57.218700Z

Zie babashka.nrepl als voorbeeld

borkdude 2020-10-08T20:09:07.218900Z

.circleci/config.yml etc

kwrooijen 2020-10-08T20:33:09.219100Z

https://github.com/babashka/clojure-lanterna/pull/1/files#diff-1d37e48f9ceff6d8030570cd36286a61 Er zijn nog geen tests, waarschijnlijk kunnen er nog wat dingen uit de circleci file. Maar de belangrijkste lijkt me de deploy job?

borkdude 2020-10-08T20:34:10.219300Z

Zijn er in de originele clojure lanterna ook geen tests?

kwrooijen 2020-10-08T20:34:23.219500Z

Nope

borkdude 2020-10-08T20:34:54.219700Z

aha ok

2020-10-06T09:04:14.026700Z

https://github.com/lambdaisland/trikl

borkdude 2020-10-06T09:17:27.027Z

There's also: https://github.com/MultiMUD/clojure-lanterna

borkdude 2020-10-06T09:18:24.027500Z

example: https://github.com/netb258/console-tetris

kwrooijen 2020-10-06T09:32:25.028Z

Thanks, I'll take a look at these options

borkdude 2020-10-06T09:43:33.028200Z

@kevin.van.rooijen Quickly tried to compile tetris: https://github.com/borkdude/console-tetris#graalvm It seems it gets quite far, but there's an error in the final link step.

borkdude 2020-10-06T09:45:28.028600Z

I'll make a graalvm issue

borkdude 2020-10-06T09:49:20.028800Z

https://github.com/oracle/graal/issues/2898

kwrooijen 2020-10-06T09:51:11.029200Z

I think that Lanterna version is pretty outdated. Laterna seems to have updated to 3.1 recently

kwrooijen 2020-10-06T09:51:24.029400Z

Maybe interop would be a better option

kwrooijen 2020-10-06T09:51:57.029600Z

I'll take a look after work

borkdude 2020-10-06T09:52:58.029800Z

yeah. would also be interesting to see if this may work for bb

🙌 1
kwrooijen 2020-10-06T09:55:03.030100Z

If you could seamlessly build tui apps with bb, that would be amazing

borkdude 2020-10-06T09:59:48.030300Z

@kevin.van.rooijen Ah, this guy made it work somehow: https://github.com/phronmophobic/terminal-todo-mvc

borkdude 2020-10-06T09:59:57.030700Z

Totally forgot about that one

borkdude 2020-10-06T10:00:19.030900Z

He uses the new lanterna and made his own wrapper

kwrooijen 2020-10-06T10:02:24.031100Z

Very cool, this project https://github.com/phronmophobic/membrane

borkdude 2020-10-06T10:17:40.032100Z

@kevin.van.rooijen Would also be interesting to try out trilk: https://github.com/lambdaisland/trikl#graal-compatibility

kwrooijen 2020-10-06T10:19:47.034300Z

Will do, though I think Lanterna looks more promising since it's a bit more maintained. I think this is built from scratch and commits look a bit quiet

kwrooijen 2020-10-06T10:20:08.034900Z

Also seems to be a work in progress and not on clojars

kwrooijen 2020-10-06T10:21:00.036600Z

(seems to be another branch that's being worked on, by bad)

borkdude 2020-10-06T10:21:35.037Z

yeah

borkdude 2020-10-06T10:21:39.037200Z

oh

borkdude 2020-10-06T10:27:50.037400Z

The code looks quite minimal, and minimal is good imo ;)

kwrooijen 2020-10-06T10:28:34.037600Z

Very true

borkdude 2020-10-06T10:28:59.037800Z

maybe it doesn't support mouse clicks etc

borkdude 2020-10-06T10:29:09.038Z

so maybe lantera is a better option in that regard

borkdude 2020-10-06T10:29:24.038200Z

I'll keep an eye on your experimentation

borkdude 2020-10-06T10:29:31.038400Z

or: feel free to keep me posted

kwrooijen 2020-10-06T10:31:16.038600Z

Will do

Matias Francisco Hernandez Arellano 2020-10-06T13:15:22.039700Z

Hi Folks.. New to clojure looking for some help

Matias Francisco Hernandez Arellano 2020-10-06T13:15:39.039900Z

I'm trying to build a discord bot and in the example code of discljord defines a state variable

(def state (atom nil))
That is then used in the event handler
(defmethod handle-event :message-create
  [event-type {{bot :bot} :author :keys [channel-id content]}]
  (if (= content "!disconnect")
    (c/disconnect-bot! (:connection @state))
    (when-not bot
      (m/create-message! (:messaging @state) channel-id :content "Hello, World!"))))
I'm looking to create multiple event-handler each of those inside it's own namespace to be able to develop different commands that can be attached to the the bot ..., but not sure about the clojure way to pass that state variable across the namespaces. Should I just create the event handler and accept the state as argument? like
(defn get-on-brd-handler
  [event-type {{bot :bot} :author :keys [channel-id content]} state]
)

flowthing 2020-10-06T13:43:46.040100Z

This question might be a better fit in #beginners, but you don’t need to pass it across namespaces. You can just reference it directly. For example:

(ns foo.bar)

(def state (atom nil))
And:
(ns bar.baz
  (:require [foo.bar :as bar]))

(defn handler
  [,,,]
  (do-something-with @bar/state))

kwrooijen 2020-10-06T13:58:59.040700Z

Nice, good catch on the :text instead of :swing

kwrooijen 2020-10-06T14:07:52.040900Z

How would you integrate something like this in bb? Would you have to write an impl like with jdbc?

borkdude 2020-10-06T14:08:56.041100Z

yes, just check the other libraries that are included

Matias Francisco Hernandez Arellano 2020-10-06T14:33:34.041500Z

Thanks.

kwrooijen 2020-10-06T16:12:43.041900Z

Progress!

borkdude 2020-10-06T16:13:38.042300Z

wut!

kwrooijen 2020-10-06T16:15:01.042500Z

I'll continue on this after dinner, maybe open a WIP PR?

borkdude 2020-10-06T16:20:52.042700Z

Sure. Can you make a feature toggle for it like in: https://github.com/borkdude/babashka/blob/master/doc/build.md#feature-flags and then turn it off by default?

borkdude 2020-10-06T16:21:45.043100Z

We can turn it on after some experimentation, but I'm always conservative with adding things by default, since CI is memory constraint

borkdude 2020-10-06T16:21:57.043300Z

Also binary size is something I monitor

emccue 2020-10-06T16:28:48.044300Z

Is there any clojure/java equivalent to rails ActiveSupport::Inflector?

borkdude 2020-10-06T16:31:14.044400Z

But adding something under a feature flag is always good for a PR

emccue 2020-10-06T16:36:26.045200Z

I just want to make some strings singular

2020-10-06T16:36:29.045300Z

clojure.pprint/cl-format can do some of that

emccue 2020-10-06T16:37:13.045700Z

cl-format can hold rules for it

emccue 2020-10-06T16:37:46.046500Z

but specifically I am looking to name my sql tables plural and just have a result builder that changes :users/id to :user/id

2020-10-06T16:38:01.046800Z

user=> (clojure.pprint/cl-format nil "~D tr~:@P/~D win~:P" 7 1)
"7 tries/1 win"

emccue 2020-10-06T16:39:40.047600Z

yeah but that only works if I have a certain amount of times something appears in mind and also deconstruct the string into the format

emccue 2020-10-06T16:40:17.048500Z

like I can manually write {"users" "user"} and do a mapping - but I'm looking to see if I can "solve" the problem

2020-10-06T16:40:50.049300Z

given your actual use case, I suspect the amount of effort that would go into automating it exceeds the effort of just having a conversion layer that knows about each table

emccue 2020-10-06T16:41:38.050200Z

Thats true, but there are "cool" and "fun" bars that only apply when unemployed and working on hobby projects

2020-10-06T16:42:25.051400Z

also YMMV but many people consider that kind of magic conversion part of what's wrong with rails

dpsutton 2020-10-06T16:43:20.052900Z

and one day you'll end up with a table called Librarys rather than the proper plural because its simpler than building an override mechanism to whatever you're doing

1
2020-10-06T16:52:02.057900Z

I've got a result body coming out of a clj-http call that I'm needing to parse. I wrote a simple ANTLR grammar for the body that compiles using clj-antlr/parser with no issues. The problem comes when I try to actually apply the generated parser function to an input string. At this point, the parse errors out with the following message: Execution error (NullPointerException) at org.antlr.v4.runtime.atn.ATNSerializer/serialize (ATNSerializer.java:73). null. Any idea on how to even start debugging this? Or does anyone have a recommendation for a different parser library that is perhaps not so opaque?

p-himik 2020-10-06T16:53:23.058Z

Does the exception has any stack trace?

2020-10-06T16:55:51.058200Z

Have you looked at Instaparse? https://github.com/Engelberg/instaparse

p-himik 2020-10-06T16:57:19.058500Z

Instaparse doesn't handle ANTLR grammars.

2020-10-06T16:58:49.058700Z

Stack trace is as follows: [[org.antlr.v4.runtime.atn.ATNSerializer serialize ATNSerializer.java 73]   [org.antlr.v4.runtime.atn.ATNSerializer getSerialized ATNSerializer.java 601]   [org.antlr.v4.runtime.atn.ATNSerializer getSerializedAsChars ATNSerializer.java 605]   [org.antlr.v4.tool.Grammar createParserInterpreter Grammar.java 1337]   [clj_antlr.interpreted$singlethreaded_parser invokeStatic interpreted.clj 111]   [clj_antlr.interpreted$singlethreaded_parser invoke interpreted.clj 107]   [clj_antlr.interpreted.ThreadLocalParser parse interpreted.clj 119]   [clj_antlr.core.ParserWrapper parse core.clj 13]   [clj_antlr.core$parse_STAR_ invokeStatic core.clj 28]   [clj_antlr.core$parse_STAR_ invoke core.clj 19]   [clj_antlr.core$parse invokeStatic core.clj 35]   [clj_antlr.core$parse invoke core.clj 30]   [clj_antlr.core.ParserWrapper invoke core.clj 17]   [cql_p arser.core$parse_RAS_results invokeStatic form-init5406870106907233552.clj 822]   [cql_parser.core$parse_RAS_results invoke form-init5406870106907233552.clj 820]   [cql_parser.core$run_cql_file invokeStatic form-init5406870106907233552.clj 122]   [cql_parser.core$run_cql_file invoke form-init5406870106907233552.clj 109]   [cql_parser.core$run_cql_tests$fn__231 invoke core.clj 132]   [clojure.core$map$fn__5866 invoke core.clj 2755]   [clojure.lang.LazySeq sval LazySeq.java 42]   [clojure.lang.LazySeq seq LazySeq.java 51]   [clojure.lang.RT seq RT.java 535]   [clojure.core$seq__5402 invokeStatic core.clj 137]   [clojure.core$dorun invokeStatic core.clj 3133]   [clojure.core$doall invokeStatic core.clj 3148]   [clojure.core$doall invoke core.clj 3148]   [cql_parser.core$run_cql_tests invokeStatic core.clj 132]   [cql_parser.core$run_cql_tests invoke core.clj 128]   [cql_parser.core$_main invokeStatic core.clj 142]   [cql_parser.core$_main doInvoke core.clj 136]   [clojure.lang.RestFn invoke RestFn.java 397]   [c ql_parser.core$eval46620 invokeStatic form-init5406870106907233552.clj 1]   [cql_parser.core$eval46620 invoke form-init5406870106907233552.clj 1]   [clojure.lang.Compiler eval Compiler.java 7177]   [clojure.lang.Compiler eval Compiler.java 7132]   [clojure.core$eval invokeStatic core.clj 3214]   [clojure.core$eval invoke core.clj 3210]   [nrepl.middleware.interruptible_eval$evaluate$fn__944 invoke interruptible_eval.clj 91]   [clojure.main$repl$read_eval_print__9086$fn__9089 invoke main.clj 437]   [clojure.main$repl$read_eval_print__9086 invoke main.clj 437]   [clojure.main$repl$fn__9095 invoke main.clj 458]   [clojure.main$repl invokeStatic main.clj 458]   [clojure.main$repl doInvoke main.clj 368]   [clojure.lang.RestFn invoke RestFn.java 1523]   [nrepl.middleware.interruptible_eval$evaluate invokeStatic interruptible_eval.clj 84]   [nrepl.middleware.interruptible_eval$evaluate invoke interruptible_eval.clj 56]   [nrepl.middleware.interruptible_eval$interruptible_eval$fn__970$fn__974 invoke interruptible_eva l.clj 155]   [clojure.lang.AFn run AFn.java 22]   [nrepl.middleware.session$session_exec$main_loop__1071$fn__1075 invoke session.clj 190]   [nrepl.middleware.session$session_exec$main_loop__1071 invoke session.clj 189]   [clojure.lang.AFn run AFn.java 22]   [java.lang.Thread run Thread.java 745]]} CqlArithmeticFunctionsTest.cql #error {  :cause nil  :via  [{:type java.lang.NullPointerException    :message nil    :at [org.antlr.v4.runtime.atn.ATNSerializer serialize ATNSerializer.java 73]}]  :trace  [[org.antlr.v4.runtime.atn.ATNSerializer serialize ATNSerializer.java 73]   [org.antlr.v4.runtime.atn.ATNSerializer getSerialized ATNSerializer.java 601]   [org.antlr.v4.runtime.atn.ATNSerializer getSerializedAsChars ATNSerializer.java 605]   [org.antlr.v4.tool.Grammar createParserInterpreter Grammar.java 1337]   [clj_antlr.interpreted$singlethreaded_parser invokeStatic interpreted.clj 111]   [clj_antlr.interpreted$singlethreaded_parser invoke interpreted.clj 107]   [clj_antlr.interpreted.ThreadLocalParser parse interpreted.clj 119]   [clj_antlr.core.ParserWrapper parse core.clj 13]   [clj_antlr.core$parse_STAR_ invokeStatic core.clj 28]   [clj_antlr.core$parse_STAR_ invoke core.clj 19]   [clj_antlr.core$parse invokeStatic core.clj 35]   [clj_antlr.core$parse invoke core.clj 30]   [clj_antlr.core.ParserWrapper invoke core.clj 17]   [cql_p arser.core$parse_RAS_results invokeStatic form-init5406870106907233552.clj 822]   [cql_parser.core$parse_RAS_results invoke form-init5406870106907233552.clj 820]   [cql_parser.core$run_cql_file invokeStatic form-init5406870106907233552.clj 122]   [cql_parser.core$run_cql_file invoke form-init5406870106907233552.clj 109]   [cql_parser.core$run_cql_tests$fn__231 invoke core.clj 132]   [clojure.core$map$fn__5866 invoke core.clj 2755]   [clojure.lang.LazySeq sval LazySeq.java 42]   [clojure.lang.LazySeq seq LazySeq.java 51]   [clojure.lang.Cons next Cons.java 39]   [clojure.lang.RT next RT.java 713]   [clojure.core$next__5386 invokeStatic core.clj 64]   [clojure.core$dorun invokeStatic core.clj 3142]   [clojure.core$doall invokeStatic core.clj 3148]   [clojure.core$doall invoke core.clj 3148]   [cql_parser.core$run_cql_tests invokeStatic core.clj 132]   [cql_parser.core$run_cql_tests invoke core.clj 128]   [cql_parser.core$_main invokeStatic core.clj 142]   [cql_parser.core$_main doInvoke core.clj 136]   [clojure .lang.RestFn invoke RestFn.java 397]   [cql_parser.core$eval46620 invokeStatic form-init5406870106907233552.clj 1]   [cql_parser.core$eval46620 invoke form-init5406870106907233552.clj 1]   [clojure.lang.Compiler eval Compiler.java 7177]   [clojure.lang.Compiler eval Compiler.java 7132]   [clojure.core$eval invokeStatic core.clj 3214]   [clojure.core$eval invoke core.clj 3210]   [nrepl.middleware.interruptible_eval$evaluate$fn__944 invoke interruptible_eval.clj 91]   [clojure.main$repl$read_eval_print__9086$fn__9089 invoke main.clj 437]   [clojure.main$repl$read_eval_print__9086 invoke main.clj 437]   [clojure.main$repl$fn__9095 invoke main.clj 458]   [clojure.main$repl invokeStatic main.clj 458]   [clojure.main$repl doInvoke main.clj 368]   [clojure.lang.RestFn invoke RestFn.java 1523]   [nrepl.middleware.interruptible_eval$evaluate invokeStatic interruptible_eval.clj 84]   [nrepl.middleware.interruptible_eval$evaluate invoke interruptible_eval.clj 56]   [nrepl.middleware.interruptible_eval$interruptible_eval $fn__970$fn__974 invoke interruptible_eval.clj 155]   [clojure.lang.AFn run AFn.java 22]   [nrepl.middleware.session$session_exec$main_loop__1071$fn__1075 invoke session.clj 190]   [nrepl.middleware.session$session_exec$main_loop__1071 invoke session.clj 189]   [clojure.lang.AFn run AFn.java 22]   [java.lang.Thread run Thread.java 745]]

2020-10-06T17:02:01.059Z

I've looked at Instaparse. If I can't get clj-antlr working (it has worked for me in previous projects), I'll start looking at alternatives. The language only has about a dozen productions so no matter how I do it, it'll eventually work - it's just that there are some complicated date-time formats to parse that I already have ANTLR code for.

2020-10-06T17:02:11.059200Z

the only duck duck go hit for the exeception messages looks relevant https://stackoverflow.com/questions/60002238/antl4-grammar-compile-nullpointer-exception

p-himik 2020-10-06T17:05:33.059600Z

Huh. I wonder how can data.add(atn.grammarType.ordinal()); throw an NPE given that none of the values are null.

2020-10-06T17:06:10.059800Z

@hiredman - I checked that out, too. I'm not using skip anywhere in the grammar as far as I know, which I believe is what the error in this case hinges on.

2020-10-06T17:06:42.060Z

Here's the grammar, if that helps.

2020-10-06T17:06:53.060200Z

grammar RASResults; value     : tuple     | list     | interval     | literal     ; interval     : 'Interval' leftInterval literal ',' literal rightInterval      ; leftInterval     : '[' | '('     ; rightInterval     : ']' | ')'         ; list     : '[' valueList ']'     ; valueList     :     | value     | value ',' valueList     ; tuple         : 'Tuple' '{' pair '}'         | '{' STRING ':' STRING '}'         ; pair         : identifier '->' value         ; literal         : '{' '}'                                               #emptyListLiteral         | 'null'                                                #nullLiteral         | ('true' | 'false')                                    #booleanLiteral         | STRING                                                #stringLiteral         | NUMBER                                                #numberLiteral         | DATETIME                                              #dateTimeLiteral         | TIME                                                  #timeLiteral         ; identifier         : IDENTIFIER         ; /     Lexical rules */ DATETIME         : '@'             [0-9][0-9][0-9][0-9] // year             (                 (                     '-'[0-9][0-9] // month                     (                         (                             '-'[0-9][0-9] // day                             ('T' TIMEFORMAT?)?                         )                         | 'T'                     )?                 )                 | 'T'             )?             ('Z' | ('+' | '-') [0-9][0-9]':'[0-9][0-9])? // timezoneOffset         ; TIME         : '@' 'T' TIMEFORMAT         ; fragment TIMEFORMAT         : [0-9][0-9] (':'[0-9][0-9] (':'[0-9][0-9] ('.'[0-9]+)?)?)?         ; IDENTIFIER         : ([A-Za-z] | '')([A-Za-z0-9] | '')*            // Added _ to support CQL (FHIR could constrain it out)         ; STRING         : '"' (ESC | .)*? '"'         ; // Also allows leading zeroes now (just like CQL and XSD) NUMBER         : [0-9]+('.' [0-9]+)?         ; // Pipe whitespace to the HIDDEN channel to support retrieving source text through the parser. WS         : [ \r\n\t]+ -> channel(HIDDEN)         ; fragment ESC         : '\\' ([`'\\/fnrt] | UNICODE)    // allow \`, \', \\, \/, \f, etc. and \uXXX         ; fragment UNICODE         : 'u' HEX HEX HEX HEX         ; fragment HEX         : [0-9a-fA-F]         ;

2020-10-06T17:08:09.060400Z

but it points to it not being a clojure specific issue, but some issue with antlr, which means you'll have better luck asking people who know antlr, not people who know clojure

p-himik 2020-10-06T17:12:46.060600Z

@fadrian FWIW your grammar worked just fine for me with value being the root and with "{\"a\":\"b\"}" as an input.

2020-10-06T17:16:04.060900Z

I tried "49" as an input to get the error. But if you can parse that string, it may just be something in the NUMBER token that's screwing up. Let me try a few other inputs. Thanks for everyone's suggestions and assistance.

p-himik 2020-10-06T17:17:48.061100Z

"49" also worked just fine for me.

p-himik 2020-10-06T17:18:39.061300Z

Perhaps it's a version issue. I have clj-antlr 0.2.6 and antlr4 4.8-1.

kwrooijen 2020-10-06T17:22:11.061500Z

It's also a question what we want to actually supply. the clojure-lanterna lib is a bit outdated and unmaintained(?)

2020-10-06T17:24:42.061700Z

That may be. I'm still using clj-antlr 0.2.5 and I'm not sure which version of ANTLR it's using. I'll make sure everything's updated. But you've given me a couple of leads. Thanks.

kwrooijen 2020-10-06T17:26:38.061900Z

There were some things in clojure-lanterna which didn't work with GraalVM. e.g. some functions read the file system I think, and resulted in com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of <http://sun.nio.ch|sun.nio.ch>.FileChannelImpl

kwrooijen 2020-10-06T17:26:49.062100Z

Not sure how to fix that in GraalVM

kwrooijen 2020-10-06T17:32:28.062300Z

Reagent for Lanterna sounds like a fun project. On the otherhand we also have Membrane which could be an option

2020-10-06T17:40:16.062600Z

Upgrading clj-antlr to 0.2.6 seemed to do the trick. Thanks again, all.

borkdude 2020-10-06T19:54:59.064900Z

Isn't trikl intented as a reagent for the terminal kind of maybe?

2020-10-06T21:44:34.065500Z

There are pretty extensive libraries around everything natural language, icu4j springs to mind. Looking at the docs, it has pluralization.

2020-10-06T21:45:20.065700Z

But; I guess thats something to consider when you have extensively translatable apps with dozens of languages 😛

2020-10-06T21:47:40.066Z

But yeah, some people have gone above and beyond in encoding natural language inconsistencies in every imaginable aspect 😛