Skip to content

apg/kessel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Kessel

Kessel is a reworking of clarsec to use contrib.monads instead of the home brewed monads in clarsec. I'd like to, in the future, build this into something that can handle any grammar without blowing up, using some memoization techniques I've read about in some papers, but we'll see if that ever happens.

## Usage

See the examples in kessel/examples.


## Caveats (unchanged from clarsec)

forward references are a mess. I tried to maintain the DSL as simple as possible. Imagine that "structureDef" and "comma" are two already existing
parsers, and "brackets" and "sepBy" are two combinators. I want to be able to write it like this:

  (def structure 
       (brackets (sepBy structureDef comma)))

however, clojures 'def' binding is strict and all the referenced vars have to be already defined, otherwise you get:

 Var example/structureDef is unbound.

I'm a clojure newbie, so I don't know exactly how to avoid this. I know only of two workarounds:

 1. use functions:   (defn structure [] (brackets (sepBy (structureDef) (comma))))
 2. use delay:       (def structure (delay (brackets (sepBy structureDef comma))))

I opted for the "delay", as it allowed me to avoid all those spurious parens, and retain the illusion of a parser DSL, and put the "delay" only where needed. (or everywhere
with a "defblabla" macro).

Unfortunately this required a small patch to Brandmeyer's monad library.

## Installation

lein jar

## License

http://www.apache.org/licenses/LICENSE-2.0.html

About

Parsec monadic parser ported to clojure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Clojure 100.0%