PRELIM EXAM FOR PROGLANG

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

1/121

flashcard set

Earn XP

Description and Tags

Syntax and Semantics - Number, Bindings and Scope - Data Types

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

122 Terms

1
New cards

Syntax

The form and structure of program code

2
New cards

Semantics

The meaning of program code (expressions, statements, control structures)

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 like identifiers

7
New cards

Generators (Grammars)

Devices that generate sentences of a language

8
New cards

Recognizers (Parsers)

Devices that read input strings and decide if they belong to a language

9
New cards

Context-Free Grammars (CFG)

Developed by Noam Chomsky in the 50s to describe syntax

A context-free grammar G is defined by the 4-tuple G = (V, Σ, R, S)

10
New cards

Backus-Naur Form (BNF)

Invented by John Backus in 1959 to describe Algol 58

11
New cards

Nonterminal Symbols

Abstractions representing classes of syntactic structures (often in angle brackets)

12
New cards

Terminal Symbols

Lexemes or tokens in language

13
New cards

V

Finite set of non-terminal characters or variable

14
New cards

Σ

Finite set of terminals (alphabet of the language)

15
New cards

R

Finite relation from V to (V ∪ Σ)* (the rewrite rules or productions)

16
New cards

S

Start variable/symbol (element of V)

17
New cards

Left-Hand Side (LHS)

The nonterminal being defined

18
New cards

Right-Hand Side (RHS)

String of terminals and/or nonterminals

19
New cards

Alternation ( | )

Indicates multiple possible right-hand sides for a nonterminal

20
New cards

Derivation

Repeated application of rules, starting with start symbol and ending with a sentence

21
New cards

Sentential form

Any string of symbols in a derivation

22
New cards

Sentence

A sentential form with only terminal symbols

23
New cards

Leftmost Derivation

Expands the leftmost nonterminal in each step

24
New cards

Rightmost Derivation

Expands the rightmost nonterminal in each step

25
New cards

Parse tree

Hierarchical representation of a derivationA

26
New cards

Ambiguous Grammar

A grammar that generates at least one sentential form with tow or more distinct Parse Trees

27
New cards

Operator Precedence

Can be expressed by proper structuring of grammar rules

28
New cards

Operator associativity

Can be indicated by grammar structure

29
New cards

Optional Parts (EBNF)

Placed in brackets [ ]

30
New cards

Alternative Parts (EBNF)

Placed in parentheses and separated by vertical barsR

31
New cards

Repetition (0 or more) (EBNF)

Placed in curly braces { }

32
New cards

Static Semantics

Deals with context-sensitive aspects of language that CFGs cannot describe

Examples are type checking, variable declaration before use

33
New cards

Attribute Grammar

A CFG with additions to carry semantic information on parse tree nodes

34
New cards

Attributes

Values associated with grammar symbols

35
New cards

Synthesized Attributes

Defined by the functions of the form S(X₀) = f(A(X₁), ..., A(Xₙ))

36
New cards

Inherited Attributes

Passed information down the parse tree

37
New cards

Intrinsic Attributes

Initial attributes on the leaves

38
New cards

Variable

An abstraction of a memory cell, characterized by six attributes: name, address, type, value, lifetime, and scope

39
New cards

Name Characteristics

Case sensitivity, length restrictions, special characters, reserved words vs keywords

40
New cards

Reserved word

A special word that cannot be used as a user-defined name (e.g., COBOL has 300 reserved words)

41
New cards

Keyword

A word that is special only in certain contexts (e.g., “real” in Fortran)

42
New cards

Aliases

When two variable names can be used to access the same memory location (created via pointers, reference variables, unions)

43
New cards

Name

The identifier used to reference the variable

44
New cards

Address (l-value)

The memory address with which the variable is associated

45
New cards

Type

Determines the range of values and set of operations defined for the variable

46
New cards

Value (r-value)

The contents of the location with which the variable is associated

47
New cards

Lifetime

The time during which a variable is bound to a particular memory cell

48
New cards

Scope

The range of statements over which the variable is visible

49
New cards

Binding

An association between an entity and an attribute

50
New cards

Binding time

The time at which a binding takes place

51
New cards

Static Binding

Occurs before runtime and remains unchanged throughout program execution

