Programming Language Concepts Format: 1 Exam Review
Programming Language Concepts Format: 1 Exam Review
Format
Programming Language
Concepts Exam Time
• Feb 16th, 7-8pm US Eastern Time (60 minutes)
Canvas-based exam
• You will be shown one question at a time
Gary Tan • Can go forward/backward to next/previous question
Computer Science and Engineering • IMPORTANT: you can submit your exam only once
Penn State University – DO NOT PRESS the “SUBMIT QUIZ” button until you are
done
•1 •2
Format
Next for moving
to the next 60-min exam
question
• Closed book and notes
• Not allowed to communicate with other students
during the exam
• Questions during the exam can be posted to
campuswire
Submit Quiz for – make them viewable only to instructors and TAs
submitting the – phrase the question to make it easily understandable
entire exam (can be Feb 16th class cancelled
done only once)
• Instead, I will move my office hours this week to the
16th class time: 12:20 to 2:20pm
•3 •4
Types of Questions
True/false questions
Multiple-choice questions
Short answer questions
Versions of homework problems
You will be expected to be able to read and
write small programs
1ST EXAM REVIEW
•5 •6
1
Ch1 Introduction Ch2 Grammar
Language = syntax + semantics + philosophy BNF grammar (CFG)
Programming paradigms • Terminals, nonterminals, production rules, start
• Imperative programming, OO, functional symbol
programming, logic programming • Derivation, left-most vs. right-most derivations, parse
tree
Possible kinds of questions
• True/false questions; multiple-choice questions
Ambiguity
• Definition
You do not need to know
• Removing operator ambiguity
• Date when a language was designed
– Adding explicit parenthesis
– Design a new grammar to enforce associativity and
precedence rules
– Ambiguous grammar + informal spec. of associativity and
precedence rules
•7 •8
•9 •10
Ch2 Lexical and Syntactic Analysis Ch2 Lexical and Syntactic Analysis
Regular expressions
• epsilon, a, rs, r|s, r* Possible kinds of questions
• extended regular expressions
– r+, r?, [a-z]
• Write regular expressions for syntax of tokens
FSA • Given a regular expression, develop an FSA/DFA
• states, input alphabet, transition function
• accepting an input • Conversion form extended regular expressions to
• deterministic FSA vs. nondeterministic FSA regular expressions
• Theorem: each RE corresponds to a deterministic FSA
The construction of lexers • Write pseudo code for recursive descent parsers,
• a single FSA for all tokens; nextToken() given a grammar
The construction of parsers: recursive-descent parsing
• Limitation: left recursion
• Left-recursion removal
• Left-recursion removal
Lexer and parser generators
•11 •12
2
Ch3 Names, Scopes and Bindings Ch3 Names, Scopes and Bindings
Syntactic issues for Naming Static scoping vs. dynamic scoping
• lexical rules
Binding: compile time vs. runtime • Algorithm based on stack of dictionaries
Variable Possible kinds of questions
• common bindings; naming convention
• l-values vs. r-values
• Scoping
Scope: decides when a name is visible
• nested scopes
• “holes” in scopes
• scope not the same as lifetime
Constructs that can introduce a scope
• Blocks, functions, for-loops, classes, packages (module),
namespace
•13 •14
•15 •16