Compiler Theory Basics
Fundamental concepts of how compilers work, including lexical analysis, parsing, and code generation
- Category
- Computer Programming
- Level
- intermediate
- Languages
- en → en
- Cards
- 47
- Markdown
- Compiler Theory Basics (.md)
Flashcards (47)
| # | Front (Term / Question) | Back (Definition / Answer) | Example | Multiple-Choice Options |
|---|---|---|---|---|
| 1 | What is semantic analysis? | Semantic analysis is the phase of a compiler that checks for semantic consistency and correctness of the parsed code, ensuring that it makes logical sense. | ||
| 2 | What is a static analysis? | Static analysis is the examination of code without executing it, often used to find bugs, vulnerabilities, and enforce coding standards. | ||
| 3 | What is a compiler optimization technique? | Compiler optimization techniques include loop unrolling, constant folding, dead code elimination, and inlining functions to improve performance. | ||
| 4 | What is lexical analysis? | Lexical analysis is the first phase of a compiler that converts a sequence of characters from the source code into tokens. | ||
| 5 | What is a compiler construction tool? | Compiler construction tools are software tools that assist in building compilers, such as lexers, parsers, and code generators. | ||
| 6 | What is a semantic error? | A semantic error is a logical error in the code that does not violate syntax rules but leads to incorrect behavior or results. | ||
| 7 | What is a regular expression? | A regular expression is a sequence of characters that defines a search pattern, commonly used for specifying tokens in lexical analysis. | ||
| 8 | What is a token in compiler theory? | A token is a categorized block of text, representing a basic element of the source code, such as keywords, identifiers, operators, and literals. | ||
| 9 | What is a symbol table? | A symbol table is a data structure used by a compiler to store information about variables, functions, objects, and their attributes. | ||
| 10 | What is code generation? | Code generation is the final phase of a compiler where the optimized intermediate code is translated into machine code or assembly language. | ||
| 11 | What is a three-address code? | Three-address code is an intermediate representation that uses at most three operands per instruction, simplifying code generation and optimization. | ||
| 12 | What is an abstract syntax tree (AST)? | An abstract syntax tree is a tree representation of the abstract syntactic structure of source code, abstracting away certain syntax details. | ||
| 13 | What is register allocation? | Register allocation is the process of assigning a limited number of CPU registers to variables in a program to optimize performance. | ||
| 14 | What is a front-end optimization? | Front-end optimization involves improving the source code or intermediate representation before code generation, such as constant propagation. | ||
| 15 | What is a control flow graph? | A control flow graph is a representation of all paths that might be traversed through a program during its execution, used in optimization and analysis. | ||
| 16 | What is machine code? | Machine code is a low-level code that is directly executed by a computer's CPU, consisting of binary instructions specific to the architecture. | ||
| 17 | What is a context-free grammar? | A context-free grammar is a formal grammar that consists of a set of production rules used to define the syntax of a programming language. | ||
| 18 | What is a grammar ambiguity? | Grammar ambiguity occurs when a single input string can be generated by two or more different parse trees, leading to multiple interpretations. | ||
| 19 | What is a finite automaton? | A finite automaton is a theoretical model of computation used to represent and recognize patterns in input strings, often used in lexical analysis. | ||
| 20 | What is a compiler back-end? | The back-end of a compiler includes optimization and code generation, focusing on producing efficient machine code. | ||
| 21 | What is a compiler optimization phase? | The compiler optimization phase is where the intermediate code is improved for performance, often involving various optimization techniques. | ||
| 22 | What is a compiler? | A compiler is a program that translates source code written in a high-level programming language into machine code or intermediate code. | ||
| 23 | What is lex? | Lex is a tool used to generate lexical analyzers (lexers) from regular expressions. | ||
| 24 | What is a high-level programming language? | A high-level programming language is a programming language that is more abstract and easier for humans to read and write, such as Python or Java. | ||
| 25 | What is a compiler front-end? | The front-end of a compiler includes the phases of lexical analysis, syntax analysis, and semantic analysis, focusing on understanding the source code. | ||
| 26 | What is dynamic analysis? | Dynamic analysis involves executing the program and monitoring its behavior to identify issues such as memory leaks or runtime errors. | ||
| 27 | What is a loader? | A loader is a program that loads an executable file into memory for execution, preparing it for the operating system to run. | ||
| 28 | What is a shift-reduce parser? | A shift-reduce parser is a type of bottom-up parser that uses a stack to hold symbols and applies shift and reduce operations to parse input. | ||
| 29 | What is LL parsing? | LL parsing is a top-down parsing technique that reads input from left to right and constructs a leftmost derivation of the sentence. | ||
| 30 | What is a parse tree? | A parse tree is a tree representation that shows the syntactic structure of the source code based on the grammar of the language. | ||
| 31 | What is a linker? | A linker is a tool that combines multiple object files generated by a compiler into a single executable program, resolving references between them. | ||
| 32 | What is dead code? | Dead code refers to parts of the code that are never executed or used, which can be removed during optimization without affecting program behavior. | ||
| 33 | What is inlining? | Inlining is an optimization technique where function calls are replaced with the actual function code to reduce overhead and improve performance. | ||
| 34 | What role does a lexer play in a compiler? | A lexer, or lexical analyzer, processes the input source code and generates tokens for the next phase of the compiler. | ||
| 35 | What is syntax analysis? | Syntax analysis, or parsing, is the phase of a compiler that checks the tokens against the grammatical rules of the programming language. | ||
| 36 | What are the main phases of a compiler? | The main phases of a compiler are lexical analysis, syntax analysis, semantic analysis, optimization, and code generation. | ||
| 37 | What is a back-end optimization? | Back-end optimization focuses on improving the efficiency of the generated machine code, such as instruction scheduling and register allocation. | ||
| 38 | What is a parse table? | A parse table is a data structure used by parsers to guide the parsing process, indicating which production rules to apply based on the current input symbol. | ||
| 39 | What is intermediate code? | Intermediate code is a low-level representation of the source code that is easier to optimize and translate into machine code. | ||
| 40 | What is type checking? | Type checking is a process during semantic analysis that verifies that operations in the code are performed on compatible data types. | ||
| 41 | What is yacc? | Yacc (Yet Another Compiler Compiler) is a tool used to generate parsers based on a given context-free grammar. | ||
| 42 | What is code optimization? | Code optimization is the process of improving the intermediate code to make it run more efficiently, reducing resource usage and execution time. | ||
| 43 | What is a syntax-directed translation? | Syntax-directed translation is a method of translating source code into intermediate code based on the structure of the parse tree. | ||
| 44 | What is a language specification? | A language specification is a formal document that defines the syntax, semantics, and behavior of a programming language. | ||
| 45 | What is a syntax error? | A syntax error is a mistake in the source code that violates the grammatical rules of the programming language, preventing successful parsing. | ||
| 46 | What is LR parsing? | LR parsing is a bottom-up parsing technique that reads input from left to right and constructs a rightmost derivation in reverse. | ||
| 47 | What is a programming language? | A programming language is a formal set of instructions that can be used to produce various kinds of output, including software applications. |