Chapter 3: Describing Syntax & Semantics- Survey Programing

0.0(0)
studied byStudied by 0 people
0.0(0)
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/33

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:04 PM on 2/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

34 Terms

1
New cards
What is syntax?
The structure or form of expressions, statements, and program units.
2
New cards
What is semantics?
The meaning of expressions, statements, and program units.
3
New cards
What is a sentence?
A string of characters over some alphabet.
4
New cards
What is an alphabet?
A set of symbols used to construct sentences.
5
New cards
What is a language?
A set of valid sentences.
6
New cards
What is a lexeme?
The lowest-level syntactic unit of a language (e.g., *, sum, begin).
7
New cards
What is a token?
A category of lexemes, such as identifier.
8
New cards
What is a recognizer?
A program that determines whether a string belongs to a language (used in compilers).
9
New cards
What is a generator?
A device that generates valid sentences of a language.
10
New cards
What is a Context-Free Grammar (CFG)?
A grammar used to describe the syntax of programming languages.
11
New cards
What are the four parts of a CFG?
N (non-terminals), T (terminals), P (production rules), S (start symbol).
12
New cards
What is Backus-Naur Form (BNF)?
A formal notation used to write context-free grammars.
13
New cards
How are grammar rules written in BNF?
Using a left-hand side non-terminal and a right-hand side of terminals and/or non-terminals.
14
New cards
What is an example of BNF for an expression grammar?
โ†’ + | โ†’ * |
15
New cards
What is a derivation?
The step-by-step application of grammar rules to generate a sentence.
16
New cards
What is a leftmost derivation?
A derivation that always expands the leftmost non-terminal first.
17
New cards
What is a rightmost derivation?
A derivation that always expands the rightmost non-terminal first.
18
New cards
What is a parse tree?
A hierarchical tree representation of a derivation showing structure.
19
New cards
What is an ambiguous grammar?
A grammar in which a string can have more than one parse tree.
20
New cards
How is ambiguity reduced in grammars?
By using operator precedence and associativity rules.
21
New cards
What is operator precedence?
Rules that determine which operations are evaluated first.
22
New cards
What is operator associativity?
Rules that determine evaluation order for operators of the same precedence.
23
New cards
What is Extended BNF (EBNF)?
A simplified form of BNF that reduces the number of grammar rules.
24
New cards
What does the EBNF optional symbol [ ] indicate?
It indicates optional elements.
25
New cards
What does the EBNF repetition symbol { } indicate?
It indicates zero or more repetitions.
26
New cards
What does the EBNF alternatives symbol ( | ) indicate?
It indicates choices.
27
New cards
What is static semantics?
Language rules that cannot be expressed by context-free grammars.
28
New cards
What is an example of static semantics?
Variables must be declared before they are used.
29
New cards
What is an attribute grammar?
A context-free grammar extended with semantic information.
30
New cards
What is a synthesized attribute?
An attribute computed from child nodes upward.
31
New cards
What is an inherited attribute?
An attribute passed from parent nodes downward.
32
New cards
What is operational semantics?
Defines program meaning by describing execution.
33
New cards
What is denotational semantics?
Defines program meaning using mathematical functions.
34
New cards
What is axiomatic semantics?
Defines program meaning using logic, preconditions, and postconditions.