Skip to content

Commit

Permalink
Merge pull request #175 from jneen/topic/code-organization
Browse files Browse the repository at this point in the history
Reorganize tests a lot, and code
  • Loading branch information
Brian Mock authored Jun 19, 2017
2 parents 8e585cc + 3870e59 commit 9c3325b
Show file tree
Hide file tree
Showing 65 changed files with 3,986 additions and 2,246 deletions.
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"extends": ["eslint:recommended"],
"env": {
"commonjs": true
},
"rules": {
"eqeqeq": "error",
"strict": ["error", "global"],
"brace-style": ["warn", "1tbs", {"allowSingleLine": true}],
"comma-style": ["warn", "last"],
"dot-notation": "warn",
Expand All @@ -17,6 +22,8 @@
"no-useless-concat": "warn",
"no-useless-escape": "warn",
"no-with": "error",
"no-floating-decimal": "warn",
"curly": ["warn", "all"],
"object-curly-spacing": ["warn", "never"],
"one-var": ["warn", "never"],
"quote-props": ["warn", "as-needed"],
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ Parsimmon is a small library for writing big parsers made up of lots of little p

Parsimmon supports IE7 and newer browsers, along with [Node.js][]. It can be used as a standard Node module through [npm][] (named `parsimmon`), or directly in the browser through a script tag, where it exports a global variable called `Parsimmon`. To download the latest browser build, use the [unpkg version][]. For more information on how to use unpkg, see the [unpkg homepage][].

<!--
Parsimmon is officially tested against Node.js 4.x and higher. It should also work in [browsers with ES5 support][es5] (IE9* and up).
If you need IE8 support, you may be able to get Parsimmon to work by using [es5-shim][], but this is **not officially supported**. Alternately, you can use an older version of Parsimmon which supports IE8.
\* _IE9 does not support "strict mode", but Parsimmon does not require it._
## Module usage
```
npm install --save parsimmon
```
## Browser usage
To download the latest browser build, use the [unpkg version][]. Parsimmon is exposed as a global variable called `Parsimmon`. For more information on how to use unpkg, see the [unpkg homepage][].
-->

## API Documentation

[Full API documentation in `API.md`.][api]
Expand Down Expand Up @@ -80,7 +100,7 @@ Thanks to [@bd82][] we have a good [benchmark comparing Parsimmon CPU performanc

## Fantasyland

Parsimmon is also compatible with [fantasyland][]. It is a Semigroup, an Applicative Functor, and a Monad.
Parsimmon is also compatible with [fantasyland][]. It implements Semigroup, Apply, Applicative, Functor, Chain, and Monad.

[@bd82]: https://github.com/bd82
[@laughinghan]: https://github.com/laughinghan
Expand All @@ -98,3 +118,5 @@ Parsimmon is also compatible with [fantasyland][]. It is a Semigroup, an Applica
[parsec]: https://hackage.haskell.org/package/parsec
[fantasyland]: https://github.com/fantasyland/fantasy-land
[perf]: https://sap.github.io/chevrotain/performance/
[es5]: https://kangax.github.io/compat-table/es5/
[es5-shim]: https://github.com/es-shims/es5-shim
2 changes: 2 additions & 0 deletions examples/json.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

// Run me with Node to see my output!

let util = require('util');
Expand Down
16 changes: 9 additions & 7 deletions examples/lisp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

// Run me with Node to see my output!

var util = require('util');
var P = require('../');
let util = require('util');
let P = require('../');

///////////////////////////////////////////////////////////////////////

Expand All @@ -13,7 +15,7 @@ function spaced(parser) {
.skip(P.optWhitespace);
}

var Lisp = P.createLanguage({
let Lisp = P.createLanguage({
Expression: function(r) {
return P.alt(
r.Symbol,
Expand Down Expand Up @@ -54,16 +56,16 @@ var Lisp = P.createLanguage({

///////////////////////////////////////////////////////////////////////

var text = `\
let text = `\
(list 1 2 (cons 1 (list)))
(print 5 golden rings)
`;

function prettyPrint(x) {
var opts = {depth: null, colors: 'auto'};
var s = util.inspect(x, opts);
let opts = {depth: null, colors: 'auto'};
let s = util.inspect(x, opts);
console.log(s);
}

var ast = Lisp.File.tryParse(text);
let ast = Lisp.File.tryParse(text);
prettyPrint(ast);
2 changes: 2 additions & 0 deletions examples/math.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

// Run me with Node to see my output!

let util = require('util');
Expand Down
14 changes: 8 additions & 6 deletions examples/python-ish.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

// Run me with Node to see my output!

var util = require('util');
var P = require('..');
let util = require('util');
let P = require('..');

///////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -45,7 +47,7 @@ let Pythonish = P.createLanguage({

///////////////////////////////////////////////////////////////////////

var text = `\
let text = `\
block:
a()
b()
Expand All @@ -62,10 +64,10 @@ block:
`;

function prettyPrint(x) {
var opts = {depth: null, colors: 'auto'};
var s = util.inspect(x, opts);
let opts = {depth: null, colors: 'auto'};
let s = util.inspect(x, opts);
console.log(s);
}

var ast = Pythonish.Block.tryParse(text);
let ast = Pythonish.Block.tryParse(text);
prettyPrint(ast);
Loading

0 comments on commit 9c3325b

Please sign in to comment.