Language Translators: Full Compilers, Linkers, Interpreters, and Hybrid Implementations Flashcards
List the 4 fundamental phases of a typical compiler
- lexical analyzer
- syntatic analyzer
- semantic analyzer & intermediate code generator
- final code generator
T/F: C++ and Ada are not fully compiled languages.
False, they are fully compiled
What does the Lexical Analyzer do?
- Breaks the character stream into “words” called lexemes
- categorizes lexemes by token type
- detects lexical errors
list some typical tokens
- Identifiers
- reserved words
- numeric literals
What are tokens equivalent to?
English parts of speech like verbs or nouns.
What are lexical errors?
Sequences of characters that doesn’t represent valid tokens
give an example of a lexical error
A question mark outside of a comment, character, or string literal is usually an error
What does the syntactic analyzer do? (3)
- verifies syntax
- detects errors
- generates the parse tree
T/F: Most compilation errors are syntax errors
True
What is a typical example of a syntax error in most languages?
a missing semi-colon “;”
What is a parse tree used for? what is this approach generally referred to as?
Intermediate code generation
syntax-directed translation.
What does the Semantic Analyzer do?
Detects static semantic errors
What are the most common semantic errors?
Mismatching types, like a non-boolean expression in an if statement.
What does the intermediate code generator do?
Generates intermediate code.
What is intermediate code?
a machine-independent low-level language that has no nested expressions or statements
What phase is included in production compilers in regards to the semantic analyzer and intermediate code generator?
Optimizer