compilers i cns 3490. history wires wires machine language machine language ffba ffba no translation...

Download Compilers I CNS 3490. History Wires Wires Machine Language Machine Language FFBA FFBA No Translation necessary No Translation necessary Assembly Language

Post on 20-Jan-2016




0 download

Embed Size (px)


  • Compilers ICNS 3490

  • HistoryWiresMachine LanguageFFBANo Translation necessaryAssembly LanguageMov r1, 0xFBAssemblerCompilersX = 2Fortran (1954-1957)

  • Related ProgramsInterpretersExecutes source program immediately rather than generating object code.LinkersCollects separately compiled code into one executableLoadersOften addresses need to be relocated in order for a program to be loaded into a specific spot in memoryPreprocessorOutput = Source Code

  • Related ProgramsEditorsDebuggersProfilersProject ManagersExample: rcs (revision control system)IDE Integrated development environments

  • Translation ProcessParserCode GeneratorOptimizerScannersource codetokenssyntax treeexecutableexecutableLiteral TableSymbol TableError Handler

  • The ScannerPerforms Lexical AnalysisExamplea[index] = 4 + 2Would be translated intoaidentifier[left bracketindexidentifier]right bracket=assignment4number+plus sign2number

  • The ParserPerforms Syntax AnalysisIt determines the syntax of the source codeTurn the expression: a[index] = 4 + 2 into a parse tree

  • Code GeneratorTakes an annotated parse tree and turns it into machine code or assembly language.For exampleThe parse Tree for a[index] = 6 could be turned into Mov r0, indexMul r0, 2Mov r1, &aAdd r1, r0Mov *r1, 6

  • Major Data Structures in a CompilerTokensSymbolic representation of one lexical component (one symbol)Syntax TreeRepresents the structure of the source code being parsedSymbol TableCollection of all of the variables, class names etc.Literal TableCollection of all of the literal values (especially strings)

  • Error HandlingAny good compiler should respond well to static or (compile-time) errors.The compilation process should terminate gracefullyIdeally, only one error should be reported for each actual error in the source code.


View more >