Compiler

cosmos 20th August 2019 at 6:46pm
Programming

See also Formal language, Programming language, Assembly (programming language)

Compiler design lectures

Book

https://github.com/aalhour/awesome-compilershttp://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdfhttps://osmosianplainenglishprogramming.blog/

Context-free grammars and compilers: video

Full compilation process

The compilation process usually involves these steps:

HLL

Pre-processor

Pure HLL

Compiler

Assembly

Assembler

M/C (relocatable)

Loader/linker

Absolute machine code

Compiler steps

HLL

Lexical analysis

Stream of tokens

Syntax analysis (Parsing)

Parse tree

Semantic analysis

Parse tree (semantically verified)

Intermediate code generator

Three adress code

Code optimizer

Target code generator

Assembly code.

All these steps will also make use of a symbol table manager, and they communicate with an Error handler

Example

Compiler front-end

Lexical analsys

Tool: lex

Converts string of characters into string of tokens, using, for instance a Regular expression. For instance in an anglebraic expression, all things that match [[a-z]\d]+, where [a-z] is a letter, and \d is a digit, are converted into an "identifier" token, which is a fundamental unit in the grammar.

Lecture

Syntax analysis (Parsing)

Tool: yacc

Create parse tree according to rules of some Grammar

Lecture

Semantic anlysis

  • Type checking

Intermediate code generator

Compiler back-end

Code optimization

Target code generator