Writing Domain Specific Languages with Python
summary
Covers concrete techniques and tradeoffs: implementing DSLs with PLY and PyParsing, using the ast and tokenizer or metaprogramming (metaclasses, context managers, operator overloading) to map text into structures, and when those tricks bite back. Shows a working project — an adventure game script that wins Pi Week — with roughly 1,100 lines of DSL and ~3,000 Python lines. Argues metaclasses are safest, operator-overloading causes surprising precedence bugs, and custom parsers need clear errors and tooling.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 0:15Domain Specific Languages
- 4:22What is a DSL
- 6:02Metaclasses
- 9:54Context managers
- 11:17Operator Overloading
- 21:22Parsers
- 22:01DSLs
- 28:51Do it Line
- 35:35Linewise parses
- 37:12Parser generators
- 40:12PLY
- 47:43Summary
related talks
53mDomain Specifc Languages
53mDeveloping DSLs in a pragmatic way
22mLearning Parseltongue: Wizardry in Python
01h 10mDomain Specific Languages: Molding Ruby
45mReinventing the Parser Generator
46mPython ships a ready-made frontend for your compiler
38mDSLs, Code Generation, and New Domains for Ruby
31mWrite your Own Domain Specific Language with F#
