326 exam 1

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/26

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

27 Terms

1
New cards

How do we evaluate programming languages?

Readability, writability, and reliability

2
New cards

What are the evaluation criteria

1) simplicity/orthogonality

2) control structures

3) data types

4) syntax design

5) abstraction support

6) expressive

7) Type checking

8) exception handling

9) aliasing

3
New cards

What are the 3 implementation methods

1) compilation/translation

2) interpretation

3) hybrid (both)

4
New cards

What’s the difference between a compiler and interpreter

Compiler: translates source program and generates an executable

Interpreter: reads a line of code, translates it, and executes the translation

5
New cards

What are the common types of programming paradigms

imperative and declarative

6
New cards

how do we precisely describe what a program is in a language

we use grammars to describe the syntax of different languages

7
New cards

list all the terms used to describe syntax and briefly describe them

1) Lexeme: lowest level syntactic unit of a language: *, class, sum, …

2) Token: A category of lexemes: identifies, keywords, …

3) Sentence: A stream of characters over an alphabet

8
New cards

What are the 2 distinct ways to define a language

recognizer (scanner) and a generator (parser)

9
New cards

What is a metalanguage

a language used to describe another language

10
New cards

Explain how BNF can be used

to create rules for any languages

11
New cards

why are derivations important

It shows the steps/sequence of rules that must be applied to generate a sentence of a given language

12
New cards

what’s a parse tree

a tree that represents a syntactically valid program/string

13
New cards

given a parse tree and a grammar, can we always produce a correct derivation without any mistakes

yes, but ONLY if the grammar is unambiguous

14
New cards

when is a grammar ambiguous

2+ parse trees for the same string

15
New cards

How do we preserve left associativity

1) Determine the precedence of all operators

2) Write the grammar in a cascading manner

16
New cards

Can we prove when a grammar is ambiguous

No, but we can demonstrate it

17
New cards

How do we precisely describe what a program is in a language

We use grammars to desceibe the sytax of deifferent languages

18
New cards

What are the 2 distinct goals of parsing

1) Determine if the program/string is syntactically correct

2) Produce/generate a unique parse tree

19
New cards

What are the 2 types of parsing algorithms that we will study

1) top down

2) bottom up

20
New cards

Top Down parsing

parse tree is created from root (start) to leaves (terminals) during a Left Most derivation

21
New cards

Bottom Up Parsing

parse tree is created from leaf nodes (terminals) to root (start symbol during a Right Most derivation

22
New cards

What is a recursive descent parsing, and how is it implemented

1) A kind of top down parsing

2) One function per non terminal with one case per different RHS (for the same LHS)

23
New cards

Provide an example of an expression that can be parsed using a recursive descent parser

A → aA | ε

w = aaa…a

24
New cards

If we let G be a grammar, then what can a parser do?

It can describe whether w (input) is the language generated by a grammar

25
New cards

What are the rules for computing the first sets

1) If X produces a terminal a, then FIRST(X) = {a}

2) If X produces ε, then FIRST(X) = {ε}

3) If X produces a mix of terminals and non-terminals, then FIRST(X) = FIRST(Y1) U FIRST(Y2) U … excluding {ε}

26
New cards

What makes a grammar LL(1)

1) No left recursive rules

2) Must pass pairwise disjoint test

27
New cards