CSE 3302 Exam 3 Chapter 6 Slides

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

1/99

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.

100 Terms

1
New cards

Syntax

The structure of a language; defines how symbols can be combined to form valid programs.

2
New cards

Noam Chomsky

Developed the idea of context-free grammars in 1950, which describe the structure of languages.

3
New cards

John Backus and Peter Naur

Developed the notational system known as Backus-Naur Form (BNF) to describe programming language syntax, first used for Algol60.

4
New cards

Backus-Naur Form (BNF)

A notation system for describing context-free grammars, using "→" for rules and "|" for choices.

5
New cards

Context-Free Grammar

A grammar made up of rules where a single nonterminal on the left side can be replaced by a sequence of terminals or nonterminals on the right.

6
New cards

Extended Backus-Naur Form (EBNF)

A variation of BNF adding curly braces {} for repetition and square brackets [] for optional parts.

7
New cards

Syntax Diagram

A visual representation of grammar rules using shapes and arrows to show sequence, repetition, and choice.

8
New cards

Lexical Structure

The structure of the tokens (words) in a programming language; handled during the scanning phase.

9
New cards

Token

A basic unit in source code such as a keyword, identifier, literal, or operator.

10
New cards

Scanning Phase

The compilation phase where a translator collects sequences of characters and forms them into tokens.

11
New cards

Parsing Phase

The phase where the translator processes tokens to determine syntactic structure.

12
New cards

Semantics

The meaning of syntactically correct statements; syntax defines structure while semantics defines meaning.

13
New cards

Reserved Words (Keywords)

Predefined tokens that cannot be redefined in a program.

14
New cards

Literals or Constants

Tokens representing fixed values such as numbers or characters.

15
New cards

Special Symbols

Characters like ";", "<=", or "+" that have syntactic meaning.

16
New cards

Identifiers

Names given to variables, functions, etc. defined by the programmer.

17
New cards

Predefined Identifiers

Identifiers with initial meanings in the language that can be redefined by the programmer.

18
New cards

Principle of Longest Substring

The scanner should recognize the longest possible valid token sequence.

19
New cards

Token Delimiters (Whitespace)

Formatting like spaces or newlines that separate tokens.

20
New cards

Free-Format Language

A language where indentation or spacing does not affect structure, only token separation.

21
New cards

Fixed-Format Language

A language where tokens must appear in specific positions (e.g., Fortran).

22
New cards

Regular Expression

A formal pattern describing sets of strings used to define token structures.

23
New cards

Concatenation

Sequentially combining items in a regular expression.

24
New cards

Repetition (*)

Indicates zero or more repetitions of the preceding element in a regular expression.

25
New cards

Choice (|)

Indicates an alternative between items in a regular expression.

26
New cards

Character Range ([a-z])

Specifies a range of allowed characters.

27
New cards

Optional (?)

Marks an item as optional in a regular expression.

28
New cards

Period (.)

Represents any single character in a regular expression.

29
New cards

Context-Free Grammar Rule

A rule describing how a nonterminal can be replaced with other symbols.

30
New cards

Metasymbols

Symbols used in grammar notation like "→" and "|".

31
New cards

Derivation

The process of generating a string by applying grammar rules starting from the start symbol.

32
New cards

Nonterminal

A symbol that can be replaced by other symbols through grammar rules.

33
New cards

Terminal

A basic symbol that cannot be replaced further; corresponds to tokens.

34
New cards

Production

Another name for a grammar rule.

35
New cards

Start Symbol

The top-level nonterminal representing an entire language structure.

36
New cards

Language of the Grammar

The set of all strings derivable from the start symbol following the grammar rules.

37
New cards

Recursion in Grammar

A rule that refers to itself, allowing repeated structures.

38
New cards

Parse Tree

A graphical depiction of how a string is derived from the start symbol using grammar rules.

39
New cards

Abstract Syntax Tree (AST)

A simplified version of a parse tree that omits unnecessary syntactic details.

40
New cards

Syntax-Directed Semantics

Associating meaning with syntactic structures during compilation.

41
New cards

Concrete Syntax

The exact textual form of a program's syntax.

42
New cards

Ambiguous Grammar

A grammar where more than one parse tree can represent the same string.

43
New cards

Leftmost Derivation

A derivation where the leftmost nonterminal is always expanded first.

44
New cards

Rightmost Derivation

A derivation where the rightmost nonterminal is always expanded first.

45
New cards

Precedence

Determines which operations bind more tightly when parentheses are omitted.

46
New cards

Associativity

Determines the order of evaluation for operations of the same precedence (left or right).

47
New cards

Ambiguity Resolution

The process of rewriting or constraining grammar to remove ambiguity.

48
New cards

Left-Recursive Rule

A grammar rule where the leftmost symbol in the right-hand side is the same as the left-hand side.

49
New cards

Right-Recursive Rule

