executes instructions one by one (analyzing each time)
Slower than compiler
ex: Scheme, Python, Perl, Bash
Back
Types
Front
A type is a collection of values and a collection of operations on those values.
ex: simple types/numbers
structured types/strings,lists
The type can help determine legal operations, type errors
Back
EBNF
Front
{} for a series of zero or more
() for a list, must pick one
[] for an optional list; pick one or none
Back
All programming Languages have four properties
Front
Syntax
Names
Types
Semantics
Back
BNF is less powerful than regular expressions
Front
False
Back
Early/Late binding
Front
Early binding takes place at or before compile time
Late binding takes place at run time
Back
Parse tree
Front
a hierarchical representation of a derivation
Back
Concrete syntax
Front
rules for writing (expressions, statements and programs) / what statements look like
Back
Semantics
Front
The meaning of a program is called its semantics:
What does each statement mean? When a program is running, what happens to the values of the variables?
What underlying model governs run time behavior?
Back
Funcitonal
Front
Domain/Range, functional decomposition, recursion.
Mains means of computations is applying functions to parameters
ex: Lisp, Scheme, ML, F#, Haskell
Back
Production rule (P)
Front
rule that has a left-handed side, which is a nonterminal, and a right-handed side, which is a string of terminals
and or nonterminals
Back
Associativity (Exam)
Front
of and operator, left- or right, is determined by the use of left or right recursion, respectively.
Back
Formal language theory is used for semantical structure of programming languages (Chomsky hierarchy)
Front
True
Back
Precedence (Exam)
Front
is determined by the length of the shortest derivation from the start symbol to the operator.
Back
Associativity
Front
of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses
Back
Binding
Front
A language element/object is bound to a property at the time that property is defined for it.
A binding is the association between an object and a property of that object
Ex: a variable and its type -typical bound to type during declaration
a variable and its value - bound when variable define/initialized
Back
Imperative
Front
Central features are variables, assignment statements, and iterations.
state-value, procedural abstraction
ex: C, Perl, Cobol, Fortran, Ada
Back
Ambiguous Grammar
Front
if one of its strings has two or more different parse trees (or two or more different leftmost/rightmost derivations)
Back
token
Front
a category of lexemes
Back
Regular expressions are used because they are more expressive than other common formalisms
Front
False
Back
Associativity of relational operators?
Front
in c (a<b<c) means: if a<b and b<c
Back
Regular grammar
Front
Used in the scanner, produce tokens
Used to write formal description of the token patterns (when creating the lexical analyzer - the scanner)
Back
Precedence
Front
The order of operations (or operator precedence) is a collection of rules that define which procedures/operations to perform first in order to evaluate a given expression.
Back
There are programs that can generate the source code for the syntactical analyzer from a description of the grammar
Front
True
Back
Context-free grammar
Front
Verify grammar, parser
Back
Compiler
Front
translates once, produces machine code (faster)
Back
Hybrid Interpreter
Front
Java: process:
Source code
Lexical Analyzer
>>tokens
Syntax Analyzer
>>parse trees
IC generator
Interpreter
results
Back
Characteristics of successful language
Front
Simplicity and readability
Reliability, abstraction, orthongonality, Efficient Implementation
Back
Translation to native code can be done after execution begins
Front
True
Back
Nonterminals (N)
Front
Abstractions used to represent classes of syntactic structures
Back
Interpreter process
Front
Source program
Interpreter
result
Back
Abstract syntax
Front
internal representation (deep structure); carries only essential information, without concern for syntactic idiosyncrasies like punctuation or parentheses
There are programs that can generate the source code for the lexical analyzer from a description of the tokens
Front
True
Back
Object-Oriented
Front
data abstraction (Encapsulation, inheritance, polymorphism) Collection of objects that interact by passing messages that transform the state.
ex: java, C++, C#, Python, smalltalk
Back
Lexical Syntax
Front
Symbols of the language (all the basics)/the vocabulary of the language
names, values, operators etc.
Back
Logic
Front
Rule-based(rules are specified in no particular order) Facts, constraints, and queries, all solution, nondeterministic
ex: prolog
Back
lexeme
Front
the lowest level syntactic unit of a language
Back
A program run via an interpreter runs faster than a compiled program
Front
False
Back
Simplicity and orthogonality
Front
Few constructs, a small number of primitives, a small set of rules for combining them
Back
Terminals (T)
Front
Lexemes (tokens)
Back
Names/Entities
Front
Various entities in a program have names:
variables, types, functions, parameters, classes, objects...
Entities have four basic bindings; scope, visibility, type, lifetime
Back
Programming Paradigms
Front
Imperative
Object Oriented
Functional
Logic
Back
Syntax
Front
The syntax of a programming language is a precise description of all its grammatically correct programs
Back
Dangling else (How is it solved?)
Front
external rule: match w/ closest if (C, Algol60,C++)
add delimiter to language such as EndIf (Ada, Visual Basic, Bash, Csh)
enforce in grammar (complex BNF) rule- no shortIf (java)
Back
Compiler diagram
Front
Source Code
Lexical Analyzer
>>tokens
(Symbols table)
Syntax Analyzer
>>Parse tree
Type Checker
>>IC
Code optimizer
>>IC
Code generator
Executable
Back
Levels of Syntax
Front
Lexical syntax
Concrete Syntax
Abstract Syntax
Back
Section 2
(19 cards)
The syntax of a typical programming language can be expressed using regular expressions
Front
False
Back
What construct of a programming language provides process abstraction?
Front
Programmer defined functions
Standard function libraries
Subprograms
Back
Consider a language for matching parentheses, such as (), (()), (()()), ((()())()) but not (())). Write the context free grammar to correctly describe this language
Front
S -> (S) | B
B -> ()S | A
A -> e
Back
What is the name of the category of programming languages whose structure is dictated by the von Neumann computer architecture?
Front
Imperative
Back
There are three ways we discussed to solve the dangling else problem, What where they and what language uses it?
Front
ambiguous grammar with external rule--C
More complex grammar--Java
Adds terminator (endif) to the language--Ada
Back
Semantic Analyzer
Front
Type checker, inputs tree, output: Intermediate code
followed by an optimizer and Code generator
Back
Based on the grammar, write if its possible
A -> 01A | 10A | BAB | e
B -> 11 | 00
a. 0000
b. 110111
c. 11011000
Front
a. yes
b. no
c. yes
Back
For the following rules:
a) Give * a higher precedence than the +
b) force + to be right associative (keep * left associative)
A >> id = E
E >> E*T
E >> T
T >> T + D
T >> D
ID >> A | B | C
D >> 0 | 1 |.....9
Front
a. Make E T == E+T and make E+T == ET
b. Switch T+D to D+T (D is a terminal and will end as right associative)
Back
Which of the two grammars have we used in the study of programming languages and compilers?
Finite state automata can be used to describe that same class of languages as Context-free grammars
Front
False (regular grammar)
Back
What programming language has dominated business applications over the past 50 years?
Front
Cobol
Back
What programming language has dominated artificial intelligence over the past 50 years?
Front
lisp
Back
BNF is a stylized version of Context Sensitive Grammar
Front
False
Back
Lexer
Front
input char (source code) output tokens; based on regular grammar
Back
Mark C for compiler or I for interpreter
1.Can run immediately
2.Only object code in memory
3.Interpreter in memory when executing
4.Each statement translated once
5.Faster execution
6.Allows more sensitive enviroment
7.Translate only if needed
8.Object file likely large
9.If source code change must compile
Front
i-1.Can run immediately
c-2.Only object code in memory
i-3.Interpreter in memory when executing
c-4.Each statement translated once
c-5.Faster execution
i-6.Allows more sensitive enviroment
i-7.Translate only if needed
c-8.Object file likely large
c-9.If source code change must compile
Back
Parser
Front
inputs tokens, outputs abstract parse tree; based on EBNF