# Author: David Foltz # # Notice: Orginal Code Idea for program taken from Python v3.2.2 Documentation def Fibonacci(): """Print a Fibonacci series with an input.""" n = input('How now would you like Fibonacci to go: ') x = int(n) # Converts the String into an Int to be compared. a, b = 0, 1 while a < x: print(a, end=' ') a, b = b, a+b Input file: test program
def keyword: def Fibonacci id ( ) : """Print a Fibonacci series with an input.""“ string literal (double) n id = Input keyword: Input ( 'How now would you like Fibonacci to go: ‘ string literal (single?) ) x id = Int ( N ) a, b = 0, 1
A..Za..z_ A..Za..z_0_9 def int putin More keywords… 0-9 ‘ Anything but ‘ ‘
( ) = +, ++ \t \n ‘ whitespace A tokenizer is just a combination of all DFAs for each type of token that you want to recognize.
A..Za..z_ A..Za..z_0_9 def int 0-9 ‘ Anything but ‘ ‘ ( )
A..Za..z_ A..Za..z_0_9 def int putin More keywords… 0-9 ‘ Anything but ‘ ‘
Keyword table def input int print while A..Za..z_ A..Za..z_0_9 def Keyword: def
Keyword table def input int print while A..Za..z_ A..Za..z_0_9 Fibonacci Not a keyword, just an ID