4330 ch3

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

how to distinguish metasymbol and actual symbols in a programming language? name a few ways

" ", ___, font change, font style change (italic)

in EBNF, ( +|- ), what does () means? what does | means?

( ) used to surround things separated by | | is used to for choices

BNF was given credit to 2 guys.

1. John Backus 2. Noam Chomsky

A(X) (attributes of X) are divided into 2 categories.

1. S(X): synthesized 2. I(X): inherited

<assign>--><var>=<expression> what's <assign> what's --> what's <var> what's <expression>

1. category 2. rules or production 3. token or lexeme 4. statement

____ ____ uses the state of the program to describe meaning, whereas ____ _____ uses the state of a machine.

1. denotational semantics 2. operational semantics

A attribute grammar is a GRAMMAR with 2 additional feature.

1. for each grammar symbol: A(X) 2. for reach rule: set of semantic function possibly empty set of predication functions

levels of uses of operational semantics, at highest level, it's called ______ at lowest level, it's called ______

1. natural operational semantics 2. structural operational semantics

what are the 3 ways to describe dynamic semantics?

1. operational semantics 2. denotational semantics 3. axiomatic semantics

why do we want formal semantic definition of a language?

1. programmers want to know 2. compiler writers want to know 3. prove program is correct without testing 4. verify correctness of compiler 5. generate compiler 6. language designers wants to discover ambiguities and inconsistencies.

language can be formally defined in 2 ways.

1. recognition 2. generation

Noam Chomsky come up with 2 classes that are useful for describing the syntax of languages.

1. regular : for lexemes 2. context-free grammar : for whole language

in EBNF, superscript of a number means? superscript of a + means?

1. repeat number times 2. required 1 or more

John Backus's 3 contributions.

1. speed coding 2. Fortran 3. BNF

semantic function for assignment produces _____ semantic function for expression produces ______

1. state 2. value pair

what are the 2 things we need to describe languages?

1. syntax (form) 2. semantic (meaning)

example of static semantic errors

1. type mismatch (assignment, operation such as add) 2. undeclared variable

when using VARMAP on a expression, it produces _______ of the expression. when using VARMAP on statement, it produces _____ of the statement.

1. value 2. state

is <exp>=<exp>+<list> recursive? is it left or right recursive? or is the + operator left or right associative?

1. yes, it is recursive 2. it is left recursive 3. + is left associative

in EBNF for c-based language, instead -->, it uses ____

: drop statement here

what is the most abstract way to describe dynamic semantics which is based on mathematical logic.

Axiomatic semantics

what does BNF stand for

Backus Naur Form

who designed the attribute grammar?

Donald Knuth

_______ removed recursion from BNF

EBNF

A grammar that generates a sentence for which there are 2 or more distinct parse tree is said to be ______

ambiguity

Between a then and its matching else statement, there cannot be _____________ (or unmatched statement)

an if statement without an else.

what is Ma function? and the param?

Mapping of assignment takes in the assignment expression ie x=E where E is the expression. and 2nd param is the state before the assignment.

An ______ is a logical expression that specifies constraints on program variables.

assertion

what is operational semantics?

attempts to describe the meaning of a statement or program by specifying the effects of running it on a machine.

____ _____ functions specify how attribute values are computed. (semantic functions)

attribute computation

an ____ _____ can be used to describe more of the structure of a programming language than is possible with a context-free grammar

attribute grammar

_____ are properties that can have values assign to them

attributes

predicate function is a _____ _____ where {A(x0), ..., A(xn)} U { literal attribute values}

boolean expression

____ ____ values is sometimes called decorating the parse tree.

computing attribute

_____ ______ is formal method for describing the meaning of programs that based on recursive function theory.

denotational semantics

a sentence generation is called ______

derivation

A derivation is allowed to continue only if _________________________

every predicate associated with every nonterminal is TRUE

if all the attribute values in a parse tree have been computed, the tree is said to be ______ _____

fully attributed

A BNF description, or _______, is a collection of rules

grammar

_____ is a generative device?

grammar

the ____ ____ is a method of inferring the truth of one logical statement based on the truth of other logical statements.

inference rule

____ attributes are synthesized attributes of leaf nodes whose values are determined outside the parse tree. (symbol table)

intrinsic

operational semantics lacks precision because ______

it is not based on mathematics.

each rule has a ______ (LHS) and ____ (RHS)

left-hand side right-hand side

_____ ____ is one in which the replaced nonterminal is always the leftmost nonterminal.

leftmost derivation

strings of a language are called

lexemes

in EBNF { rule }, what does { } means?

loop, 0 or more times

