Giter VIP home page Giter VIP logo

smug's Introduction

SMUG : Super Monadic Über Go-into

SMUG is a library for parsing text, based on monadic parser combinators. Using a simple technique from the functional programming camp, SMUG makes it simple to create quick extensible recursive descent parsers without funky syntax or impenetrable macrology.

Features

  • parsers are first class values written in basic lisp
  • non-deterministic infinite look-ahead
  • easy to learn, easy to use
  • extensible input protocol : parse strings, streams, lists etc
  • in-depth tutorial : no previous experience required.

Download and Install

cd ~/quicklisp/local-projects
git clone https://github.com/drewc/smug.git
(ql:quickload :smug)

Documentation

See doc/smug.org

Support

https://github.com/drewc/smug/issues or mailto:[email protected]

Licence

The MIT License (MIT)

Copyright (c) 2010-2015 Drew Crampsie

see LICENSE

smug's People

Contributors

drewc avatar fiddlerwoaroof avatar jasom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smug's Issues

Evaluation aborted as calling CLOSURE by providing the input of the predicate in .satisfies.

As going through the section ".SATISFIES : the parser predicate" in the tutorial. Then I have the input of the predicate digit-char-p to make the CLOSURE for .satisfies , see the below.

(setq ss (.bind (.item) 
        (lambda (x) 
          (if (apply #'digit-char-p x)
              (.identity x)
              (.fail)))))

Then call (funcall ss "1 and") ,then it evaluation aborted. See the following backtrace

  0: ((LAMBDA (X)) #\1)
  1: ((LAMBDA (INPUT) :IN .BIND) "1 and")
  2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (FUNCALL SS "1 and") #<NULL-LEXENV>)
  3: (EVAL (FUNCALL SS "1 and"))

License?

I looked around but couldn't find a license for this. What (if any) license is it released under?

at-least is broken when :limit is not pased

When :limit is not passed, it still tries to decrement it, causing an error for (1- nil).
Changling line 199 of smug.lisp to this fixes the problem.
(xs (at-least (1- n) parser :limit (and limit (1- limit)))))

input-rest broken when input is "base-string"

This is an issue on ECL which makes strings base-string unless they contain non base-chars; for example (type-of "") => (SIMPLE-ARRAY BASE-CHAR (0))

The fix is fairly easy; you can either specialize input-rest for base-string, or add this to the beginning of input-rest for cl:string:

(when (not (equal (array-element-type input)
              (upgraded-array-element-type 'character)))
      (setf input
        (make-array (length input) :element-type 'character
            :initial-contents input)))

Finding position of parse fails

Hi!

This is a cool project, I've enjoyed playing with it.

I was trying it out as an alternative for a parser I'm putting together for a project of my own. I need the ability to identify the line number and context of a parser failure. I don't see any way to do that off hand with Smug. Is that possible?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.