Bristol's free PHP meetup. Talks, pizza & pub, every second Wednesday.

← All talks

Given at PHPSW · January 2025

Writing an Expression Language from Scratch in 45 minutes

Expression languages allows you to evaluate strings such as 5 + 5 * someVar to a value. They have a multitude of usages - from rule engines to web frameworks. The patterns you learn can further be used to create SQL parsers, code formatters, code generators and other eclectic entities for work and pleasure!

This talk will clearly demonstrate how to write a simple lexer, parser and tree-walking interpreter. We'll transform bytes to tokens, tokens to nodes and evaluate nodes to values!