Chapt 3: Syntax & Semantics Flashcards
Describing Syntax & Semantics
The ___ of a programming language is the form of its expressions, statements, and program units
Syntax
The ___ of a programming language is the meaning of its expressions, statements, and program untis.
Semantics
___ ___ are the syntax and semantics of a language for all those potential users & evaluators, who are interested in learning a& building skills in a specific language.
Language Descriptions
A ___ ___ can be defined as a setup which can be used to generate sentences of a language. The setup can be made to work & produce a sentence as per the requirement as in input and output.
language generator
the operation of a general ___ ___ is to aid compiler (of a language) by helping it in analyzing the syntax of the program code.
language recognizer
The strings of a language are called ___ or statements.
sentences
The ___ of a programming language include its numeric literals, operators, and special words among others.
lexemes
A ___ represents a lexeme group; a category of its lexemes.
token
Give the token for the example lexemes:
- index
- =
- 2
- +
- count
- identifier
- equal_sign
- int_literal
- plus_op
- identifier
__ __ are literal symbols that can appear in the inputs to or outputs from the creation rules of a grammar.
terminal symbols
A ___ is a sentential form that has only terminal symbols.
sentence
___ form of a grammar G can be any sequence of grammar symbols (terminal or nonterminal) derived in 0 or more steps from the start symbol of G.
Sentential
__ __, a noted linguist, described four classes of grammars of which two are useful in describing the syntax of programming languages.
Noam Chomsky
The two classes used for describing the syntax of programming languages, that are also used in describing natural languages are ___ & ___.
context free, regular
___ is a natural notation for describing syntax; introduced in 1959 to describe ALGOL 58 and modified for the description of ALGOL 60
BNF, Backus-Naur Form
BNF is a ___ for describing programming languages.
metatlanguage
All things on the RHS combine to make the ___, or ___.
rule, production
The abstractions in a BNF description are often called ___.
nonterminals
The lexemes and tokens of BNF of the rules are called ___.
terminals
A rule is ___ if its LHS appears in its RHS.
recursive
The sentences of the language are generated through a sequence of application of the rules, beginning with a special nonterminal of the grammar called the ___ ___.
start symbol
The sequence of rule applications is called a ___.
derivation
The symbol => is read “___”.
derives
One of the most attractive features of grammars is that they naturally describe the hierarchical syntactic structure, or ___ ___, of the sentences of languages they define.
parse trees
A grammar that generates a sentential form for which there are two or more distinct parse trees is said to be ___.
ambiguous
When a grammar rule has its LHS also appearing at the beginning of its RHS, the rule is said to be ___ ___.
left recursive
Left recursion specifies ___ ___.
left associativity
Left recursion of the rules of grammar causes it to make both addition and multiplication left associative which is in conflict with ___ ___ of ___.
mathematical order of precedence
A grammar rule is ___ ___ if the LHS appears at the right end of the RHS.
right recursive
The ___ ___ of a language is only indirectly related to the meaning of programs during execution; rather, it has to do with the legal forms of programs.
static semantics
___, which are associated with grammar symbols, are similar to variables in the sense that they can have values assigned to them.
Attributes
___ ___ ___, sometimes called semantic functions, are associated with grammar rules and.
Attribute computation functions
___ ___ ___ are used to specify how attribute values are computed.
Attribute computation funcitons
___ ___, which state the static semantic rules of the language, are associated with grammar rules.
Predicate functions
___ ___ are used to pass semantic information up a parse tree
synthesized attributes
___ ___ pass semantic information down and across a parse tree.
inherited attributes
If all attribute values in a parse tree have been computed, the ree is said to be ___ ___.
fully attributed.
___ ___ are synthesized attributes of leaf nodes whose values are determined outside the parse tree.
Intrinsic attributes
___ ___ is the meaning of the expressions, statements and program units of a programming language.
Dynamic semantics
The idea behind ___ ___ is to describe the meaning of a statement or program by specifying the effects of running it on a machine.
operational semantics
Sometimes called ___ ___ semantics; the highest level where the interest is in the final result of the execution of a complete program.
natural operational
At the lowest level, ___ ___ semantics can be used to determine the precise meaning of a program through an examination of the complete sequence of state changes that occur when the program is executed.
structural operational
___ ___ is the most rigorous and most widely known formal method for describing the meaning of programs.
Denotational semantics
In denotational semantics, the domain is called the ___ domain and the range is called the ___ domain.
syntactic, semantic
___ semantics, is the most abstract approach to semantics specification.
Axiomatic
The logical expressions used in axiomatic semantics are called predicates or____.
assertions
___ is the process of repeating items in a self-similar way.
Recursion
___ semantics is meant for describing the meaning of program code.
Dynamic
___ semantics is basically confined to token, or syntax, part of the program and is only indirectly related to the meaning of the program during execution.
Static
___ grammar is a device used to describe more of the structure of a programming language than can be described with a context-free grammar.
Attribute
___ grammar allows certain language rules to be conveniently described, such as type compatibility.
Attribute
The ___ precondition is the least restrictive precondition that will guarantee the validity of the associated post condition.
weakest
An ___ ___ is a method of inferring the truth of one assertion on the basis of the values of other assertions.
inference rule
An ___ is a logical statement that is assumed to be true.
Axiom
The ___ of ___ says that a post-condition can always be weakened and a precondition can always be strengthened.
Rule of Consequence
__ and __ are equivalent ___ that are well suited for the task of describing the syntax of programming languages.
BNF, context-free, metalanguages
An ___ grammar is a descriptive formalism that can describe both the syntax and static semantics of a language.
attribute
What are the three mothods of semantic description
operational, denotational, and exiomatic
___ semantics is a method of describing themeaning of language constructs in terms of their effects on and ideal machine.
Operational
In ___ semantics, mathematical objects are used to represent the meanings of language constructs.
denotational
___ semantics, which is based on formal logic, was devised as a tool for proving the correctness of programs.
Axiomatic