# Author: David Foltz # # Notice: Orginal Code Idea for program taken from Python v3.2.2 Documentation def Fibonacci(): """Print a Fibonacci series with.

Slides:



Advertisements
Similar presentations
For(int i = 1; i
Advertisements

This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;
This Week More Types boolean string Modules print statement Writing programs if statement Type boolean.
1 Week 2 Questions / Concerns Schedule this week: Homework1 & Lab1a due at midnight on Friday. Sherry will be in Klamath Falls on Friday Lexical Analyzer.
§3 Dynamic Programming Use a table instead of recursion 1. Fibonacci Numbers: F(N) = F(N – 1) + F(N – 2) int Fib( int N ) { if ( N
Μαθαίνοντας Python [Κ4] ‘Guess the Number’
CS 445 Lecture #2 Lexical Analysis. Regular Expressions ε is a r.e. Any char in the alphabet is a r.e. If r and s are r.e.’s then r | s is a r.e. If r.
Introduction to Python
COS 320 Compilers David Walker. Outline Last Week –Introduction to ML Today: –Lexical Analysis –Reading: Chapter 2 of Appel.
Mini-Pascal Compiling Mini-Pascal (MPC) language
Fall 2006Costas Busch - RPI1 Lex. Fall 2006Costas Busch - RPI2 Lex: a lexical analyzer A Lex program recognizes strings For each kind of string found.
1 Scanning Tokens. 2 Tokens When a Scanner reads input, it separates it into “tokens”  … at least when using methods like nextInt()  nextInt() takes.
Applications of Regular Expressions BY— NIKHIL KUMAR KATTE 1.
Python Programming Fundamentals
CMSC 331, Some material © 1998 by Addison Wesley Longman, Inc. 1 Chapter 4 Chapter 4 Lexical analysis.
Munster Programming Training
Python: Modularisation Damian Gordon. Modularisation Remember the prime checker program:
Compiler Phases: Source program Lexical analyzer Syntax analyzer Semantic analyzer Machine-independent code improvement Target code generation Machine-specific.
Lexical Analysis Mooly Sagiv Schrierber Wed 10:00-12:00 html:// Textbook:Modern.
Structured programming 3 Day 33 LING Computational Linguistics Harry Howard Tulane University.
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 12: A few other things.
Lexical Analyzer (Checker)
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Variables and Expressions CMSC 201 Chang (rev )
C++ Character Set It is set of Characters/digits/symbol which is valid in C++. Example – A-Z, (white space) C++ Character Set It is set of.
CS412/413 Introduction to Compilers Radu Rugina Lecture 4: Lexical Analyzers 28 Jan 02.
Flex: A fast Lexical Analyzer Generator CSE470: Spring 2000 Updated by Prasad.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
CS 536 Fall Scanner Construction  Given a single string, automata and regular expressions retuned a Boolean answer: a given string is/is not in.
Python The tutorial
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
Variables, Expressions and Statements
Overview of Previous Lesson(s) Over View  Symbol tables are data structures that are used by compilers to hold information about source-program constructs.
Variables and Expressions CMSC 201. Today we start Python! Two ways to use python: You can write a program, as a series of instructions in a file, and.
Lexical Analysis – Part II EECS 483 – Lecture 3 University of Michigan Wednesday, September 13, 2006.
Exercise Solution for Exercise (a) {1,2} {3,4} a b {6} a {5,6,1} {6,2} {4} {3} {5,6} { } b a b a a b b a a b a,b b b a.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Costas Busch - LSU1 Lex. Costas Busch - LSU2 Lex: a lexical analyzer A Lex program recognizes strings For each kind of string found the lex program takes.
Function and Function call Functions name programs Functions can be defined: def myFunction( ): function body (indented) Functions can be called: myFunction(
An Introduction to Regular Expressions Specifying a Pattern that a String must meet.
LECTURE 11 Semantic Analysis and Yacc. REVIEW OF LAST LECTURE In the last lecture, we introduced the basic idea behind semantic analysis. Instead of merely.
LECTURE 6 Scanning Part 2. FROM DFA TO SCANNER In the previous lectures, we discussed how one might specify valid tokens in a language using regular expressions.
Getting Started With Python Brendan Routledge
Find LCM Least Common Multiple of 3 and 5: List the Multiples of each number, The multiples of 3 are 3, 6, 9, 12, 15, 18,... etc The multiples of 5 are.
Lecture 4.1: More on Scanner, Methods, and Codingbat Michael Hsu CSULA.
DEFINITION Java IDE created by Xinox Software JCreator is a powerful interactive development environment (IDE) for Java technologies. A Java compiler.
Whatcha doin'? Aims: To start using Python. To understand loops.
Introduction to Python
String Concepts In general, a string is a series of characters treated as a unit. Computer science has long recognized the importance of strings, but it.
Compilers Welcome to a journey to CS419 Lecture5: Lexical Analysis:
Introduction to Programming
Lexical analysis Jakub Yaghob
CS 536 / Fall 2017 Introduction to programming languages and compilers
Register Use Policy Conventions
CSC141 Computer Science I Zhen Jiang Dept. of Computer Science
SQL – Python and Databases (Continued)
Strings.
Recognition of Tokens.
مبانی برنامه‌سازی Fundamentals of Programming
Topics discussed in this section:
Module 2 - Part 1 Variables, Assignment, and Data Types
Python Basics with Jupyter Notebook
Appending or adding to a file using python
Python Inputs Mr. Husch.
More Basics of Python Common types of data we will work with
def-ining a function A function as an execution control structure
Python fundamental.
Getting Started in Python
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

# 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