Let P and Q be sets of strings. Then string
s ∈ (P Q) if and only if s can be broken into two pieces: s = s1s2 such that s1 ∈ P and s2 ∈ Q.
Delim = ( '(' | ')' | := | ; | , | '+' | - | '*' | / | = | $$$ )
Let P be a set of strings. String s ∈ P* if and only if s can be broken into zero or more pieces:
s = s1 s2 s3 ... snsuch that each si ∈ P.
For example, D = ( 0|1|2...|9) L = (A|...|Z )
Allowing us to define the Ada Comment:
Comment = -- Not(Eol)*Eoland the Fixed decimal literal
Lit = D+.D+and identifiers composed of letters, digits, underscore, must begin with a letter, ends with letter or digital with no consecutive underscores
ID = L (L|D)* (_(L|D)+)*Comments delimited by ##, which allow a single # within the comment body
Comment2 = ##((#|lambda)Not(#))*##
Use the Document Projector in Smart Classroom to work with Diagrams
from this section of our text.
letter [a-zA-Z_] digit [0-9] letter_or_digit [a-zA-Z_0-9] white_space [ \t\n] blank [ \t] other .
(E|e)(N|n)(D|d)
Expr? matches Expr zero times or once. It is equivalent to(expr) | λand obviates the need for an explict λ symbol.
digit [0-9]so that {digit}+ expands to [0-9]+ which may help with readability, once you become comfortable with this notation.
Fundament Characters %% Regular expressions and the command to execute when recognized return token(): %% any additional C-code, as appropriate
With this background, you should be able to examine our specification of tokens for the beginning language recognized by your compiler project:
Reserved words, may look like identifiers, so care is taken in the definition of the language to avoid imposing restrictions on the language user.
You will want to become adept at moving between Regular Expressions and drawing the corresponding finite automata that recognizes them. As well as vice-versa - given a FA, write the regular expression.
Our focus will be on DETERMINISTIC Finite Automata.
You will be expected to draw the diagrams of the Finite Automata that correspond to regular expressions, and vice versa. For example, several problems in our text address this and midterm exam questions will be modeled on this.
en.wikipedia.org/wiki/Regular_expression
Deterministic Finite State Machine
en.wikipedia.org/wiki/Finite_state_automaton
http://www.faqs.org/docs/htmltut/characterentities_famsupp_69.html HTML 4
representation of special characters, such as "lambda".