@masala/parser
Version:
Masala Parser
52 lines (29 loc) • 1.16 kB
Markdown
Parser Extensions
=====
These functions allow users to quickly find letters or numbers in
a standard text
* Forces a value
* Does not consume a character
* The point is that the parserFunction is not called immediately
- Use `F.lazy( this.text )` and not `F.lazy( this.text() )`
* The parserFunction will be called when needed
* One important use is [when dealing with **recursion**](./recursion.html)
expression() {
return F.try(
number()
.thenLeft(plus())
.then(F.lazy( expression ) ) // <-- function is not called
.map(values => values[0]+values[1])
)
.or(this.number());
}
Important : Masala is a streaming parser.
[](https://github.com/d-plaindoux/masala-parser/issues/13) The good news is that any left recursive grammar can be rewritten to a form that masala-parser can handle.