




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An analysis of the abstract syntax tree (ast) of a programming code snippet, focusing on variables, instance variables, and semantic errors. It covers the structure of class variables, array variables, and instance variables, as well as common semantic errors such as type mismatches, structured variable errors, function and method errors, and access violation errors.
Typology: Exams
1 / 201
This page cannot be seen from the preview
Don't miss anything!





























































































David Galles Department of Computer ScienceUniversity of San Francisco
FR-0:
DFA for else, end, identifiersCombine DFA
FR-2:
We’d like a tool:
Describe the tokens in the language Automatically create DFA for tokens Then, automatically create C code that implementsthe DFA We need a method for describing tokens
FR-3:
Σ: Set of all possible symbols
(characters) in the input file
Think of
as the set of symbols on the
keyboard String
w: Sequence of symbols from an alphabet String length
|w
|^ Number of characters in a
string:
|car
|abba
Empty String
ǫ: String of length 0:
|ǫ|
Formal Language
: Set of strings over an
alphabet Formal Language
Programming language – Formal
Language is only a set of strings.
FR-5:
Given two formal
languages
and
, the concatenation of
and
xy|
x^ ∈
, y^
For example:{fire, truck, car} {car, dog} ={firecar, firedog, truckcar, truckdog, carcar, cardog}
FR-6:
Given a formal language
=^
{ǫ} (^1) L =^
=^
=^
=^
n^ L
FR-8:
From highest to Lowest:Kleene Closure *ConcatenationAlternation
ab*c
|e = (a(b*)c)
|^ e
FR-9:
(a|b)*
all strings over {a,b}
binary integers (with leading zeroes)
a(a
|b)*a
all strings over {a,b} thatbegin and end with a
(a|b)*aa(a
|b)*
all strings over {a,b} thatcontain aa
b(abb)*(a
|ǫ)^
all strings over {a,b} thatdo not contain aa
FR-11:
Language if^ {if}
["a"-"z"]["0"-"9","a"-"z"]*
Set of legal identifiers
["0"-"9"]+
Set of integers (with leading zero
(["0"-"9"]+"."["0"-"9"]*)
|^ Set of real numbers
(["0"-"9"]*"."["0"-"9"]+)
FR-12:
FR-14:
FR-15:
num
FR-17:
ambiguous
if there is at least one
string with more than one parse tree The expression grammar we’ve seen so far isambiguous E^ →
num
FR-18:
num F^ →