chapter3 language translation issues l.
Skip this Video
Loading SlideShow in 5 Seconds..
Chapter3: Language Translation issues PowerPoint Presentation
Download Presentation
Chapter3: Language Translation issues

Loading in 2 Seconds...

play fullscreen
1 / 15

Chapter3: Language Translation issues - PowerPoint PPT Presentation

  • Uploaded on

Chapter3: Language Translation issues. Programming language Syntax Key criteria concerning syntax Basic syntactic concepts Overall Program-Subprogram structure Stages in Translation Analysis of the source program Synthesis of the object program Bootstrapping. What is Syntax.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Chapter3: Language Translation issues' - lark

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
chapter3 language translation issues
Chapter3: Language Translation issues
  • Programming language Syntax
    • Key criteria concerning syntax
    • Basic syntactic concepts
    • Overall Program-Subprogram structure
  • Stages in Translation
    • Analysis of the source program
    • Synthesis of the object program
    • Bootstrapping
what is syntax
What is Syntax

The syntax of a programming language describes the structure of programs without any consideration of their meaning.

key criteria concerning syntax
Key criteria concerning syntax

Readability – a program is considered readable if the algorithm and data are apparent by inspection.

Writeability – ease of writing the program.

Verifiability – ability to prove program correctness (very difficult issue)

Translatability – ease of translating the program into executable form.

Lack of ambiguity – the syntax should provide for ease of avoiding ambiguous structures

basic syntactic concepts
Basic syntactic concepts
  • Character set – The alphabet of the language. Several different character sets are used: ASCII, EBCIDIC, Unicode
  • Identifiers – strings of letters of digits usually beginning with a letter
  • Operator Symbols – +-*/
  • Keywords or Reserved Words – used as a fixed part of the syntax of a statement
basic syntactic concepts5
Basic syntactic concepts
  • Noise words – optional words inserted into statements to improve readability
  • Comments – used to improve readability and for documentation purposes. Comments are usually enclosed by special markers
  • Blanks – rules vary from language to language. Usually only significant in literal strings
basic syntactic concepts6
Basic syntactic concepts
  • Delimiters – used to denote the beginning and the end of syntactic constructs
  • Expressions – functions that access data objects in a program and return a value
  • Statements – these are the sentences of the language, they describe a task to be performed
overall program subprogram structure
Overall Program-Subprogram Structure

Separate subprogram definitions: Separate compilation, linked at load time E.G. C/C++

Separate data definitions:General approach in OOP.

Nested subprogram definitions: Subprogram definitions appear as declarations within the main program or other subprograms. E.G. Pascal

overall program subprogram structure8
Overall Program-Subprogram Structure

Separate interface definitions:

C/C++ header files

Data descriptions separated from executable statements. A centralized data division contains all data declarations. E.G. COBOL

Unseparated subprogram definitions: No syntactic distinction between main program statements and subprogram statements.


stages in translation
Stages in Translation
  • Analysis of the source program
  • Synthesis of the object program
  • Bootstrapping
analysis of the source program
Analysis of the source program
  • Lexical analysis (scanning) – identifying the tokens of the programming language: keywords, identifiers, constants and other symbols
  • In the program
  • void main()
  • { printf("Hello World\n"); }
  • the tokens are
  • void, main, (, ), {, printf, (, "Hello World\n", ), ;, }
syntactic and semantic analysis
Syntactic and semantic analysis
  • Syntactic analysis (parsing) – determining the structure of the program, as defined by the language grammar.
  • Semantic analysis - assigning meaning to the syntactic structures
  • Example: int variable1;
  • meaning: 4 bytes for variable1 , a specific set of operations to be used with variable1.
basic semantic tasks
Basic semantic tasks
  • The semantic analysis builds the bridge between analysis and synthesis.
      • Basic semantic tasks:
    • Symbol–table maintenance
    • Insertion of implicit information
    • Error detection
    • Macro processing
  • Result : an internal representation, suitable to be used for code optimization and code generation.
synthesis of the object program
Synthesis of the object program

Three main steps:

Optimization - Removing redundant statements

Code generation - generating assembler commands with relative memory addresses for the separate program modules - obtaining the object code of the program.

Linking and loading - resolving the addresses - obtaining the executable code of the program.

optimization example
Optimization example

Assembler code not optimized:




LOAD_R Temp1



LOAD_R Temp2


Intermediate code:

Temp1 = B + C

Temp2 = Temp1 + D

A = Temp2

Statements in yellow can be removed

  • The compiler for a given language can be written in the same language.
  • a program that translates some internal representation into assembler code
  • the programmer manually re-writes the compiler into the internal representation, using the algorithm that is encoded into the compiler.
  • From there on the internal representation is translated into assembler and then into machine language.