3. DSL (embedded)
result.should be 2
In order to write a language
As a Ruby programmer
I want to have an easy and powerful tool
5. Write a lang?
In fact, you do it all the time.
Open files, parse stuff, turn it into strings,
numbers, arrays and link it to code.
Like when you wrote your first csv parser.
(yeah, i know you did it...)
You just didn’t had the right tool.
// Wich alert will be executed?
if(false) if(false) alert(“Don’t say ‘the
second if alert’.”)else alert(“Say ‘the else
alert’. Say it!!!”)
Generally, languages prefer to associate
else to the nearest if. But this has to be
made in a “meta” rule.
Nathan Sobo (Pivotal Labs),
Clifford Heath, Nick Kallen & more.
Parsing Expression Grammars
Brian Ford paper 2004:
Priorities, Not Ambiguities
/ (slash operator)
(a / a b) is different of (a b / a)
Syntactic Predicates (& and !)
Regular Expression Like
No left recursion.
Idea: Recognizes a language
- linear time parsing using memoization
- one and only one valid parse tree
- no dangling else cases
- much easier to learn and use
- still new
- memory eater
- not suitable for natural language processing