Preview

Rock

Good Essays
Open Document
Open Document
1053 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Rock
COP4020
Programming
Languages
Compiler phases
Prof. Xin Yuan

Overview


Compiler phases









10/2/2013

Lexical analysis
Syntax analysis
Semantic analysis
Intermediate (machine-independent) code generation
Intermediate code optimization
Target (machine-dependent) code generation
Target code optimization

COP4020 Spring 2013

2

Source program with macros

A typical compilation process
Preprocessor
Source program

Compiler
Target assembly program

Try g++ with –v, -E, -S flags on linprog.

assembler
Relocatable machine code

linker
Absolute machine code

10/2/2013

COP4020 Spring 2013

3



What is a compiler?


A program that reads a program written in one language
(source language) and translates it into an equivalent program in another language (target language).


Two components





Understand the program (make sure it is correct)
Rewrite the program in the target language.

Traditionally, the source language is a high level language and the target language is a low level language (machine code). Source program compiler

Target program Error message
10/2/2013

COP4020 Spring 2013

4

Compilation Phases and Passes


Compilation of a program proceeds through a fixed series of phases






Each phase use an (intermediate) form of the program produced by an earlier phase
Subsequent phases operate on lower-level code representations

Each phase may consist of a number of passes over the program representation




10/2/2013

Pascal, FORTRAN, C languages designed for one-pass compilation, which explains the need for function prototypes
Single-pass compilers need less memory to operate
Java and ADA are multi-pass

COP4020 Spring 2013

5

Compiler Front- and Back-end
Abstract syntax tree or other intermediate form

Source program (character stream)

Scanner
(lexical analysis)

MachineIndependent Code