52
New cards

Dynamic Binding

Occurs during execution or can change during execution

53
New cards

Language Design Time

Binding operator symbols to operation

54
New cards

Language Implementation Time

Binding float type to a representation

55
New cards

Compile Time

Binding a variable to a type in C or Java

56
New cards

Runtime

Binding a non-static local variable to a memory cell

57
New cards

Explicit declaration

A program statement used for declaring types of variables

58
New cards

Implicit declaration

A default mechanism for specifying types through conventions

59
New cards

Type Inferencing

Determining types of variables from context (C#, Visual BASIC 9.0, ML, Haskell, F#, GO)

60
New cards

Static

Bound to a memory cells before execution begins and remains bound to the same memory cell

61
New cards

Stack-dynamic

Storage bindings created when declaration statements are elaborated

62
New cards

Explicit heap-dynamic

Allocated and deallocated by explicit directives during execution

63
New cards

Implicit heap-dynamic

Allocation and deallocation caused by assignment statements

64
New cards

Local Variables

Variables declared in a program unit

65
New cards

Nonlocal Variables

Variables visible in a unit but not declared there

66
New cards

Global Variables

Special category of nonlocal variables

67
New cards

Scope Rules

Determine how references to names are associated with variables

68
New cards

Static Ancestors

Enclosing static scopes to a specific scope

69
New cards

Static Parent

The nearest static ancestor

70
New cards

Blocks

Method of creating static scopes inside program units (from ALGOL 60)

71
New cards

Declaration Order

When and where variables must be declared (varies by language)

72
New cards

Global Scope

Variables declared outside function definitions (C, C++, PHP, Python)

73
New cards

Dynamic Scope

Based on calling sequences of program units (temporal vs spatial)

References connected by searching through the chain of subprogram calls

74
New cards

Data Type

A collection of data objects and a set of predefined operations on those objects

75
New cards

Primitive Data Type

Data types not defined in terms of other data types; often reflections of Hardware

76
New cards

Primitive Data Types

Integer, Floating Point, Complex, Decimal, Boolean, Charact

77
New cards

Integer

Represents numbers without fractions

Many languages provide multiple int types of different sizes

78
New cards

Floating Point

This primitive data type models real numbers

79
New cards

IEEE Floating-Point Standard 754

The standard for floating Points

80
New cards

Complex

This primitive data type consists of two floating point values: real and imaginary part

Supported by Fortran and Python

81
New cards

Decimal

This primitive data type stores numbers using decimal digits (4 bits per digit)

Its advantage is accuracy for financial calculations

Its disadvantage is that it wastes memory and has limited range

82
New cards

Boolean

Simplest primitive data type with values true and false

Often implemented as bytes than bits

83
New cards

Character

This primitive data type is stored as numeric codings

Common encodings are ASCII (8-bit) and Unicode (16-bit)

84
New cards

Unicode

This character encoding includes all characters from most natural languages

85
New cards

Character String Types

Values are sequences of characters

86
New cards

Character String Types Typical Operations

Assignment and Copying

Comparison

Catenation (Concatenation ??)

Substring Reference

Pattern Matching

87
New cards

Ordinal Types

Types where possible values can be associated with positive integers

88
New cards

Primitive Ordinal Type Examples

Integer, character, boolean types

89
New cards

User-Defined Ordinal Types

Enumeration Types

Subrange Types

90
New cards

Enumeration Types (Ordinal Type)

This ordinal type’s possible values are named constants

91
New cards

Subrange Types (Ordinal Type)

This ordinal type is an ordered contiguous subsequence

92
New cards

Array Type

Aggregate of homogeneous data elements identified by position

93
New cards

Array Indexing

Mapping from indices to elements

94
New cards

Integer Only Index Types

Java, C++, Fortran has one type of Index Type

95
New cards

Ordinal Types in General

Ada has one type of Index Type

96
New cards

Default Range Checking

Range checking of Java, C#

97
New cards

No Range Checking

Range checking of C, Fortran

98
New cards

On Demand Range Checking

Range checking of C++, Ada

99
New cards

Location Options

Static, stack, and heap allocations

100
New cards

Size Management

Static array sizes (known during compile time)

Dynamic management during runtime