regular-stream
streaming regular parser
npm install regular-stream
Want to see pretty graphs? Log in now!
2 | downloads in the last week |
8 | downloads in the last month |
Last Published By | |
---|---|
Version | 1.0.0 last updated a year ago |
License | MIT |
Repository | git://github.com/dominictarr/regular-stream.git (git) |
Homepage | https://github.com/dominictarr/regular-stream |
Dependencies | pull-markable |
regular-stream
streaming acceptor for regular languages
[http://en.wikipedia.org/wiki/Regular_language]
WORK IN PROGRESS
var r = require('regular-stream')
, and = r.and, start = r.star, plus = r.plus
, or = r.or, r.maybe = r.maybe, empty = r.empty
and('A', 'B', star('C')) //ABCCCCCCCC
and('A', star('A')) //A | AAAAAA
plus('A') //same as ^
star(or(A, B)) //ABBABABABBABABABBBABAA
and(A, or(B, empty()), C) //AB?C
and(A, maybe(B), C) //ABC | AC
Graphs
Each expression can also be drawn as state transition graphs. Would be cool to generate this automatically.
and / cat
events must occur in order
and (A, B, C)
* --> A --> B --> C
or / union
or (A, B)
x ---> A ---> y
\ /^
\ /
`-> B -`
star
star (A)
&
k ---> A ---> y
\ /^
`---------`
plus
plus (A)
&
x ---> A --->y
maybe
maybe (A)
x ---> A --->y
\ /^
`--------`
And then we can draw a big graph, and show a program's execution path on it!
but maybe using canvas instead of ansi.
License
MIT