Chapter 3 | Describing Syntax and Semantics

0.0(0)
studied byStudied by 8 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/78

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.

79 Terms

1
New cards

True or False:

Syntax defines the meaning of programming language constructs.

False

2
New cards

True or False:

Semantics defines the meaning of statements in a programming language.

True

3
New cards

True or False:

Lexical analysis groups characters into tokens.

True

4
New cards

True or False:

A context-free grammar (CFG) is commonly used to describe semantics.

False

5
New cards

True or False:

BNF stands for Backus–Naur Form.

True

6
New cards

True or False:

In BNF, nonterminal symbols are typically written in angle brackets < >.

True

7
New cards

True or False:

Terminals in a grammar are symbols that can be further expanded.

False

8
New cards

True or False:

Ambiguity occurs when a grammar produces more than one parse tree for a single string.

True

9
New cards

True or False:

EBNF (Extended BNF) allows repetition and optional parts in grammar rules.

True

10
New cards

True or False:

Parse trees represent the semantic meaning of a program.

False

11
New cards

True or False:

A leftmost derivation always replaces the rightmost nonterminal first.

False

12
New cards

True or False:

Recursive descent parsers may require backtracking.

True

13
New cards

True or False:

Attribute grammars extend context-free grammars with attributes and rules.

True

14
New cards

True or False:

In attribute grammars, synthesized attributes pass information upward in the parse tree.

True

15
New cards

True or False:

Inherited attributes flow only upward in the parse tree.

False

16
New cards

True or False:

Static semantics involves properties checked at compile time.

True

17
New cards

True or False:

Type checking is a form of static semantics.

True

18
New cards

True or False:

Dynamic semantics refers to meaning that can be checked without execution.

False

19
New cards

True or False:

Operational semantics describes meaning by changes in an abstract machine’s state.

True

20
New cards

True or False:

Denotational semantics describes meaning using mathematical functions.

True

21
New cards

True or False:

Axiomatic semantics is based on predicate logic.

True

22
New cards

True or False:

Hoare triples are part of denotational semantics.

False

23
New cards

True or False:

A Hoare triple has the form {precondition} program {postcondition}.

True

24
New cards

True or False:

Operational semantics is the most abstract approach to describing semantics.

False

25
New cards

True or False:

Denotational semantics maps programming constructs to precise mathematical objects.

True

26
New cards



True or False:

Axiomatic semantics is mainly concerned with implementation efficiency.

False

27
New cards

True or False:

Regular expressions are sufficient to describe all programming language syntax.

False

28
New cards

True or False:

Context-free grammars can describe nested constructs such as balanced parentheses.

True

29
New cards

True or False:

All BNF grammars are guaranteed to be unambiguous.

False

30
New cards

True or False:

Arithmetic precedence rules can be expressed using context-free grammars.

True

31
New cards

True or False:

Static semantics cannot be described using grammar alone.

True

32
New cards

True or False:

Syntax-directed definitions link grammar rules with semantic actions.

True

33
New cards

True or False:

Attribute grammars cannot be used for static semantics checks.

False

34
New cards

True or False:

Denotational semantics is generally less mathematically precise than operational semantics.

False

35
New cards

True or False:

Axiomatic semantics uses logic to prove program correctness.

True

36
New cards

True or False:

Parse trees and derivations are used to represent semantics.

False

37
New cards

True or False:

BNF and EBNF are primarily concerned with describing syntax.

True

38
New cards

True or False:

Attribute grammars combine both syntax and semantics in a unified framework.

True

39
New cards

True or False:

In programming languages, syntax and semantics are unrelated.

False

40
New cards

True or False:

The study of semantics helps in understanding program correctness and reasoning.

True

41
New cards

The part of a programming language that defines the meaning of statements and constructs.

Semantics

42
New cards

The set of rules that defines the structure of programs and how symbols can be combined.

Syntax

43
New cards

The process of grouping characters from source code into meaningful tokens.

Lexical analysis

44
New cards

A formalism used to describe programming language syntax, not semantics.

Context-free grammar (CFG)

45
New cards

A notation for describing context-free grammars, commonly using angle brackets for nonterminals.

BNF (Backus–Naur Form)

46
New cards

Symbols in a grammar that cannot be expanded further.

Terminals

47
New cards

Occurs when a grammar can produce more than one parse tree for the same string.

Ambiguity

48
New cards

An extension of BNF that allows optional and repeated elements in grammar rules.

EBNF

49
New cards

Trees that represent the syntactic structure of a program.

Parse trees

50
New cards

A parsing strategy that may require backtracking when encountering multiple possible expansions.

Recursive descent parser

51
New cards

Grammars that are extended with attributes and rules to link syntax and semantics.

Attribute grammars

52
New cards

Attributes that pass information upward in the parse tree.

Synthesized attributes

53
New cards

Attributes that flow downward or across siblings in a parse tree.

Inherited attributes

54
New cards

Properties of a program that can be checked at compile time.

Static semantics

55
New cards

The process of verifying type correctness and other compile-time rules.

Type checking

56
New cards

Describes program meaning during execution rather than at compile time.

Dynamic semantics

57
New cards

Describes the meaning of a program by modeling state changes in an abstract machine.

Operational semantics

58
New cards

Describes programming constructs using precise mathematical functions.

Denotational semantics

59
New cards

Uses predicate logic to reason about program correctness.

Axiomatic semantics

60
New cards

A logical assertion of the form {precondition} program {postcondition}.

Hoare triple

61
New cards

The approach to describing semantics that focuses on proving program correctness rather than execution.

Axiomatic semantics

62
New cards

The formal system that maps programming constructs to precise mathematical objects.

Denotational semantics

63
New cards

Grammars capable of describing nested structures like balanced parentheses.

Context-free grammars (CFGs)

64
New cards

Grammars that may produce multiple parse trees for the same string are called…

Ambiguous grammars

65
New cards

The rules that define arithmetic precedence in programming languages can be expressed using this.

Context-free grammars

66
New cards

Describes properties of programs that cannot be enforced by grammar alone.

Static semantics

67
New cards

A method that links grammar rules directly with semantic actions.

Syntax-directed definitions

68
New cards

Grammars that can be used to check static semantics, like type consistency.

Attribute grammars

69
New cards

The formal approach to semantics that is less abstract and often models execution on an abstract machine.

Operational semantics

70
New cards

Trees or derivations that represent syntactic structure rather than semantic meaning.

Parse trees

71
New cards

A notation primarily concerned with describing syntax, such as grammar rules.

BNF or EBNF

72
New cards

A formalism that combines both syntax and semantics in a unified framework.

Attribute grammars

73
New cards

The study of meaning in programming languages, which helps reason about program correctness.

Semantics

74
New cards

Properties or rules of a program that can be enforced at compile-time rather than runtime.

Static semantics

75
New cards

The semantic approach that uses logic to prove correctness of programs.

Axiomatic semantics

76
New cards

Semantic method that describes meaning by mapping constructs to mathematical functions.

Denotational semantics

77
New cards

Semantic method that describes meaning via state changes in an abstract machine.

Operational semantics

78
New cards

A Hoare triple expresses correctness with a precondition, program, and postcondition.

{precondition} program {postcondition}

79
New cards

Dynamic semantics refers to meaning that is determined during program execution rather than at compile time.

Dynamic semantics