;;;; mother modular generic compiler project
; (c)2001,2002/GPL Oskar Schirmer <oskar@scara.com>
; see file COPYING for GPL license details

; finite automaton scanner description for ansi c (principle language)
; according to Harbison and Steele, "C A Reference Manual", ISBN 0-13-110933-2

(finite-automaton
  '(
    (initial
      ((#\space #\newline #\tab #\return #\page)
                    #f get  #f initial     #f)
      (#\!         #t  get pos exclamation #f)
      (#\%         #t  get pos percent     #f)
      (#\^         #t  get pos circumflex  #f)
      (#\&         #t  get pos ampersand   #f)
      (#\*         #t  get pos asterisk    #f)
      (#\-         #t  get pos minus       #f)
      (#\+         #t  get pos plus        #f)
      (#\=         #t  get pos equal       #f)
      (#\~         #t  get pos initial     binarynot)
      (#\|         #t  get pos verticalbar #f)
      (#\.         #t  get pos period      #f)
      (#\<         #t  get pos less        #f)
      (#\>         #t  get pos greater     #f)
      (#\/         #t  get pos slash       #f)
      (#\?          #f get pos initial     question)
      (#\(          #f get pos initial     lparen)
      (#\)          #f get pos initial     rparen)
      (#\[          #f get pos initial     lbracket)
      (#\]          #f get pos initial     rbracket)
      (#\{          #f get pos initial     lbrace)
      (#\}          #f get pos initial     rbrace)
      (#\,          #f get pos initial     comma)
      (#\;          #f get pos initial     semicolon)
      (#\:          #f get pos initial     colon)
      (#\L          #f get pos l           #f)
      ((#\A . #\Z) #t  get pos word        #f)
      ((#\a . #\z) #t  get pos word        #f)
      ((#\_ #\$)   #t  get pos word        #f)
      (#\0         #t  get pos null        #f)
      ((#\1 . #\9) #t  get pos digit       #f)
      (#\"          #f get pos string      #f)
      (#\'          #f get pos character   #f)
      (else         #f  #f  #f #f          #f)
    )
    (exclamation
      (#\=         #t  get  #f initial     compare)
      (else         #f  #f  #f initial     logicalnot)
    )
    (percent
      (#\=         #t  get  #f initial     assignment)
      (else         #f  #f  #f initial     modulo)
    )
    (circumflex
      (#\=         #t  get  #f initial     assignment)
      (else         #f  #f  #f initial     binaryxor)
    )
    (ampersand
      (#\=         #t  get  #f initial     assignment)
      (#\&         #t  get  #f initial     logicaland)
      (else         #f  #f  #f initial     ampersand)
    )
    (asterisk
      (#\=         #t  get  #f initial     assignment)
      (else         #f  #f  #f initial     asterisk)
    )
    (minus
      (#\=         #t  get  #f initial     assignment)
      (#\-         #t  get  #f initial     decrement)
      (#\>         #t  get  #f initial     pointer)
      (else         #f  #f  #f initial     add)
    )
    (plus
      (#\=         #t  get  #f initial     assignment)
      (#\+         #t  get  #f initial     increment)
      (else         #f  #f  #f initial     add)
    )
    (equal
      (#\=         #t  get  #f initial     compare)
      (else         #f  #f  #f initial     be)
    )
    (verticalbar
      (#\=         #t  get  #f initial     assignment)
      (#\|         #t  get  #f initial     logicalor)
      (else         #f  #f  #f initial     binaryor)
    )
    (period
      ((#\0 . #\9) #t  get  #f numfract    #f)
      (else         #f  #f  #f initial     period)
    )
    (less
      (#\=         #t  get  #f initial     relational)
      (#\<         #t  get  #f shift       #f)
      (else         #f  #f  #f initial     relational)
    )
    (greater
      (#\=         #t  get  #f initial     relational)
      (#\>         #t  get  #f shift       #f)
      (else         #f  #f  #f initial     relational)
    )
    (shift
      (#\=         #t  get  #f initial     assignment)
      (else         #f  #f  #f initial     shift)
    )
    (slash
      (#\=         #t  get  #f initial     assignment)
      (else         #f  #f  #f initial     divide)
    )
    (word
      ((#\A . #\Z) #t  get  #f word        #f)
      ((#\a . #\z) #t  get  #f word        #f)
      ((#\_ #\$)   #t  get  #f word        #f)
      ((#\0 . #\9) #t  get  #f word        #f)
      (else         #f  #f  #f initial     word)
    )
    (null
      ((#\X #\x)   #t  get  #f integerhex  #f)
      ((#\0 . #\7) #t  get  #f integeroct  #f)
      ((#\8 . #\9) #t  get  #f number      #f)
      (#\.         #t  get  #f numfract    #f)
      ((#\e #\E)   #t  get  #f numexpon    #f)
      ((#\u #\U)   #t  get  #f integeru    #f)
      ((#\l #\L)   #t  get  #f integerl    #f)
      (else         #f  #f  #f initial     integer)
    )
    (digit
      ((#\0 . #\9) #t  get  #f digit       #f)
      (#\.         #t  get  #f numfract    #f)
      ((#\e #\E)   #t  get  #f numexpon    #f)
      ((#\u #\U)   #t  get  #f integeru    #f)
      ((#\l #\L)   #t  get  #f integerl    #f)
      (else         #f  #f  #f initial     integer)
    )
    (integerhex
      ((#\0 . #\9) #t  get  #f integerhex2 #f)
      ((#\A . #\F) #t  get  #f integerhex2 #f)
      ((#\a . #\f) #t  get  #f integerhex2 #f)
      (else        #t   #f  #f #f "error in hexadecimal constant")
    )
    (integerhex2
      ((#\0 . #\9) #t  get  #f integerhex2 #f)
      ((#\A . #\F) #t  get  #f integerhex2 #f)
      ((#\a . #\f) #t  get  #f integerhex2 #f)
      ((#\u #\U)   #t  get  #f integeru    #f)
      ((#\l #\L)   #t  get  #f integerl    #f)
      (else         #f  #f  #f initial     integer)
    )
    (integeroct
      ((#\0 . #\7) #t  get  #f integeroct  #f)
      ((#\8 . #\9) #t  get  #f number      #f)
      (#\.         #t  get  #f numfract    #f)
      ((#\e #\E)   #t  get  #f numexpon    #f)
      ((#\u #\U)   #t  get  #f integeru    #f)
      ((#\l #\L)   #t  get  #f integerl    #f)
      (else         #f  #f  #f initial     integer)
    )
    (integeru
      ((#\l #\L)   #t  get  #f initial     integer)
      (else         #f  #f  #f initial     integer)
    )
    (integerl
      ((#\u #\U)   #t  get  #f initial     integer)
      (else         #f  #f  #f initial     integer)
    )
    (number
      ((#\0 . #\9) #t  get  #f number      #f)
      (#\.         #t  get  #f numfract    #f)
      ((#\e #\E)   #t  get  #f numexpon    #f)
      (else        #t   #f  #f #f "error in floating point constant")
    )
    (numfract
      ((#\0 . #\9) #t  get  #f numfract    #f)
      ((#\e #\E)   #t  get  #f numexpon    #f)
      ((#\f #\F #\l #\L)
                   #t  get  #f initial     number)
      (else         #f  #f  #f initial     number)
    )
    (numexpon
      ((#\0 . #\9) #t  get  #f numexpon3   #f)
      ((#\- #\+)   #t  get  #f numexpon2   #f)
      (else        #t   #f  #f #f "error in floating point constant")
    )
    (numexpon2
      ((#\0 . #\9) #t  get  #f numexpon3   #f)
      (else        #t   #f  #f #f "error in floating point constant")
    )
    (numexpon3
      ((#\0 . #\9) #t  get  #f numexpon3   #f)
      ((#\f #\F #\l #\L)
                   #t  get  #f initial     number)
      (else         #f  #f  #f initial     number)
    )
    (string
      (#\"          #f get  #f stringend   #f)
      (#\\         #t  get  #f stringesc   #f)
      ((#\newline #\return)
                    #f  #f  #f #f "string must not contain newline")
      (else        #t  get  #f string      #f)
    )
    (stringesc
      (else        #t  get  #f string      #f)
    )
    (stringend
      ((#\space #\newline #\tab #\return #\page)
                    #f get  #f stringend   #f)
      (#\"          #f get  #f string      #f)
      (else         #f  #f  #f initial     string)
    )
    (l
      (#\"          #f get  #f lstring     #f)
      (#\'          #f get  #f character   #f)
      (else        #\L  #f  #f word        #f)
    )
    (lstring
      (#\"          #f get  #f lstringend  #f)
      (#\\         #t  get  #f lstringesc  #f)
      ((#\newline #\return)
                    #f  #f  #f #f "string must not contain newline")
      (else        #t  get  #f lstring     #f)
    )
    (lstringesc
      (else        #t  get  #f lstring     #f)
    )
    (lstringend
      ((#\space #\newline #\tab #\return #\page)
                    #f get  #f lstringend  #f)
      (#\L          #f get  #f lstringendl #f)
      (else         #f  #f  #f initial     lstring)
    )
    (lstringendl
      (#\"          #f get  #f lstring     #f)
      (else         #f  #f  #f lstringend3 lstring)
    )
    (lstringend3
      (else        #\L  #f pos word        #f)
    )
    (character
      (#\'          #f get  #f initial     character)
      (#\\         #t  get  #f charesc     #f)
      ((#\newline #\return)
                    #f  #f  #f #f "character must not contain newline")
      (else        #t  get  #f character   #f)
    )
    (charesc
      (else        #t  get  #f character   #f)
    )
  )
)
