Skip to content

Commit

Permalink
use external lib for streams
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Dec 25, 2017
1 parent 364e55d commit 2e6f073
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 94 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
Grammar compilation toolkit for JavaScript.
See [docs](https://aureooms.github.io/js-grammar/index.html).

```js
import * as stream from '@aureooms/js-stream' ;
import { ll1 } from '@aureooms/js-grammar' ;

const G = [ [ [ '0' , '1' ] ] ] ;

const table = ll1.compile(0, G);

const tokens = stream.fromstring('010101');

const tree = ll1.parse(0, G, table, tokens);
```

[![License](https://img.shields.io/github/license/aureooms/js-grammar.svg?style=flat)](https://raw.githubusercontent.com/aureooms/js-grammar/master/LICENSE)
[![NPM version](https://img.shields.io/npm/v/@aureooms/js-grammar.svg?style=flat)](https://www.npmjs.org/package/@aureooms/js-grammar)
[![Build status](https://img.shields.io/travis/aureooms/js-grammar.svg?style=flat)](https://travis-ci.org/aureooms/js-grammar)
Expand Down
44 changes: 0 additions & 44 deletions lib/ll1/StreamFromIterable.js

This file was deleted.

16 changes: 12 additions & 4 deletions lib/ll1/_parse.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions lib/ll1/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/ll1/parse.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"devDependencies": {
"@aureooms/js-compare": "^1.4.5",
"@aureooms/js-stream": "^0.0.1",
"ava": "^0.24.0",
"babel-cli": "^6.26.0",
"babel-polyfill": "^6.26.0",
Expand Down
22 changes: 0 additions & 22 deletions src/ll1/StreamFromIterable.js

This file was deleted.

10 changes: 7 additions & 3 deletions src/ll1/_parse.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import EOF from './EOF' ;

/**
* Table-driven predictive parsing.
*
Expand All @@ -6,13 +8,15 @@
* @param stream
* @returns {Array}
*/
export default function _parse ( grammar , table , rule , stream , nonterminal , production ) {
export default function _parse ( grammar , table , rule , stream , nonterminal , productionid ) {

const children = [];

for (const x of rule) {

const t = stream.read();
const lookahead = stream.read();

const t = lookahead === stream.eof ? EOF : lookahead ;

if (typeof x === 'string') {
if (t === x) { children.push(x); continue; }
Expand All @@ -32,7 +36,7 @@ export default function _parse ( grammar , table , rule , stream , nonterminal ,
return {
nonterminal ,
'production' : {
'id' : production ,
'id' : productionid ,
rule ,
} ,
children
Expand Down
3 changes: 0 additions & 3 deletions src/ll1/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import EOF from './EOF' ;
import EW from './EW' ;
import StreamFromIterable from './StreamFromIterable' ;
import _compile from './_compile' ;
import _first from './_first' ;
import _parse from './_parse' ;
Expand All @@ -14,7 +13,6 @@ import parse from './parse' ;
export default {
EOF ,
EW ,
StreamFromIterable ,
_compile ,
_first ,
_parse ,
Expand All @@ -29,7 +27,6 @@ export default {
export {
EOF ,
EW ,
StreamFromIterable ,
_compile ,
_first ,
_parse ,
Expand Down
Loading

0 comments on commit 2e6f073

Please sign in to comment.