instaparse

If you're not trampolining your parser, why bother getting up in the morning?
2017-08-30T20:13:48.000077Z

In clojurescript with defparser, Im guessing the regexes are read wrongly, with insta/parser I get in my willingly generated token error

{:tag :regexp,
 :expecting #"^[0-9]+\.?[0-9]*"}
in same error via defparse
{:tag :regexp,
 :expecting #"^\/^[0-9]+\.?[0-9]*\/"}
both originating from <digit> = #'[0-9]+\\.?[0-9]*'

2017-08-30T20:15:32.000271Z

my first question should be, does some other clojurescript user experience this, as Im running my forked version of Instaparse 1.4.7 running on lumo.

aengelberg 2017-08-30T20:16:28.000137Z

Instaparse is known to have some bugs on Lumo

aengelberg 2017-08-30T20:16:41.000073Z

because Lumo behaves weirdly with cljc files

2017-08-30T20:17:30.000102Z

yes, I know, I've fixed those on my fork and it's effectively working fine, just this one error with regexes, so Im only guessing this is unrelated.

aengelberg 2017-08-30T20:17:35.000515Z

since defparse is evaluated at macro-time, not runtime, my guess is that Lumo trying to execute code on ClojureScript that was meant to be run on Clojure

2017-08-30T20:18:26.000048Z

or related, then in the way you described 🙂

aengelberg 2017-08-30T20:18:33.000100Z

The regexp combinator in particular has special logic when run on ClojureScript https://github.com/Engelberg/instaparse/blob/master/src/instaparse/combinators_source.cljc#L93

aengelberg 2017-08-30T20:18:38.000069Z

which might be why you're only running into this now

2017-08-30T20:19:38.000183Z

hmm, ok, I try removing this constraint to see what happens...

aengelberg 2017-08-30T20:19:54.000273Z

also maybe try not using defparser and see if that fixes it

2017-08-30T20:20:38.000250Z

yes, that fixes it, I want to use defparser for the performance it brings, Im using the parser to evaluate musical expressions in realtime music application

aengelberg 2017-08-30T20:28:18.000398Z

makes sense.

aengelberg 2017-08-30T20:28:35.000515Z

also that sounds cool, is your application similar to https://github.com/alda-lang/alda ?

2017-08-30T20:38:15.000146Z

The Adlaphone: a musical instrument for programmers

2017-08-30T20:39:58.000160Z

only very partially similar to Alda, the use of parser is very limited, and only an extra feature Im implementing atm.

2017-08-30T20:41:13.000665Z

more about native datatypes Im sending to Csound, audio processing language, and make simple repetitive patterns.

2017-08-30T20:54:34.000055Z

loud thinking, I notice that the function regex gets called twice by defparser but once on parse, the second time the input is "/^[0-9]+\.?[0-9]*/" and returnes #"^\/^[0-9]+\.?[0-9]*\/"

2017-08-30T20:58:58.000586Z

ah fixed it 🙂

2017-08-30T21:00:05.000018Z

in defparse macro I commented

;; Regexp terminals are handled differently in cljs
 ;; (= :regexp (:tag form))
 ;; `(merge (c/regexp ~(str (:regexp form)))
 ;;         ~(dissoc form :tag :regexp))
maybe I should test the standard cljs and see if this is also a problem there.