Number digits digits ee

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ::= re Dan Grossman Dan Grossman –  Restric?on: abbrevia?ons may not be circular Fall 2011 Fall 2011 (recursive) either directly or indirectly (else would be not be a regular language) •  digit ::= [0- 9] is okay •  number ::= digit number is not Winter 2013 UW CSE 401 (Michael Ringenburg) 15 Example CSE341: Programming CSE341: Programming Languages Languages •  Possible syntax for numeric constants Lecture 1 Lecture 1 Dan Grossman Fall 2011 Fall 2011 digit ::= [0- 9] Course Mechanics Course Mechanics digits ::= digit+ ML Variable Bindings ML Variable Bindings )? number ::= digits ( . digits ( [eE] (+ | - )? digits ) ? Dan Grossman •  No?ce that this allows (unnecessary) leading 0s, e.g., 00045.6. (0, or 0.14 would be necessary 0s.) •  How would you prevent that? Winter 2013 UW CSE 401 (Michael Ringenburg) 16 6 1/11/13 Example CSE341: Programming CSE341: Programming Languages Languages •  Possible syntax for numeric constants Lecture 1 Lecture 1 digit ::= [0- 9] Course Mechanics Course Mechanics nonzero_digit ::= [1- 9] ML Variable Bindings ML Variable Bindings digits ::= digit+ number ::= (0 | nonzero_digit digits?) Dan Grossman Dan Grossman ( . digits )? Fall 2011 Fall 2011 ( [eE] (+ | - )? digits ) ? Winter 2013 UW CSE 401 (Michael Ringenburg) 17 Recognizing REs CSE341: Programming CSE341: Programming Languages Languages •  Finite automata can be used to recognize Lecture 1 r ecture 1 languages generated by Legular expressions Course Course Mechanics Mechanics •  Can build bVariableor L utoma?cally M a Variable Bindings ML y hand Bindings –  Reasonably straighoorward, and can be done Dan Grossman Dan systema?cally Grossman Fall 2011 Fall 2011 –  Tools like Lex, Flex (for compilers wripen in C++), and JFlex (for compilers wripen in Java) do this automa?cally, given a set of REs. Winter 2013 UW CSE 401 (Michael Ringenburg) 18 7 1/11/13 Finite State Automaton CS theory Programming CSE341: Programming Languages Languages •  Review from your CSE341: class … •  A finite set of states Lecture 1 Lecture 1 –  One marked as ini?al state Course Mechanics –  One or more marked as final Course Mechanics states ML Variable Bindings –  States some?mes labeled or numbered ML Variable Bindings •  A set of transi?ons from state to state Dan Grossman –  Each labeled with symbol from Σ (the alphabet), or ε Dan Grossman F in he input stream....
View Full Document

Ask a homework question - tutors are online