Lexical Analysis

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

exl.scm
(define scanner-exl
   '(
      (white-sp (whitespace) skip)
      (comment ("#" (arbno (not #\newline))) skip)
      (identifier (letter (arbno (or letter digit)))
         make-symbol)
      (number (digit (arbno digit)) make-number)
   )
)

*This is the definition of the lexical structure of the Example Language.
 
*It consists of a list of token definitions where each token definition is a list with a token name, a regular expression, and an action:


Token NameRegular ExpressionAction

white-sp\s+skip
comment#.*\nskip
identifier[A-Za-z][A-Za-z0-9]*make-symbol
number\d+make-number


 

*Regular expressions can also be formed by some list structure. arbno means ``arbitrary number'' and represents the Kleene star.
 
*All delimiters and keywords that are used in form of string constants in the grammar do not need to be included here.
 

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2002 Andreas Borchert, converted to HTML on May 02, 2002