3.9 Chapter Summary
The source code of a program is simply a string of characters. After comments are purged from the string, scanning (or lexical analysis) partitions the string into the most atomic lexical units based on some delimiter (usually whitespace) and produces a list of these lexical units. The scanner, which models the regular grammar that defines the tokens of the programming language, then determines the validity of these lexical units. If all of the lexical units are lexemes (i.e., valid), the scanner returns a list of tokens—which is input to a parser. The parser, which models the context-free grammar that defines the structure or syntax of the language, determines whether the program is syntactically valid. Parsing (or syntactic ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access