Introduction to Language Processing Technology - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to Language Processing Technology

Description:

Introduction to Language Processing Technology Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University Outline Level of Programming Languages. – PowerPoint PPT presentation

Number of Views:366
Avg rating:3.0/5.0
Slides: 33
Provided by: NNP
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Language Processing Technology


1
Introduction to Language Processing Technology
  • Natawut Nupairoj, Ph.D.
  • Department of Computer Engineering
  • Chulalongkorn University

2
Outline
  • Level of Programming Languages.
  • Language Processors.
  • Specification of Programming Languages.

3
Level of Programming Languages
  • swap(int v, int k)
  • int temp
  • temp vk
  • vk vk1
  • vk1 temp
  • swap
  • muli 2, 5, 4
  • add 2, 4, 2
  • lw 15, 0(2)
  • ...
  • High level C / Java / Pascal
  • Low level Assembly / Bytecode
  • Machine Language
  • 000010001101101100110000
  • 000010001101101100110000
  • 000010001101101100110000
  • 000010001101101100110000
  • ...

C Compiler
Assembler
4
High-Level Language Characteristics
  • Expressions
  • a b (c d)/2
  • Data types
  • Integer, character, boolean.
  • Record, array.
  • Control structures
  • Selective.
  • Iterative.

5
High-Level Language Characteristics
  • Declarations
  • Identifier can be constant, variable, procedure,
    function, and type.
  • Abstraction
  • Object-oriented concept.
  • Concern only what, not how.
  • Encapsulation
  • Object-oriented concept.
  • Information hiding.

6
Language Processors
  • Program that manipulates programs express in some
    programming languages.
  • Example
  • Editor.
  • Translator / Compiler.
  • Interpreter.

7
Translator
  • Translate a source program into an equivalent
    object program.

C C FORTRAN Java VB
Assembly C Bytecode p-code
8
Tombstone Diagrams
  • Ordinary program

Program P
Written with Language L
9
Tombstone Diagrams
  • Machine

SPARC
x86
Machine M
M
x86
SPARC
10
Tombstone Diagrams
  • Translator

S is translated to T
Translator is written with Language L
11
Tombstone Diagrams
  • Compilation

x86
12
Tombstone Diagrams
  • Cross Compilation

SPARC
13
Tombstone Diagrams
  • Two-stage compilation

14
Tombstone Diagrams
  • Compiling a compiler

15
Tombstone Diagrams
  • Interpreter

Basic x86
Interpret source S
S L
Basic x86
SQL SPARC
x86
Written in language L
16
Tombstone Diagrams
  • Abstract machine hardware emulator
  • interpreter for low-level language.

370 x86

x86
17
Tombstone Diagrams
  • Java
  • Portable environment write-once-run-anywhere.
  • Interpretive compiler.

JVM Bytecode
JVM M
18
Tombstone Diagrams
19
Tombstone Diagrams
  • Bootstrapping
  • Compiler L that is written on L language.
  • Full bootstrap
  • Start from nothing.
  • Half bootstrap
  • Start from other machine.

20
Tombstone Diagrams
  • Full Bootstrap

NNP
NNP
21
Tombstone Diagrams
NNP
22
Tombstone Diagrams
NNP
NNP
NNP
23
Tombstone Diagrams
  • Half Bootstrap

x86
x86
24
Specification of Programming Language
  • Specification
  • Syntax
  • Define symbol and structure of the language.
  • Grammar.
  • Contextual constraints
  • Constraints beyond grammar.
  • Rules of the language scope rules, type rules,
    etc.
  • Semantics
  • Meaning of program its behaviors when run.
  • How to translate a sentence S of the language L
    to a machine code on M

25
Syntax
  • Context-free grammar
  • Terminals.
  • Non-terminals / Variables.
  • Start symbol.
  • Production rules.
  • Usually being expressed with BNF notation.

26
BNF Notation
  • Backus-Naur Form.
  • Given production rule
  • N a
  • N b
  • Can be written as
  • N a b

27
Example Mini-Triangle Program
  • ! This is a comment. It continues to the
    end-of-line.
  • let
  • const m 7
  • var n Integer
  • in
  • begin
  • n 2 m m
  • putint(n)
  • end

Terminals begin const do else end if in let then v
ar while ( ) - / lt gt \
28
Mini-Triangle Syntax
  • Program Command
  • Command single-Command
  • Command single-Command
  • single-Command V-name Expression
  • Identifier ( Expression )
  • if Expression then single-Command
  • else single-Command
  • while Expression do single-Command
  • let Declaration in single-Command
  • begin Command end

29
Mini-Triangle Syntax
  • Expression primary-Expression
  • Expression Operator primary-Expression
  • primary-Expression Integer-Literal
  • V-name
  • Operator primary-Expression
  • ( Expression )
  • V-name Identifier
  • Declaration single-Declaration
  • Declaration single-Declaration
  • single-Declaration const Identifier
    Expression
  • var Identifier Type-denoter

30
Mini-Triangle Syntax
  • Type-denoter Identifier
  • Operator - / lt gt \
  • Identifier Letter Identifier Letter
  • Identifier Digit
  • Integer-Literal Digit Integer-Literal Digit
  • Comment ! Graphic eol
  • Letter a b z
  • Digit 0 1 2 9

31
Syntax Tree
  • Ordered tree with
  • Internal nodes non-terminals.
  • Leaf nodes terminals.
  • N-tree of G is a syntax tree with N as the root.

32
Mini-Triangle Syntax Tree
  • Expression primary-Expression
  • Expression Operator
  • primary-Expression
  • primary-Expression Integer-Literal
  • V-name
  • Operator
  • primary-Expression
  • ( Expression )
  • V-name Identifier
Write a Comment
User Comments (0)
About PowerShow.com