- Didier Plaindoux
- Nicolas Zozol
- Direct Style Monadic Parser Combinators For The Real World
- Haskell Parsec
- Existing in JS: Jison, Bennu (Kephri)
- Alternative for Lex & yacc
- Extract data from a big text, replace complex regexp
- Validate complete structure with variations
- Note taking with very customized markdown
Keywords: variations and maintainability
- Works in the browser
- Zero dependence
- 400 unit & integration tests
- 100% coverage
- API now stable
- Typescript d.ts (not tested enough)
- Floor Notation
- Tikka Masala
- Operation
// N: Number Bundle, C: Chars Bundle
import {stream, N,C} from 'parser-combinator';
const document = '|4.6|';
const floorCombinator= C.char('|')
.thenRight( N.numberLiteral ) // we had [ '|' , 4.6], we keep 4.6
.thenLeft( C.char('|') ) // we had [ 4.6 , '|' ], we keep 4.6
.map(x => Math.floor(x)); // we transform selected value in meaningful value
// Parsec needs a stream of characters
const parsing = floorCombinator.parse(stream.ofString(document));
console.log( parsing.value === 4 );
in functional programming, a parser combinator is a higher-order function that accepts several parsers as input and returns a new parser as its output.
!image : curry-paste.jpg
!image : parsec.png
- Streams
- Class
Parser
- CharBundle, NumberBundle, FlowBundle
- Genlex: ParserStream
... Live demo
The flow bundle will mix ingredients together.
F.try(parser).or(otherParser)
F.not(parser)
: Accept anything elseF.eos
: Accepted if the Parser has reached the End Of Stream
Others:
F.lazy
: Makes a lazy evaluation.- May be used for Left recursionue
letter
: accept an ascii letterletters
: accepts many letters and returns a stringchar(x)
: accept if next input isx
lowerCase
: accept any next lower case inputs- ...
numberLiteral
: accept any float number, such as -2.3E+24digit
: accept any single digit, and return a single chardigits
: accept many digits, and return a string.integer
: accept any positive or negative integer
.. improving parsing
- Json Parser
- Bricks for custom markdown
- 2 paying clients
- Extractor
- Markdown (quick notes)
- Markdown for those who write a lot
- Business specific plugins and mini-application
!bang
: specific command with autocompletion!!bangbang
: newbie popup, access to apps (table, ...)
!quizz: La renaissance
!q: Quelle année pour Marignan ?
** 1515
* 1525
* 1625
!include: @jeanne/renaissance
... 95% pure markdown
!image class=right: gutenberg.jpg
!image size=small right=right: @nicolas/renaissance.jpg
!image small right: @nicolas/renaissance.jpg
!! => 'bang-bang' ; ouvre une boite de dialogue applicative
tableaux, addons, ...
- Mini-app
- Json pur < Lotech < Interface graphique
!task: ranger le bureau
!team name=Bricolo: Réparer des choses faciles
!captain: Nicolas
* Magali
* Your name here
!team name=Menuiserie: Fermer la cage d'escalier
!captain: Pascal
* Your name here
- Hard to debug, especially Genlex
- Sometimes locked (
optrep().rep()
)