Q6 : Define a left-recursive grammar rule.
A
: In the formal language theory of computer science, left recursion is a special case of recursion. In terms of context-free grammar, a non-terminal
r
is left-recursive if the left-most
symbol in any of r
’s productions (‘alternatives’) either immediately
(direct/immediate left-recursive) or through some other non-terminal
definitions (indirect/hidden left-recursive) rewrites to r
again.
Q7 : What three extensions are common to most
EBNFs?
A
: The first of these denotes an optional part of
an RHS, which is delimited by brackets.
The second extension is the use of braces in an RHS to indicate that the enclosed part can be repeated
indefinitely or left out altogether. The third common extension deals with multiple-choice options.
Q8 : Distinguish between static and dynamic semantics.
A : We can distinguish between the static
(external) world, representing the program text, which does not change, and the
dynamic (internal) world, representing the hardware at run-time, which is where
it all happens.
*Static objects
are constructs (identifiers, statements, expressions etc.) in the text of the
program, and have no meaningful existence beyond compile-time.
*Dynamic objects are (instances of) values, locations and the like, which live and move and have their being inside the computer at run-time.
*Dynamic objects are (instances of) values, locations and the like, which live and move and have their being inside the computer at run-time.
Q9 : What purpose do predicates serve in an attribute grammar?
A : The use of predicates functions is to
state the static semantic rules of the language.
Q10 :
What is the difference between a synthesized and an inherited attribute?
A
: The synthesized attributes are
the result of the attribute evaluation rules, and may also use the values of
the inherited attributes. The inherited attributes are passed down from
parent nodes. In some approaches, synthesized attributes are used to pass
semantic information up the parse tree, while inherited attributes help pass
semantic information down it.
For instance, when constructing a language translation tool, such
as a compiler, it may be used to assign semantic values to syntax
constructions. Also, it is possible to validate semantic checks associated with
a grammar, representing the rules of a language not explicitly imparted by the
syntax.
No comments:
Post a Comment