Programing Languages chapter 6

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

1/32

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

33 Terms

1
New cards

Syntax

The structure and rules that define how statements are constructed in a programming language.

2
New cards

Context-free grammars

Introduced by Noam Chomsky in the 1950s.

3
New cards

BNF

Backus-Naur Form, a notation for describing the grammar of programming languages.

4
New cards

Variations of BNF

Original BNF, Extended BNF (EBNF), and syntax diagrams.

5
New cards

Lexical structure

Defines the tokens or words of a language, handled during the scanning phase of compilation.

6
New cards

Tokens vs. Syntactic structure

Tokens are the basic words or symbols; syntax is how tokens are arranged to form valid statements.

7
New cards

Types of tokens

Reserved words, literals/constants, special symbols, identifiers, predefined identifiers.

8
New cards

Principle of longest substring

The scanner collects the longest possible string of nonblank characters to form a token.

9
New cards

Whitespace effect on token recognition

Whitespace separates tokens and can affect how tokens are recognized; in some languages, indentation matters.

10
New cards

Free-format language

A language where the format does not affect program structure, except for the longest substring rule.

11
New cards

Fixed-format language

A language where tokens must appear in specific locations on the page.

12
New cards

Tokens description

Described formally by regular expressions, which use concatenation, repetition (*), choice (|), range (-), optional (?), and any character (.).

13
New cards

Regular expression for an integer constant

A sequence of digits 0-9.

14
New cards

Context-free grammar

A set of rules with a single nonterminal on the left and a sequence of terminals/nonterminals on the right.

15
New cards

Production in grammar

A single rule in a context-free grammar or BNF.

16
New cards

Parse tree

A graphical representation of the syntactic structure of a string according to a grammar.

17
New cards

Abstract syntax tree (AST)

A simplified version of a parse tree that captures the essential structure for translation or analysis.

18
New cards

Grammar ambiguity

Occurs when two distinct parse trees (or leftmost derivations) can be constructed for the same string.

19
New cards

Associativity

The order in which operations of the same precedence are performed (left or right).

20
New cards

Precedence

A ranking that determines which operations are performed first in an expression.

21
New cards

Removing grammar ambiguity

Can be done by revising grammar rules or disambiguating them, such as introducing new nonterminals for precedence.

22
New cards

Leftmost derivation

A derivation where the leftmost nonterminal is replaced at each step, leading to a unique parse tree.

23
New cards

EBNF additions to BNF

Adds curly braces for repetition, square brackets for optional parts, making some rules clearer.

24
New cards

Syntax diagram

A graphical way to represent grammar rules, using shapes for terminals/nonterminals and arrows for sequence.

25
New cards

Recognizer in parsing

A tool that accepts or rejects strings as legal according to a grammar.

26
New cards

Bottom-up parsing

A parsing technique that builds parse trees from the leaves upward (shift-reduce parsing).

27
New cards

Top-down parsing

A parsing technique that builds derivations from the root downward.

28
New cards

Parser generator

A tool that automates parser creation, such as YACC or Bison.

29
New cards

Recursive-descent parsing

A parsing method where nonterminals become mutually recursive procedures matching input tokens to grammar rules.

30
New cards

Difference between lexics, syntax, and semantics

Lexics: token recognition; Syntax: structure; Semantics: meaning, sometimes context-sensitive.

31
New cards

Reserved word

A word that cannot be used as an identifier in a program.

32
New cards

Predefined identifier

An identifier with an initial meaning that can be redefined in a program.

33
New cards

TinyAda

A small language used to illustrate high-level syntactic features, with a syntax analyzer that checks correctness independently of semantics.