You May Also Find These Documents Helpful

  • Satisfactory Essays

    The second category of fault changes individual instructions in the text segment. These faults are intended to approximate the assembly-level manifestation of real C-level programming…

    • 285 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    Service Request Sr Rm 004

    • 1582 Words
    • 7 Pages

    This phase requires the coordination and cooperation of many people. The system analyst cannot conduct all the work alone. The first step involves coding. Coding is process of converting writing computer language that tells the system the commands to perform when certain commands are given. As the coding process being, the process of testing is also taking place as well. When coding is written, it must pass validation or the computer will not understand the language and the expect program will not perform to standard. Many strategies are available for testing validation; the size of the system dictates which is best. Throughout the system development life cycle, software testing was taking place after certain events to ensure the preliminary creation was on track. During analysis the overall test plan was developed. In the design phase, the unit test, integration test plan, and a system test plan was developed. Inspections are formal group activities that perform manually to find obvious errors such as syntax and…

    • 1582 Words
    • 7 Pages
    Better Essays
  • Good Essays

    pt1420 exam review

    • 738 Words
    • 3 Pages

    What is used to translate high level language programs to machine language (or machine code)? Compiler…

    • 738 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Rock the Ages

    • 10565 Words
    • 43 Pages

    Number of Schedules K-1. Attach one for each person who was a partner at any time during the tax year…

    • 10565 Words
    • 43 Pages
    Satisfactory Essays
  • Powerful Essays

    EAS230Syllabus

    • 1748 Words
    • 8 Pages

    C++ programming: editing, compiling, user I/O, variables (ints, doubles, char, strings, booleans), loops, decisions, functions, pointers, arrays, tables, databases, sorting.…

    • 1748 Words
    • 8 Pages
    Powerful Essays
  • Better Essays

    Rock-N-Roll Part 1

    • 1248 Words
    • 5 Pages

    The Negotiators are a rock and roll band whose contract is up for renewal with their current publisher, R-n-R Label. University of Phoenix MGT557 class Team B role-played the characters Jimmy, Tinny, and Janice of The Negotiators, and an agent from the firm Agent-town to understand the complexities of how agents, constituencies, and audiences communicate during negotiations. The authors describe their experiences with how The Negotiators agreed on increase percentages, how the band members managed their agent, how Agent-town managed the constituencies and audiences, and how all parties agreed to an increase percentage.…

    • 1248 Words
    • 5 Pages
    Better Essays
  • Good Essays

    Rock "N" Rap

    • 597 Words
    • 3 Pages

    a. Find at least three combinations of rock and rap CDs that would give the company a profit of $120,000, and mark these points in one color on your graph. (The combinations do not have to be in the feasible region.) Profit=x20,000+y30,000…

    • 597 Words
    • 3 Pages
    Good Essays
  • Good Essays

    The Rolling Stones were a big part of early Rock N’ Roll. They pushed the envelope more than any other band of their time. Paint it black which was released in 1966 is a very good example of the Rolling Stones not caring attitude. The Stones experimented a lot with different instruments, and gave their music a distinct sound.…

    • 580 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Now, the way people communicate with computers is not directly by the language that the computer understands (machine language), but instead a set of instructions have to be written in a different language that specializes in writing programs such as C++ or Visual Basic. These types of languages at the same time have to be translated into machine language either through compilers or interpreters. Compilers translate all the source codes (C++, Visual Basic, etc. language) in a program to machine language before it’s executed. Then after that the compiled program (in this case machine language) is executed by the Central Process Unit (CPU). At this time the machine language can be used every time the program is run unless the source code changes, in which then the machine language should be recompiled. Like compilers, interpreters also translate the source code into machine language, but they only translate each line of the code as it is executed. Difference is also that every time the program is run each line must be translated again. Which in comparison to compilers, interpreters are much…

    • 322 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Lab 3 Student

    • 1264 Words
    • 7 Pages

    Step 3: Write the exact output you would expect from the following line of code if the user of the program enters “Nolan Owens”. (Reference: Displaying Items, page 40 – 41).…

    • 1264 Words
    • 7 Pages
    Satisfactory Essays
  • Better Essays

    Essay On Rockabilly

    • 994 Words
    • 4 Pages

    Rockabilly is one of the oldest styles of rock and roll. It blends rock and roll with the music genre of bluegrass and country music, with the rhythm of blues music. It can be known for “hillbilly” music, but with the influence it has on today's music, it would not be labeled for “hillbillies”, and yet it had the beat of swing. In the book, “The Appearance of the Electric Bass Guitar: A Rockabilly Perspective” written by Roy C. Brewer, He writes about the different basses that were used in rockabilly which gave the genres sound. He explains how in the early 1950s, rockabilly was popular due to the fact they were one of the first genres to introduce rock…

    • 994 Words
    • 4 Pages
    Better Essays
  • Good Essays

    Rockin' 3 Billy Goats

    • 890 Words
    • 4 Pages

    Are you ready?! One of my favourite stories and it actually comes from the country called Norway which is way way up North from Scandinavia and its very cooooolllddd..... Can you imagine how it feels to be cold coz’ i know it’s not very cold right now. So can you show me how cold feels? COOoolldd... VERY Good! Now there in Norway they do have summer time and when they do... They have lots and tons of green green grass. And you’ll probably recognize my friends in the story.…

    • 890 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Punk Rock

    • 501 Words
    • 3 Pages

    American exceptionalism is a pivotal concept within the American culture. Stemming from a revolution, this theory shaped a new way of thinking within the United States that seemed far different from many other cultures. Seymour Martin Lipset used this concept to explain, “why the United States is the only industrialized country which does not have a significant socialist movement or Labor party.” This essentially explains why America is extraordinary. Punk personifies American exceptionalism with its distinct lifestyle to be different from the norm, and is surrounded by independent self-governing thinkers. The United States didn’t become what it is today because of law abiding and passive citizens. This is also a main reason why Punk Rock became so popular in America, and has stayed relevant to teens and young adults all over the world. People began to thrive on understanding the history of this nation, and take pride in the originality of our constitution, and way of life. Punk Rock adds another chapter in the long list of independent concepts and ideas within the American Culture.…

    • 501 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    Rock on

    • 2584 Words
    • 11 Pages

    For most anticipated new releases, please see The Numbers' Most Anticipated Movies. Release Date Movie Distributor Gross to date Trailer May, 18 Louder Than A Bomb (limited) Balcony Releasing $7,000 May, 20 Pirates of the Caribbean: On Stranger Tides Walt Disney Pictures $113,595,287 Trailer…

    • 2584 Words
    • 11 Pages
    Powerful Essays
  • Good Essays

    Compiler Design

    • 7419 Words
    • 30 Pages

    DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING 2007-2008, EVEN SEMESTER PRINCIPLES OF COMPILER DESIGN-CS1352 TWO-MARK QUESTIONS 1. What does translator mean? A translator is a program that takes a input program on one programming language (source language) and produces output in another language (object language or target language). 2. What are the phases of a compiler? • Lexical analysis phase or scanning phase • Syntax analysis phase • Intermediate code generation • Code optimization • Code generation 3. What is the role of lexical analysis phase? Lexical analyzer reads the source program one character at a time, and grouped into a sequence of atomic units called tokens. Identifiers, keywords, constants, operators and punctuation symbols such as commas, parenthesis, are typical tokens. 4. Define lexeme? The character sequence forming a token is called lexeme for the token. 5. What are the two functions of parser?  It checks the tokens appearing in its input, which is output of the lexical analyzer.  It involves grouping the tokens of source program into grammatical phrases that are used by the compiler to synthesize the output. Usually grammatical phrases of the source program are represented by tree like structure called parse tree. 6. Mention the role of semantic analysis? Semantic analysis checks the source program for semantic errors and gathers information for the subsequent code-generation phase. It uses hierarchical structure to identify the operators and operands of expressions and statements. An important component of semantic analysis is type checking .In type checking the compiler checks that each operator has operands that are permitted by the source language specification.…

    • 7419 Words
    • 30 Pages
    Good Essays

Related Topics