Syntax and Semantics Flashcards

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

1/69

flashcard set

Earn XP

Description and Tags

Flashcards for Chapters 3 and 4 covering Syntax and Semantics

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

70 Terms

1
New cards

Syntax

The form or structure of expressions, statements, and program units in a language.

2
New cards

Semantics

The meaning of expressions, statements, and program units in a language.

3
New cards

Sentence

A string of characters over some alphabet.

4
New cards

Language

A set of sentences.

5
New cards

Lexeme

The lowest level syntactic unit of a language.

6
New cards

Token

A category of lexemes (e.g., identifier, int_literal).

7
New cards

Identifiers

Names the programmer chooses.

8
New cards

Keywords

Names already in the programming language.

9
New cards

Separators (Punctuators)

Punctuation characters.

10
New cards

Operators

Symbols that operate on arguments and produce results.

11
New cards

Literals

Numeric, logical, or textual values.

12
New cards

Recognizer

A recognition device that reads input strings and decides whether they belong to the language.

13
New cards

Generator

A device that generates sentences of a language.

14
New cards

Context-Free Grammars

Language generators used to describe the syntax of natural languages.

15
New cards

Backus-Naur Form (BNF)

Equivalent to context-free grammars, used to describe the syntax of Algol 58.

16
New cards

Nonterminal Symbols (Nonterminals)

Syntactic variables that represent classes of syntactic structures.

17
New cards

Terminals

Lexemes or tokens in a grammar.

18
New cards

Production Rules

Defines how non-terminals can be expanded or replaced.

19
New cards

Left-Hand Side (LHS)

The nonterminal on the left side of a production rule.

20
New cards

Right-Hand Side (RHS)

A string of terminals and/or nonterminals on the right side of a production rule.

21
New cards

Grammar

A finite non-empty set of rules.

22
New cards

Start Symbol

A special element of the nonterminals of a grammar.

23
New cards

Derivation

A repeated application of rules, starting with the start symbol.

24
New cards

Sentential Form

A string of symbols in a derivation.

25
New cards

Sentence

A sentential form that has only terminal symbols.

26
New cards

Leftmost Derivation

The replaced non-terminal is always the leftmost non-terminal.

27
New cards

Rightmost Derivation

The replaced non-terminal is always the rightmost non-terminal.

28
New cards

Parse Tree

Hierarchical structure that shows the derivation process.

29
New cards

Ambiguous Grammar

A grammar that generates a sentential form with two or more distinct parse trees.

30
New cards

Specifying Precedence

Building precedence into the grammar using a different non-terminal for each precedence level.

31
New cards

Specifying Associativity

Allowing recursion only on either left or right non-terminal to specify the order of operations.

32
New cards

Dangling-Else

An optional else clause in a nested conditional structure that becomes ambiguous.

33
New cards

Extended BNF (EBNF)

Extensions to BNF to simplify rules without enhancing descriptive power.

34
New cards

Lexical Analyzer

A low-level part of a language processor; a finite automaton based on a regular grammar.

35
New cards

Syntax Analyzer (Parser)

A high-level part of a language processor; a push-down automaton based on a context-free grammar.

36
New cards

Lexical Analyzer

A pattern matcher for character strings.

37
New cards

Lexemes

Substrings of the source program that belong together.

38
New cards

Token (Lexical Analyzer Context)

Character pattern associated with a lexical category.

39
New cards

Lookup

Determines whether the string in lexeme is a reserved word.

40
New cards

GetChar

Reads the next character of the input string.

41
New cards

AddChar

Appends nextChar to the current lexeme.

42
New cards

Goals of the Parser

Find all syntax errors, produce an appropriate diagnostic message and recover quickly; produce the parse tree.

43
New cards

Top-Down Parser

Produces the parse tree, beginning at the root (leftmost derivation).

44
New cards

Bottom-Up Parser

Produces the parse tree, beginning at the leaves (reverse of a rightmost derivation).

45
New cards

Top-Down Parser Operation

Uses the first token produced by the A-rule to choose correct A-rule to get the next sentential form.

46
New cards

Bottom-Up Parser Operation

Identifies which substring of α corresponds to the right-hand side of a grammar rule.

47
New cards

Recursive Descent

A coded implementation of a top-down parser.

48
New cards

LL Algorithm

An algorithm that generates a leftmost derivation with a left-to-right scan of input.

49
New cards

LR Family

where L stands for a left-to-right scan of the input and a rightmost derivation is being constructed.

50
New cards

nextToken

The next token code is stored here by the lexical analyzer.

51
New cards

Left Recursion Problem

A problem where a grammar cannot be the basis for a top-down parser due to recursion.

52
New cards

Left Factoring

A process to eliminate common prefixes so the correct RHS can be determined with one token of lookahead.

53
New cards

Handle

The specific RHS in the right sentential form that must be reduced to get the previous sentential form.

54
New cards

Shift

Moving the next input token to the top of the parse stack.

55
New cards

Reduce

Replacing the handle on the top of the parse stack with its corresponding LHS.

56
New cards

Static Semantics

Rules that further constrain syntactically correct programs; verified at compiler time.

57
New cards

Attribute Grammar

Designed to describe both the syntax and the static semantics of PLs.

58
New cards

Attributes

Associated with grammar symbols, either terminal or nonterminal.

59
New cards

Attribute Computation Functions (Semantic Functions)

Associated with grammar rules; specify how attribute values are computed.

60
New cards

Predicate Function

Associated with grammar rules and state the static semantic rules of the language.

61
New cards

Synthesized Attributes

Used to pass semantic information up a parse tree (bottom up).

62
New cards

Inherited Attributes

Used to pass semantic information down and across a tree (top down).

63
New cards

Operational Semantics

Describe the meaning of a statement or program by specifying the effects of running it on a machine.

64
New cards

Denotational Semantics

Defines a mathematical object for each language entity and a function that maps language instances onto mathematical objects.

65
New cards

State of a Program

The values of all its current variables.

66
New cards

Axiomatic Semantics

Based on formal logic (predicate calculus) for formal program verification.

67
New cards

Assertions

Logical expressions stating relationships and constraints among variables.

68
New cards

Precondition

An assertion that states relationships and constraints among variables that are true at that point in execution, before a statement.

69
New cards

Postcondition

An assertion that states relationships and constraints among variables that are true at that point in execution, following a statement.

70
New cards

Weakest Precondition

The least restrictive precondition that will guarantee the postcondition.