|
3.1 MetalanguageThe metalanguage for a scanner generator is a set of regular expressions describing the tokens in the language. A program stub or finite state table is generated from the regular expressions. At compile-time, the driver reads input characters from the source program, consults the table based upon the input and the current state, and moves to a new state based upon the entry, perhaps prforming an action such as entering an identifier into a name table. We will illustrate these concepts with a sample language consisting of assignment statements whose right-hand sides are arithmetic expressions. These regular expressions are input to the generator to produce state tables either in table form or as a case statement program stub. In Section 3.2 and in Section 3.3, we discuss the two programs, the driver program and the lexical analyzer generator. Send questions and comments to: Karen Lemone |