01-FiniteStateMachines

01-FiniteStateMachines - Discussion #1 Finite State...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Discussion #1 Regular Expressions
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Topics Compilers and Interpreters Lexical Analyzers Regular Expressions Finite State Machines & Finite State Transducers Project 1
Background image of page 2
Compilers for Programming Languages Program Compiler Code Lexical Analyzer Program Parser Tokens Code Generator Internal Data Code Keywords String literals Variables Error messages Syntax Analysis Or Interpreter (Executed directly)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Series of 6 Projects: Datalog Interpreter Example Input : Example Output : Schemes: snap(S,N,A,P) csg(C,S,G) cn(C,N) ncg(N,C,G) Facts: snap('12345','C. Brown','12 Apple St.','555-1234'). snap('22222','P. Patty','56 Grape Blvd','555-9999'). snap('33333','Snoopy','12 Apple St.','555-1234'). csg('CS101','12345','A'). csg('CS101','22222','B'). csg('CS101','33333','C'). csg('EE200','12345','B+'). csg('EE200','22222','B'). Rules: cn(c,n) :- snap(S,n,A,P),csg(c,S,G). ncg(n,c,g) :- snap(S,n,A,P),csg(c,S,g). Queries: cn('CS101',Name)? ncg('Snoopy',Course,Grade)? cn('CS101',Name)? Yes(3) Name='C. Brown' Name='P. Patty' Name='Snoopy' ncg('Snoopy',Course,Grade)? Yes(1) Course='CS101', Grade='C'
Background image of page 4
Project 1: Lexical Analyzer Example Input : Example Output : Queries: IsInRoomAtDH('Snoopy',R,'M',H) #SchemesFactsRules . #|comment >= wow|# (QUERIES,"Queries",1) (COLON,":",1) (ID,"IsInRoomAtDH",2) (LEFT_PAREN,"(",2) (STRING,"'Snoopy'",2) (COMMA,",",2) (ID,"R",2) (COMMA,",",2) (STRING,"'M'",2) (COMMA,",",2) (ID,"H",2) (RIGHT_PAREN,")",2) (COMMENT,"#SchemesFactsRules",3) (PERIOD,".",4) (COMMENT,"#|comment >= wow|#",5) (EOF,"",7) Total Tokens = 16
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Point of CS 236 Use mathematics to write better code. in Project 1: some sample code to help get started in later projects: continue this process independently Project 1: Use a Finite State Machine to write a Lexical Analyzer.
Background image of page 6
Regular Expressions Pattern description for strings Standard patterns: – Concatenation: abc matches …abc… but not …abdc… or …ac… – Boolean or: ab|ac matches …ab… and …ac… but not …cba… – Kleene closure: ab* matches …a… and …ab… and …abb… and … Common shorthand patterns Optional: ab?c matches …ac… and …abc… but not …abbc…
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 20

01-FiniteStateMachines - Discussion #1 Finite State...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online