CS 330: Lecture 11 – Type Systems
Dear students, Today we begin our focus of programming language concepts, rather than the tools (regex, lexers, and parsers) that we use for interpreting programming languages. In particular, we start off with types. To get us started, here’s a question to discuss with your neighbor. What are types? Why do have them? In the past, […]
CS 330: Lecture 10 – Conditionals and Loops
Dear students, The dream of every machine is to amplify human effort—turning a little force at the input end to a big effect at the output end. Our language is starting to have this quality. With just a few utterances we can draw a picture. But there are still two big things missing from it: […]
CS 330: Lecture 9 – Assignment and Operators
Dear students, We’ve got a little programming language up and running. It’s got commands for drawing rectangles and circles, and it supports integer literals and variables. Today we add to it variable assignments and operators. Next time we’ll add loops and functions. To help us get a feel for what our programs will look like […]
CS 330: Lecture 8 – Parsing
Dear students, We started writing our own lexer last time. Today, we’re going to get a parser that tries to make sense of those tokens. But first, we should talk about what kind of programming language we’re writing. Let’s write a language for drawing things with shapes. Really simple shapes. We’ll need a name for […]
CS 330: Lecture 7 – Lexing, Really
Dear students, Okay, with regexes and the notion of state machines tucked away in our brains, we’re now on a quest to design our own programming language. Usually you’re supposed to start this kind of learning by writing a calculator. I couldn’t bring us to do that. Instead we’re going to design a language for […]
CS 330: Lecture 6 – Lexing
Dear students, Okay, with regexes and the notion of state machines tucked away in our brains, we’re now on a quest to design our own programming language. Usually you’re supposed to start this kind of learning by writing a calculator. I couldn’t bring us to do that. Instead we’re going to design a language for […]
CS 330: Lecture 5 – Lookaround Assertions and Numeric Ranges
Dear students, To start things off, we’re going to play some Regex Bingo. Find a partner and make a 4×4 grid of randomly generated strings. Include uppercase and lowercase letters, numbers, whitespace, and punctuation. Keep the strings short. There’s no free space. I will call out the following regex, one at a time. Cross out […]
CS 330: Lecture 4 – Find and Replace
Dear students, Last week we started examining regex, a language for recognizing languages. We examined their syntax and theoretical background. I want to spend two more days discussing them. Today we look at several applications of them inspired by real-life needs that I’ve encountered: Extract the URLs from all img elements. If you alter this […]
CS 330: Lecture 3 – State Machines and More Regex
Dear students, Before diving into code, let’s be computer scientists for a minute. We’re going to consider a model of computation called a deterministic finite automaton (DFA). A DFA is a special case of a state machine. Here’s a state machine used to model an avatar’s state in a game: Thanks, Bob Nystrom. And one […]
CS 330: Lecture 2 – Regex Capturing and Find-All
Dear students, Last time we started looking a regular expressions. There’s something I didn’t share because I was afraid your minds would explode. It’s this: Regex is a language for recognizing a language. We use regex to create little recognition machines. We feed a string into such a machine, and it either belches approvingly or […]