Formal Languages, BNF, and Syntax Diagrams

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/24

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards reviewing core concepts of formal languages, context-free grammars, Backus–Naur Form (BNF) syntax, and syntax diagrams.

25 Terms

1
New cards

Formal language

A set of strings formed from an alphabet according to defined rules that describe which sequences of symbols are syntactically valid.

2
New cards

Context-free language

A language that can be generated by a context-free grammar, using production rules in which a single non-terminal is replaced by a sequence of terminals and/or non-terminals.

3
New cards

Grammar

A set of production rules that defines how valid strings in a language can be generated, describing permitted structure without listing every valid string.

4
New cards

Backus–Naur Form (BNF)

A notation for defining the syntax of a language using production rules, defining non-terminals in terms of terminals and/or other non-terminals.

5
New cards

Production rule

A grammar rule that defines how a non-terminal can be replaced, such as ::= + | -.

6
New cards

Non-terminal

A named grammar element that can be expanded using a production rule, commonly written in angle brackets, such as or .

7
New cards

Terminal

A literal symbol or token that appears in the final string and is not expanded further by the grammar, such as 0, +, (, and keywords.

8
New cards

::= (BNF symbol)

A BNF operator that means 'is defined as' or 'can be replaced by', which separates the non-terminal being defined from its possible replacement(s).

9
New cards

| (BNF symbol)

A BNF operator that means 'or', separating alternative valid replacements in a production rule.

10
New cards

Sequence (in BNF)

A required ordering represented by writing elements next to each other in the required order, such as ::= .

11
New cards

Recursion (in a grammar)

A feature occurring when a production rule refers, directly or indirectly, to the non-terminal it defines, enabling the grammar to describe repeated or nested structures.

12
New cards

Base case (in a grammar)

An alternative in a recursive grammar rule that stops the recursion, allowing repeated expansion to finish and produce a string containing only terminals.

13
New cards

Derivation (in BNF)

The process of starting with a start symbol and repeatedly applying production rules until only terminal symbols remain, forming the generated string.

14
New cards

Syntax diagram

A graphical way of representing language syntax using paths and labelled symbols to show the valid order, alternatives, and repetition of elements.

15
New cards

Alternative path (in a syntax diagram)

A branch representing choices where the input follows one permitted route; symbols on unchosen routes are not required.

16
New cards

Loop / Return path (in a syntax diagram)

A path allowing an element or group of elements to be traversed repeatedly according to arrows and notation keys.

17
New cards

Optional element (in a syntax diagram)

An element with one route that passes through it and an alternative route that bypasses it, allowing it to appear once or be omitted.

18
New cards

{0n1n∣n≥1}\{0^n 1^n \mid n \ge 1\}

An example of a context-free language that is not regular, featuring equal numbers of 0s followed by 1s (01, 0011, 000111, etc.) generated by ::= 01 | 01.

19
New cards

Matching nested brackets

A context-free pattern of unbounded depth that can be described by a recursive grammar, but cannot be tracked by a finite-state machine due to lacking unbounded memory.

20
New cards

Regular expression vs. BNF

A regular expression describes a regular language, whereas BNF can describe context-free structures using recursion; every regular language is context-free, but not every context-free language is regular.

21
New cards

Syntax

The permitted structure or arrangement of symbols in a language.

22
New cards

Semantics

The meaning or behaviour of a valid statement in a language.

23
New cards

Start symbol

The non-terminal from which a derivation begins, representing the overall construct being described, such as or .

24
New cards

Angle brackets (

The notation used to enclose and mark a non-terminal symbol in BNF.

25
New cards

BNF recursion advantage

The capability of BNF production rules to represent nested or matched structures of arbitrary depth or quantity, which a finite-state machine or regular expression cannot recognise.