what is VARMAP? and what are the parameters for this VARMAP function?

mapping function of variable and state are the params.

what is the M_dec function? param?

mapping of a decimal value takes in the decimal value

what is M_b function? param?

mapping of boolean test function param: condition and the state of the variables

what is the M_l function? and the param?

mapping of logical pretest loop param: the while loop condition and the state before entering the loop (state of all variables involved)

what is M_sl? and the param?

mapping of statement list param: loop body (stmts) and the state before entering the loop.

A _______ is a language that is used to describe another language.

metalanguage

the symbols used specifically for BNF are called______

metasymbols

what language's international standard used denotational semantics?

modula-2

in EBNF for c-based language, instead of use <nonterminal>, it uses

nonterminal

abstractions are called _____ _____, or simply ________

nonterminal symbols nonterminals

_____ ____ is to describe the meaning of a statement or program by specifying the effects of running it on a machine.

operational semantic

in EBNF [ rule ], what does [ ] mean?

optional, 0 or more

how to does state of program be represented in the denotational semantics?

order pairs of (variable, its_value)

graphical representation of a derivation is called ______

parse tree

______ categorize lexemes based on type and precedence

parser

what are inherited attributes used for?

pass semantic information DOWN and ACROSS a tree

a _____ is an assertion that describes new constraints on program variables AFTER the execution of a statement.

postcondition

what is one of the disadvantage to use EBNF instead of BNF?

precedence information is lost in EBNF

a _______ is an assertion that describe any necessary constraints on program variables BEFORE the execution of a statement.

precondition

____ ____ state the static semantic rules of the language (rules we are trying to enforce)

predicate functions

what is axiomatic semantics is useful for?

proving program correct

Given a context-free grammar (BNF), a _____ for the language generated by the grammar can be algorithmically constructed

recognizer

syntax parser in a compiler is like the _______, it has the rules built in

recognizer

a rule is _____ if its LHS appears in its RHS.

recursive

what branch of math is denotational semantics based on?

recursive function theory

how to avoid circularity when computing for I(Xj)??

restrict so that the function is I(Xj)=F(X0, .... , X(j-1))

assertions are tested at ________

run time

in a well-designed programming language, ____ should follow directly from _____

semantics, syntax

The strings of a language are called _____ or statements?

sentences

each string in a derivation, including the start symbol, is called a _______ ___

sentential form

the demotational semantics of a program could be defined in terms of ____ ____ in an ideal computer.

state change

____ _____ rules of a language are not part of the language's syntax.

static semantic

attribute grammar will detect ____ ____ errors

static semantic

in EBNF for c-based language, instead of [ ] for optional, it uses _____

subscript opt

in denotational semantics, the domain is called the ____ domain and the range is called ____ domain

syntactic semantic

lexemes and tokens are called _____ ____ or simply ______

terminal symbols terminals

what is syntax?

the form of its expressions, statements, and program units.

what is semantics?

the meaning of those expressions, statements, and program units

what does VARMAP output?

the value of the variable in a given state

what are synthesized attributes used for?

to pass semantic information UP a parse tree

a _____ of a language is a category of its lexemes

token

what is the special value used when th e variable's value in a state is currently undefined?

undef

the ____ ______ is the least restrictive precondition that will guarantee the validity of the associated prostcondition

weakest precondition

static semantic can be detected ______

without running the program, at compile time

yacc stands for

yet another compiler compiler

preconditions and postconditions are placed inside of ____ and placed before or after the assignment statement.

{ }

the first and most significant use of formal operational semantics was to describe the semantics of ________.

PL/I

for a rule X0 --> X1 ... Xn. how do we compute for S(X0)?

S(X0)=F(A(X1), ... , A(Xn)) where F is the semantic function (attribute computation function)

who is Donald Knuth?

TAOCP

what does state of a program in denotational semantics consist?

values of program's variables

for a rule x0 --> x1 ... xn and xj, 1<=j<=n, is computed how do we compute for I(Xj)?

I(xj)=F(A(x0), ... , A(xn)) where F is the semantic function (attribute computation function)

in EBNF for c-based language, instead of using ( operator | operator | operator ... ), it uses

LHS: one of = *= /= %= .......... ***list***

what is Me function? and the param of this function is?

Mapping of Expression takes in E (expr) and s (state)


Ensembles d'études connexes

Biology - Unit 1 - Taxonomy: Key to Organization: Concept of Species

View Set

General Psychology Test 1 - Lamar (Barclay)

View Set

H- Practice test questions- psych and mental

View Set

Penny Review Chapter 13: Testicular/ Male Pelvis

View Set

Human Resource Management Exam 1 Question Study Guide

View Set