Compilers and interpreters need to understand code's structure to run it, just as we need to understand code's structure to read it. This screencast introduces context-free languages, which are used to define the syntaxes of Python, Lua, Lisp, and many other programming languages. We begin with a simple synthetic example showing why context-free languages are more powerful than regular languages. Then, we examine the actual grammar definitions of the Python and Lua programming languages. We analyze code snippets in each language, using the languages' grammar definitions to see the structure of the code in the same way that a compiler or interpreter sees it.
Execute Program
Looking for something more interactive? Try Execute Program, an interactive learning platform from Destroy All Software LLC! It has courses on TypeScript, SQL, regular expressions, JavaScript concurrency, and more. All Destroy All Software subscriptions include full access to Execute Program, or you can subscribe to Execute Program directly.