Created
July 6, 2015 07:01
-
-
Save StoneCypher/c1a3b6291dbadd269f0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // http://pegjs.org/online | |
| start = basic* | |
| basic = (w:sentence . ws q:quote ws e:expl ws? nl) { return { word: w, quote: q, expl: e }; } | |
| quote = qt (s:sentence) qt { return s; } | |
| expl = phrase | |
| phrase = sentence* | |
| sentence = (s:(w:word sep? ws?)*) . { console.log(JSON.stringify(s)); return s.map(function(X) { return X[0] + X[1]; }).join(' ') + '.'; } | |
| words = (w:word+ ws) { return w.join(''); } | |
| word = (w:char+) { return w.join(''); } | |
| char = [a-z]i | |
| sep = (s:[,:]*) { return s.join(''); } | |
| qt = "\"" | |
| ws = (w:[ \t]*) { return w.join(''); } | |
| nl = [\r\n]* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment