Semantic analysis Flashcards
what grammar symbols associated with?
attributes
how are these attributes evaluated?
semantic rules
Evaluation of these semantic rules depends on :
Generate intermediate codes put information on the symbol table perform type checking issues error messages perform almost any activities
A_________checks the source program for semantic errors
semantic analyzer
A semantic analyzer collects information for ____________
Code Generation
________________ is an important part of the semantic analyzer
Type-checking
SDT
Syntax directed translation
how are attributes stored in SDT?
The attributes are attached to the grammar symbols
How are the values of the attributes calculated?
Semantic rules associated with grammar productions
The flow of the semantic compiler
input string->parse tree-> dependency graph->semantic rule evaluation order
Attribute values may represent :
Numbers strings memory locations A data type for checking expressions scoping information for declaration A data type for checking expressions scoping information for local declarations Intermediate program representations
Name two ways to represent semantic rules:
Syntax directed definitions.
& Translation Schemes
SDD are ____ level
Translation schemes are closer to an _____________
higher implementation
Explain SDD
syntax-directed definitions
Each production of A->alpha
is associated with the set of semantic rules
b=f(c1,c2,…….cn) where f is a function
b=> is synthesized attribute of A and c1,c2,c3,,,,,,,,,,cn are attributes of the grammar symbols in the production
b=>inherited attribute,one of the grammar symbols in aplha are attributes of the grammar symbols in the production (A-> alpha)
in either of the cases, we say b depends on c1,c2,c3,,,,,,,,,,,ck.
what are Synthesized attributes
Synthesized attributes are the depends only on the attributes of the children
They are the most common attribute type
Synthesized attributes never take values from their parents nodes or any sibling nodes
the non terminal concerned must be in the head of the production
Terminals have synthesised attributes which are the lexical values