js-choi / fnparse Goto Github PK
View Code? Open in Web Editor NEW[deprecated] A library for creating functional parsers in Clojure.
License: Other
[deprecated] A library for creating functional parsers in Clojure.
License: Other
Upload to clojars.org or make it otherwise leiningen friendly.
Thanks.
project.clj is missing a ]
Just an FYI... I was attempting to run the examples and found that there is a large portion of code wrapped in "comment" in hound.clj -- toward the bottom.
Matt
Hey, guys,
We're using fnparse in Drake, and we're running into some parsing performance and stack issues. Parsing a 15k line source of a very simple structure takes forever (minutes) and fails with stack overflow. I tried to profile it with YourKit Java Profiler, and I'm getting endless stack traces full of monads' m_bind_state_t and m_bind_maybe:
The list of most expensive methods by self-time.
It might be that we're doing something wrong defining grammar. Just in case you want to look at it, it's defined here and here.
We used the JSON parser example as a base, and we use a similar method for updating the current column/line numbers. One observation is that getting rid of column/line tracking reduces parsing time of ~500 line file from 4s to <2s or so. Just that simple change.
We're looking for any advice on how to bring parsing times under control, and also if there's a more efficient method for updating column/line than used in your example.
Thank you!
My project that uses fnparse doesn't compile with Clojure 1.3.0 because fnparse depends on clojure-contrib.accumulators, which in turn depends on clojure.set, which doesn't seem to exist any more.
I just tried doing this:
(def specials-
"~`#$&*()|[]{};'"<>?!")
(def specials
(apply p/alt (map p/lit specials-)))
But it didn't work, because p/alt is a macro. ("Can't take value of a macro")
For what it's worth, I basically modified your 'alt' macro and put it into my parser:
(defn altarg
[& subrules](monads/with-monad p/parser-m
%28fn [state#]
%28%28apply monads/m-plus subrules%29 state#%29%29))
(def specials-
"~`#$&*()\\|[]{};'\"<>?!")
(def specials
(apply altarg (map p/lit specials-)))
and all is well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.