Lecture Note 6 Flashcards
(25 cards)
What is specification of programming
a programming language specification (or standard or definition) is a documentation artifact that defines a programming language so that users and implementors (language translators) can agree on what programs in that language mean.
What are the main translator for programming language translations
The assembler
The compiler
The interpereter
Describe syntactic analysis
The syntactic analyser(parser) costruct a derivation tree for the list
Describe semantic analysis
The derivation tree is subjected to checks of the language’s various context-based constraints.
Descirbe Code optimization
Optimizes the code obtained from the preceding phases
Describe code generation
Generates the final object code
What is an interpreter
An Interpreter is also a program that translates high-level source code into executable code.
What are the two parts of language specification
The syntax of a programming language is the part of the language definition that says what programs look like; their form and structure.
The semantics of a programming language is the part of the language definition that says what programs do; their behavior and meaning.
The syntax of a programming language is usually described using a combination of two components??
i. A regular expression describing its lexemes,
ii. A context-free grammar which describes how lexemes may be combined to form a syntactically correct program.
What are forms of programming language specification
i. Formal Language Specification
ii) ii. A description of the behavior of a compiler (sometimes called “translator”) for the language (e.g., the C++ language and FORTRAN).
iii)A model implementation, sometimes written in the language being specified
What is programming language translation
Programming language translation is the conversion of statements written in one language to statements in another language e.g converting assembly language to machine code.
What is a compiler
A compiler translates a program written in one high level language, the source code into another language which is the object code.
What is an assembler
The assembler translates mnemonic operation codes into machine code, and symbolic addresses into machine addresses
What is documentation
Documentation is any communicable material that is used to describe, explain or instruct regarding some attributes of an object or system such as its parts, assembly, installation, maintenance and use.
Compilers are organized into three stages:
A front end
An optimizers
A back end
Object codes to source codes is done in two parts??
Analysis and synthesis
Types of assembler
Load and Go Assembler: Load-and-go assembler generates their object code in memory for immediate execution
One-Pass Assemblers : One-Pass Assemblers generate their object code in memory for immediate execution just like loadand-go assemblers.
Two Pass Assemblers: Two pass assembler translate instructions by converting labels to addresses, generating values defined by BYTE and WORD, processing the directives not done in pass one and then writing the object code to output device
Mention the three types of translator
assemblers, interpreters and Compilers
What are ways in which programming semantics can be described
Natural language: Description by human natural language
Formal semantics: Description by mathematics
Reference implementation: Description by computer program
Test suites: Descriptoin by examples of programs and their expected behaviours
Mention the two parts involved in interpretion and describe them
a parser and an evaluator
.The parser breaks the program into language components to form a parse tree.
The evaluator then uses the parse tree to execute the program.
What is the job of each stages
The front end is responsible for understanding the program.
The optimizer improves the intermediate representation to increase the speed or reduce the size of the executable which is ultimately produced by the compiler.
The back end converts the optimized intermediate representation into the output language of the compiler.
Phases of compilation
Lexical analysis:
Syntactic analysis
Semantic analysis
Code optimization
Code generation
Describe lexical analysis
The aim of lexical analysis is to read the symbols (characters) forming the program sequentially from the input and to group these symbols into meaningful logical units, which we call tokens.
Mention advantages of an interpreter
- Good at locating errors in programs
- Debugging is easier since the interpreter stops when it encounters an error.
- If an error is deducted there is no need to retranslate the whole program