Concepts of PLs Definitions Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Syntax (of a PL)

A

The form of its expressions, statements, and program units

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Semantics (of a PL)

A

The meaning of the syntax (the expressions, statements, and program units)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Sentences

A

Also called statements; the strings of a language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Lexemes

A

Lowest-level syntactic units

Examples: numeric literals, operators, special words, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Identifiers

A

A group formed by lexemes;
A token that can have lexemes, or instances

Examples: names of variables, methods, classes, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Token (of a PL)

A

The name of a lexeme group; a category of its lexemes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Recognition

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Generation

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Grammars

A

The formal language generation mechanisms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Backus-Naur Form (BNF)

A
  • a way to describe syntax of a PL
  • uses natural notation
  • nearly identical to context free grammars (also, just “grammars”)
  • “BNF” and “grammar” are used interchangeably
  • a metalanguage for PLs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Context-free grammars

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Metalanguage

A

A language used to describe another language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Left-hand side (LHS)

A

The abstraction being defined; text left side of the arrow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Right-hand Side (RHS)

A

The definition of the LHS; consists of some mixture of tokens, lexemes, references to other abstracts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Rule (production)

A

LHS -> RHS; the total definition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Nonterminal symbols (nonterminals)

A

The abstractions in a BNF description, or grammar

17
Q

Terminal symbols (terminals)

A

The lexemes and tokens of the rules

18
Q

Grammar (BNF description)

A

A collection of rules

Note: a grammar is also called BNF

19
Q

What does BNF use for syntactic structures?

A

Abstractions

20
Q

Abstraction (in a BNF description)
(also, NONTERMINAL SYMBOLS)
(Also, NONTERMINALS)

A

• can have two or more distinct definitions, representing 2+ possible syntactic forms in the language
• these multiple definitions can be written as a single rule, with the different definitions separated by “|” (“logical OR)
Pointed brackets are often used to delimit names of abstractions

21
Q

What is the following symbol called: | ?

A

Logical OR

22
Q

The following is an example of a BNF of the Java if statement. Fill in the remaining syntax.

→ ( )
→ ( ) else

A

stmt

23
Q

What can BNF describe?

A

BNF can describe nearly all of the syntax of PLs because it is sufficiently powerful

24
Q

Rewrite the following BNF description using logical or:

→ if ( )
→ if ( ) else

A

→ if ( )

| if ( ) else

25
Q

Finish the definition of recursion:

A rule is recursive if _________________________________.

A

Its LHS appears in its RHS

26
Q

What does the following rule illustrate?

→ identifier | identifier,

A

How BNF uses recursion to describe lists

27
Q

What is in the following example?

→ identifier | identifier,

A

is either:

  • a single token (identifier) OR
  • an identifier followed by a comma and another instance of