Chapter 2 (Paradigm) Flashcards
What is a syntax?
Its a precise description of all its grammatically correct programs
With what program was precise syntax used?
Algol 60
Levels of syntax?
Lexical syntax
Concrete syntax
Abstract syntax
What is a lexical syntax?
all the basic symbols of the language (names, values, operators)
What is a concrete syntax?
rules for writing expressions, statements and programs.
What is an abstract syntax?
Internal representation of the program, favoring content over form
What is a metalanguage?
Its a language used to define other languages
What is a grammar?
Its a metalanguage used to define the syntax of language
What is a BNF? What does it do?
Backus-Naur Form
stylized version of a context-free grammar
First used to define syntax of Algol 60
What is a parse tree?
Parse tree is a graphical representation of derivation.
What does a parse tree do?
node of the tree corresponds to a step in derivation
each child of node represents a right-hand side of production
each leaf node represents a symbol of the derived string
How can a grammar be defined?
With associativity and precedence
When is grammar ambiguous?
When one of its strings has two or more different parse trees.
What is a lexer?
Its the process of converting a sequence of characters into a sequence.
Input: characters
Output: tokens
What is a parser?
Based on BNF/EBNF grammar.
Input: tokens
Output: parse tree.