On lowest parentheses can be used to group res as

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: rg) 5 Opera?ons on REs CSE341: Programming CSE341: Programming Languages Languages re L(re ) Notes Lecture 1 Lecture 1 Course Course Mechanics Mechanics rs L(r)L(s) Concatenation: a string from r ML Variable ML Variable Bindings a Bindings followed by string from s r|s L(r) ∪ L(s) Grossman Dan Grossman Dan Combination (union): a string Fall 2011 Fall from either r or s 2011 r* L(r)* Kleene closure: sequence of 0 or more strings from r Precedence: * (highest), concatena?on, | (lowest) Parentheses can be used to group REs as needed Winter 2013 UW CSE 401 (Michael Ringenburg) 6 3 1/11/13 Examples CSE341: Programming CSE341: Programming Languages Languages re + ! != Meaning Lecture 1 Lecture 1 single + character Course Course Mechanics Mechanics single ! character ML Variable Bindings ML Variable Bindings 2 character sequence “!=“ Dan Grossman xyzzy an Grossman 5Dcharacter sequence “xyzzy” Fall 2011 (1|0)* Zero or more binary digits (1|0)(1|0)* Binary constant (possible leading 0s) 0|1(1|0)* Binary constant without extra leading 0s, i.e, 0 or starts with 1 (| has lowest precedence) Fall 2011 Winter 2013 UW CSE 401 (Michael Ringenburg) 7 Abbrevia?ons CSE341: Programming CSE341: Programming Languages Languages The basic opera?ons generate all possible regular expressions, but there are cecture 1 abbrevia?ons Lecture 1 L ommon C Some used for course Mechanics Mechanics Convenience. ourse examples: Abbr. ML Variable Bindings ML Variable Bindings Meaning Notes Dan Grossman r+ D (rr*)an Grossman or Fall 2011 1 more occurrences r? (r |ε) 0 or 1 occurrence [a-z] (a|b|…|z) 1 character in given range Fall 2011 [abxyz] (a|b|x|y|z) Winter 2013 1 of the given characters UW CSE 401 (Michael Ringenburg) 8 4 1/11/13 Exercise: What do these represent? CSE341: Programming CSE341: Programming Languages Languages re [abc]+ M Lectureeaning ecture 1 1L Course Course Mechanics Mechanics ML Variable Bindings ML Variable Bindings [abc]* Dan Grossman Fall 2011 [0-9]+ Dan Grossman Fall 2011 [1-9][0-9]* [a-zA-Z][a-zA-Z0-9_]* Winter 2013 UW CSE 401 (Michael Ringenburg) 9 Exercise: What do these represent? CSE341: Programming CSE341: Programming Languages Languages re [abc]+ M Lectureeaning ecture 1 1L Course Mechanics Course Mechanics of one or more a’s, b’s Sequence ML Variable Bindings ML VariableaBindings nd c’s [abc]* [0-9]+ [1-9][0-9]* Zero or an Grossman and c’s D more a’s, b’s, Dan Grossman Fall 2011 Fall 2011 Non-negative integer (possibly with leading 0s) Positive integer (no leading 0s) [a-zA-Z][a-zA-Z0-9_]* One or more letters or digits, must start with a letter. Winter 2013 UW CSE 401 (Michael Ringenburg) 14 5 1/11/13 Abbrevia?ons CSE341: Programming CSE341: Programming Languages Languages •  Many systems allow abbrevia?ons to make Lecture 1 Lecture 1 wri?ng and reading defini?ons or Course Course Mechanics Mechanics specifica?ons easier L Variable Bindings M ML Variable Bindings name...
View Full Document

Ask a homework question - tutors are online