Skip to content
This repository has been archived by the owner on Apr 2, 2018. It is now read-only.

Error parsing grammar specification #20

Open
johanatan opened this issue Nov 14, 2016 · 6 comments
Open

Error parsing grammar specification #20

johanatan opened this issue Nov 14, 2016 · 6 comments

Comments

@johanatan
Copy link

johanatan commented Nov 14, 2016

On Clojure 1.8.0 and ClojureScript 1.9.293, I'm getting the following error when requiring the instaparse module:

Uncaught exception: Error parsing grammar specification:
Parse error at line nil , column nil :

nil
nil

From cfg.cljs I can see that this is instaparse loading an internal grammar specification named 'cfg'. Is this a known issue? Could it be something else with my project setup (I didn't try a minimal repro but I can do that if you can't reproduce/don't see the issue right away).

@aengelberg
Copy link
Collaborator

I can't seem to reproduce. I went into the instaparse-cljs project (master branch) and changed the clj/cljs dependencies to your listed versions, then ran a basic ClojureScript repl:

$ lein run -m cljs.repl.node
Rewriting src/cljx to target/generated/src/clj (clj) with features #{clj} and 0 transformations.
Rewriting src/cljx to target/generated/src/cljs (cljs) with features #{cljs} and 1 transformations.
Rewriting test/cljx to target/generated/test/clj (clj) with features #{clj} and 0 transformations.
Rewriting test/cljx to target/generated/test/cljs (cljs) with features #{cljs} and 1 transformations.
ClojureScript Node.js REPL server listening on 54401
To quit, type: :cljs/quit
cljs.user=> (require 'instaparse.core)
true

@johanatan
Copy link
Author

I was afraid of that. Sorry for the false alarm.

@johanatan
Copy link
Author

Here's my full project.clj (in case there are other consequential differences [plugins etc]):

(defproject speako "0.1.5-SNAPSHOT"
  :description "speako: Speak GraphQL Schema Language with ease."
  :url "https://github.com/johanatan/speako"

  :clean-targets ["build" :target-path]

  :dependencies [[org.clojure/clojure "1.8.0"]
                 [org.clojure/clojurescript "1.9.293" :classifier "aot"]
                 [org.clojure/core.match "0.3.0-alpha4"]
                 [com.lucasbradstreet/cljs-uuid-utils "1.0.2"]
                 [com.lucasbradstreet/instaparse-cljs "1.4.1.2"]
                 [io.nervous/cljs-nodejs-externs "0.2.0"]
                 [org.clojure/tools.cli "0.3.3"]]

  :plugins [[lein-cljsbuild "1.1.4"]
            [lein-npm "0.6.2"]
            [lein-doo "0.1.7"]
            [org.bodil/lein-noderepl "0.1.11"]]

  :profiles {:dev {:dependencies [[lein-doo "0.1.6"]]}}

  :npm {:dependencies [[source-map-support "0.4.0"]]
        :package {;; To distribute a node library, set :main
                  :main "build/main.js"
                  ;; To push to a publicly available npm name set :private
                  :private false
                  }}

  :aliases {"build" ["cljsbuild" "once" "main"]
            "test" ["doo" "node" "test-node" "once"]
            "test-auto" ["doo" "node" "test-node" "auto"]}

  :release-tasks [["vcs" "assert-committed"]
                  ["clean"]
                  ["build"]
                  ["change" "version"
                   "leiningen.release/bump-version" "release"]
                  ["vcs" "commit"]
                  ["vcs" "tag"]
                  ["npm" "publish"]
                  ["change" "version" "leiningen.release/bump-version"]
                  ["vcs" "commit"]
                  ["vcs" "push"]]

  :cljsbuild {:builds [{:id "main"
                        :source-paths ["src"]
                        :compiler {:output-to "build/main.js"
                                   :output-dir "build/js"
                                   :optimizations :none
                                   :target :nodejs
                                   :source-map true
                                   :main speako.core
                                   ;:source-map "build/main.js.map"
                                   }}
                       {:id "test-node"
                        :source-paths ["src" "test"]
                        :compiler {:main speako.core-runner
                                   :output-to     "build/test-node.js"
                                   :target :nodejs
                                   :output-dir    "build/test-js"
                                   :optimizations :none
                                   :pretty-print  true}}]})

I have verified that this goes away if I remove instaparse from my project. And the following is the usage of it:

(def ^:private type-language-parser (insta/parser
  "<S> = TYPE+
  TYPE = <WS> (OBJECT | UNION | ENUM) <WS>
  <OBJECT> = TYPE_KEYWORD <RWS> IDENTIFIER <WS> <'{'> FIELD+ <WS> <'}'>
  TYPE_KEYWORD = 'type'
  RWS = #'\\s+'
  WS = #'\\s*'
  IDENTIFIER = #'[a-zA-Z0-9_]+'
  FIELD = <WS> IDENTIFIER <WS> <':'> <WS> (LIST | DATATYPE) [NOTNULL]
  LIST = <'['> DATATYPE <']'>
  NOTNULL = <'!'>
  DATATYPE = 'ID' | 'Boolean' | 'String' | 'Float' | 'Int' | IDENTIFIER
  <UNION> = UNION_KEYWORD <RWS> IDENTIFIER <WS> <'='> <WS> IDENTIFIER <WS> OR_CLAUSE+
  UNION_KEYWORD = 'union'
  <OR_CLAUSE> = <'|'> <WS> IDENTIFIER <WS>
  <ENUM> = ENUM_KEYWORD <RWS> IDENTIFIER <WS> <'{'> <WS> ENUM_VAL COMMA_ENUM_VAL+ <WS> <'}'>
  ENUM_KEYWORD = 'enum'
  ENUM_VAL = IDENTIFIER
  <COMMA_ENUM_VAL> = <WS> <','> <WS> ENUM_VAL" :output-format :enlive))

I'm pretty much stumped on this so any help you could offer would be great.

Thanks,
Jonathan

@johanatan johanatan reopened this Nov 16, 2016
@johanatan
Copy link
Author

johanatan commented Nov 17, 2016

P.S. It seems to not be enough to merely require the module in a REPL. I only get the error from a file-based compilation including the instaparse module require.

It seems the problem is during creation of the symbol instaparse.abnf.abnf_parser (which processes the internal abnf-grammar).

@johanatan
Copy link
Author

Update: tracing further I see that gll.run exhausts the entire stack and eventually returns nil.

@johanatan
Copy link
Author

@aengelberg Were you able to take a further look at this (or provide any more direction/insight)?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants