From 18326425fd1b16c58ea44edf9521a89b60196268 Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Thu, 3 May 2012 17:06:16 -0700 Subject: [PATCH] Miscellanea --- Cakefile | 14 ++++++++++ LICENSE | 19 +++++++++++++ README.md | 69 ++++++++++++++++++++++++++++++++++++++++++++++ src/reparse.coffee | 2 +- 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 Cakefile create mode 100644 LICENSE create mode 100644 README.md diff --git a/Cakefile b/Cakefile new file mode 100644 index 0000000..890df05 --- /dev/null +++ b/Cakefile @@ -0,0 +1,14 @@ +{exec} = require 'child_process' + +task 'lib', 'compile to javascript', -> + exec ['mkdir -p lib', + 'coffee -o lib -c src/reparse.coffee'].join(' && '), (err) -> + throw err if err + +task 'doc', 'build the ReParse documentation', -> + exec 'node_modules/.bin/docco src/reparse.coffee', (err) -> + throw err if err + +task 'clean', 'Delete the compiled code and generated documentation', -> + exec 'rm -fr lib docs', (err) -> + throw err if err diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8fce0a0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012 Elf M. Sternberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e1c794d --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# ReParse - Coffeescript Edition + +## Purpose + +This is a hand-written re-implementation of Ben Weaver's ReParse +(https://github.com/weaver/ReParse). It is a (mostly) faithful +reimplementation, although a few things were re-arranged to be more in +line with Haskell's parsec library, with a side-line look at JSParsec. +This version uses the Coffeescript class management toolkit, so it +*looks* much more like a classic duck-typed OO implementation, the +kind of thing you're familiar with from Ruby or Python. Take a peek +at the examples and you'll see what I mean-- I think they're 20% +cooler that Ben's, just 'cuz of how they look. + +I made the parser re-usable with a new input; it's slightly faster +than the javascript implementation. + +I wrote this because I needed a parser for a coffeescript project, and +while I liked Ben's code, I needed to disassemble it, figure out what +it did, and re-write it in my own language and with my own brain. +It's been nearly 14 years since I last had to write a parser; I +usually work at a much higher level, but my current project required +one, and this was the exercise I chose. + +## Requirements + +Coffeescript to build/run. + +Docco to produce documentation. + +Both of these are specified in the package.json file. + +## Acknowledgements + +Ben Weaver (of course) + +Balazs Endresz (for JSParsec, which at least explained some functions +of Parsec to me better than the Parsec source code) + +John MacFarlane (for Pandoc, which led me down this rabbit hole in the +first place) + +## LICENSE AND COPYRIGHT NOTICE: NO WARRANTY GRANTED OR IMPLIED + +Copyright (c) 2012 Elf M. Sternberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + - Elf M. Sternberg + + + + diff --git a/src/reparse.coffee b/src/reparse.coffee index 9bf59cc..4a74dd8 100644 --- a/src/reparse.coffee +++ b/src/reparse.coffee @@ -226,7 +226,7 @@ exports.ReParse = class ReParse endBy: (method, end, min = 0) => val = @many method, min - @option end + @produce end val # Parses 1 or more productions of method, which must be terminated