Study Guide Primary Topics Flashcards
What is semantic analysis?
The phase of the compiler that checks the source program for semantic consistency with the language definition.
What is a synthesized attribute?
Of a non terminal A at a parse tree node N is directly defined by a semantic rule associated with production at N (node value determined from child node(s))
What is an inherited attribute?
For a nonterminal B at a parse-tree node N is defined by a semantic rule associated with the production at the parent of N (node gets value from parent/sibling nodes)
What are attribute grammars?
Syntax-defined definitions whose semantic rules have no side effects.
What is a side effect?
Any action or rule application that results in an effect, such as printing or evaluating a value.
What is the purpose of the semantic analyzer?
Checking and verifying data types. Last chance to weed out inconsistent/incorrect programs at the front end.
What are the jobs of the semantic analyzer (know at least 3)
- Type checking
- Type coercion/conversion
- Variable deceleration and use
- Access control and scope checking
- Function parameter count and consistency
- Store discovered/synthesized/inherited attributes in the IR or symbol table
What is intermediate representation?
Data structure used by compiler to represent source code.
What are data types?
A collection or grouping of data values and the operations that can be performed on them.
What is a type system?
feature of a language, the collection of all its data types, data operations, and rules for how types can be combined or coerced
Language Type: Static
Type-checking performed at compile time.
Language Type: Dynamic
Type checking performed at run time
Language Type: Explicit
Types declared in source code
Language Type: Implicit
Type checking in compiler
Language Type: Safe
Cannot violate rules and structure of type system