A grammar rule where the recursive call appears on the right end of the production.

50
New cards

Term Rule (Precedence Cascade)

A new grammar rule written to handle operator precedence.

51
New cards

EBNF Curly Braces {}

Indicate zero or more repetitions of a part of a rule (loop).

52
New cards

EBNF Square Brackets []

Indicate optional parts of a rule.

53
New cards

Syntax Diagram Symbols

Circles/ovals for terminals, rectangles for nonterminals, arrows for sequence.

54
New cards

Repetition in Syntax Diagrams

Represented by loops connecting back to a previous element.

55
New cards

Parser

A program or component that analyzes token sequences according to grammar rules.

56
New cards

Recognizer

A parser that accepts or rejects input strings based on whether they follow grammar rules.

57
New cards

Bottom-Up Parser

Builds parse trees from the leaves (tokens) up to the root (start symbol).

58
New cards

Shift-Reduce Parser

A bottom-up parser that shifts tokens onto a stack and reduces them to nonterminals.

59
New cards

Top-Down Parser

Expands nonterminals to match tokens, constructing derivations directly from the start symbol.

60
New cards

Parser Generator

A tool that automatically builds parsers from grammar specifications (e.g., YACC).

61
New cards

Recursive-Descent Parser

A top-down parser implemented with mutually recursive procedures representing grammar rules.

62
New cards

Left Recursion Problem

A left-recursive grammar can cause infinite recursion in a recursive-descent parser.

63
New cards

Left Recursion Removal

Done by rewriting rules or using EBNF loops {}.

64
New cards

Left Factoring

Transforming grammar rules to remove common prefixes so a parser can decide which rule to apply.

65
New cards

Single-Symbol Lookahead

Using one token of lookahead to decide parsing actions.

66
New cards

Predictive Parser

A top-down parser that makes decisions based only on a single lookahead token.

67
New cards

LL(1) Grammar

A grammar suitable for predictive parsing with one token of lookahead.

68
New cards

YACC

A parser generator that produces bottom-up parsers in C using grammar definitions.

69
New cards

Bison

A free version of YACC.

70
New cards

yyparse

The parsing function generated by YACC.

71
New cards

yylex

The scanner function called by the parser to get tokens.

72
New cards

Lexical Conventions

Rules for tokenizing input, such as whitespace or identifier syntax.

73
New cards

Lexics

The study of the lexical (token-level) structure of programming languages.

74
New cards

Syntax

The rules governing structure and form of code.

75
New cards

Semantics

The meaning and behavior of syntactically correct code.

76
New cards

Lexics vs Syntax

Lexics deals with tokens, syntax deals with structure.

77
New cards

Syntax vs Semantics

Syntax defines form; semantics defines meaning.

78
New cards

Context-Sensitive Rules

Rules depending on context, such as variable declarations before use.

79
New cards

Semantic Properties

Aspects that cannot be described with context-free grammar (e.g., type checking).

80
New cards

Reserved Word

A keyword that cannot be used as an identifier.

81
New cards

Predefined Identifier

A name that is defined by default but can be redefined.

82
New cards

TinyAda

A simplified programming language used to illustrate syntax analysis concepts.

83
New cards

Parsing Shell

A tool or framework that applies grammar rules to check token correctness.

84
New cards

Syntax Analyzer

The component that checks the syntactic correctness of a program using grammar rules.

85
New cards

Semantic Analysis

The stage after syntax analysis that checks for meaning and type correctness.

86
New cards

Ambiguity Testing

Searching for multiple leftmost derivations of the same string to detect ambiguity.

87
New cards

Grammar Language Definition

The total set of legal strings derivable from the grammar.

88
New cards

Syntax-Directed Translation

The process of generating intermediate representations during parsing.

89
New cards

Free-Format Example

C, Python (spacing irrelevant except indentation in Python).

90
New cards

Fixed-Format Example

Early Fortran (specific column-based code structure).

91
New cards

Principle of Longest Match

The scanner always matches the longest valid token possible.

92
New cards

Regular Expression Example

[0-9]+ defines an integer constant.

93
New cards

EBNF Loop Meaning

Represents repeated elements in grammar without left recursion.

94
New cards

Predictive Parsing Condition

No two right-hand sides of a rule can start with the same token.

95
New cards

Lookahead Limitation

If grammar choices share prefixes, more lookahead or refactoring is needed.

96
New cards

Syntax and Semantics Interdependence

Occurs when meaning helps resolve ambiguous syntax.

97
New cards

Compiler Phases

Scanning, Parsing, Semantic Analysis, Code Generation, Optimization.

98
New cards

Syntactic Correctness

The program follows all grammar rules.

99
New cards

Semantic Correctness

The program makes logical sense beyond syntax.

100
New cards

Parsing Tree Node Labels

Nonterminals for internal nodes, terminals for leaves.