Fork me on GitHub
#instaparse
<
2017-08-30
>
hlolli20:08:48

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]*'

hlolli20:08:32

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.

aengelberg20:08:28

Instaparse is known to have some bugs on Lumo

aengelberg20:08:41

because Lumo behaves weirdly with cljc files

hlolli20:08:30

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.

aengelberg20:08:35

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

hlolli20:08:26

or related, then in the way you described 🙂

aengelberg20:08:33

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

aengelberg20:08:38

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

hlolli20:08:38

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

aengelberg20:08:54

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

hlolli20:08:38

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

aengelberg20:08:18

makes sense.

aengelberg20:08:35

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

gfredericks20:08:15

The Adlaphone: a musical instrument for programmers

hlolli20:08:58

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

hlolli20:08:13

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

hlolli20:08:34

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]*\/"

hlolli20:08:58

ah fixed it 🙂

hlolli21:08:05

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.