Scanner


Here is the scanner, implemented in NUT.   lex.txt

the Finite State Machine for this scanner is shown below:

Finite State Machine for Nut scanner


b is a space (space, newline)
the separators are:  space, (, )

start at state 1
if input is space skip them
if input is (  out (
if input is )  out )
if input is "  goto state 3   (accept string)
otherwise   goto state 2   (accept name)

state 2
if input is character aceept them
if input is a seperator  out token and backup one input

state 3
if input is "  (end of string) out string
otherwise collect all characters

Here is the source code for lex.txt    You have to use the new virtual machine to run it. (nvm34.exe in the package nut34.zip)

last update 19 July 2010