Create your own language DESIGN -> PARSE -> INTERPRET.

Slides:



Advertisements
Similar presentations
Java Basic Training HaiNH - FQA. Agenda Introduction to Java Java Programming Environment Language Fundamental Object Oriented Programming with Java.
Advertisements

By Neng-Fa Zhou Compiler Construction CIS 707 Prof. Neng-Fa Zhou
Lecture 01 - Introduction Eran Yahav 1. 2 Who? Eran Yahav Taub 734 Tel: Monday 13:30-14:30
Computer Concepts 5th Edition Parsons/Oja Page 546 CHAPTER 11 Software Engineering Section A PARSONS/OJA Computer Programming.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
T-diagrams “Mommy, where do compilers come from?” Adapted from:
1 Programming Languages b Each type of CPU has its own specific machine language b But, writing programs in machine languages is cumbersome (too detailed)
Reference Book: Modern Compiler Design by Grune, Bal, Jacobs and Langendoen Wiley 2000.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Programming Languages Structure
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
 Knowledge and use of tools and resources in a system: standard libraries, system calls, debuggers, the shell environment, system programs and scripting.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
1 Integrated Development Environment Building Your First Project (A Step-By-Step Approach)
CS 355 – Programming Languages
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Chapter 1.4 Programming languages Homework Due: Monday, August 11, 2014.
Chapter 1. Introduction.
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
1 October 1, October 1, 2015October 1, 2015October 1, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University Azusa.
Introduction to Compiler Construction Robert van Engelen COP5621 Compiler Construction Copyright Robert.
Lecture 10 : Introduction to Java Virtual Machine
Java Programming Introduction & Concepts. Introduction to Java Developed at Sun Microsystems by James Gosling in 1991 Object Oriented Free Compiled and.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 10, 10/30/2003 Prof. Roy Levow.
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Programming Languages & Translators (CE 359) Fall 2013 Prof. Dr: Ahmed El Nahass Lecture 1 1 FACULTY OF ENGINEERING COMPUTER ENGINEERING Prof.Dr Ahmed.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Homework #1 J. H. Wang Oct. 5, 2015.
Virtual Machines, Interpretation Techniques, and Just-In-Time Compilers Kostis Sagonas
Compiler design Lecture 1: Compiler Overview Sulaimany University 2 Oct
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
Compilers and Interpreters. HARDWARE Machine LanguageAssembly Language High Level Language C++ Visual Basic JAVA Humans.
 Programming - the process of creating computer programs.
Javascript Static Code Analyzer
Getting Started With Java September 22, Java Bytecode  Bytecode : is a highly optimized set of instructions designed to be executed by the Java.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Compilers and Interpreters
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Programming 2 Intro to Java Machine code Assembly languages Fortran Basic Pascal Scheme CC++ Java LISP Smalltalk Smalltalk-80.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
CSCE 343 – Programming Language Concepts Welcome!.
Clojure Macros. Homoiconicity All versions of Lisp, including Clojure, are homoiconic This means that there is no difference between the form of the data.
CS-140 Dick Steflik Lecture 3. Java C++ Interpreted optimized for the internet Runs on virtual ized machine Derived from C++ Good object model Widely.
INTERMEDIATE LANGUAGES SUNG-DONG KIM DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
Compiler Chapter 9. Intermediate Languages Sung-Dong Kim Dept. of Computer Engineering, Hansung University.
Chapter 1. Introduction.
Applications Active Web Documents Active Web Documents.
What Do Computers Do? A computer system is
Advanced Computer Systems
PROGRAMMING LANGUAGES
CSCI-235 Micro-Computer Applications
Compiler Chapter 9. Intermediate Languages
Chapter 1: Intro (excerpt)
High Level Programming Languages
ICT Programming Lesson 1:
Lesson Objectives Aims Understand Syntax Analysis.
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
Programming language translators
Presentation transcript:

Create your own language DESIGN -> PARSE -> INTERPRET

Language design Ask following questions before you start doing anything  What is the purpose of the language?  Why do we need it?  What exactly it should do? (how does it help to solve the problem?)  Who should use this language?  Is there some existing language that could help us to solve our problem?

Why do we ask such questions?

Language design: rule #1 1st rule of language design : keep it SIMPLE!  Easier to parse  Steep learning curve of the language  Code is more readable/strict  Code/program execution may be faster

Language design: rule #2 2nd rule of language design : keep it SIMPLE!!!

Config Template language WinCC OA project Config file/s Config file -sections Config file - properties

Config Template language  We have lots of WinCC OA projects  Each project has configuration file/s  Each “config” file has 1..* sections  Each section has 1..* properties  Each property has 1..* values  Template language is a tool that allows as to ask computer questions about config files. Are all the sections and properties correct?

How can we ask computer such questions? – REGexprs?  ?:\r\n)?[\t]))*"(?:(?:\r\n)?[\t])*)*\ ]))*"(?:(?:\r\n)?[\t])*)*\ ?:(?:\r\n)?[\t])*))*)?;\s*)

Config Template example '''print(“Hello World template!”);''' [general] {exactlyOnce} pvss_path = "C:/Siemens/" || "/opt/Siemens" proj_path = ''(value.toLowerCase().startsWith("c:/projects/"))'' [ui] showActiveShapes = 0 checkADAuthIntervall = >= 60

Root rule Section ruleProperty ruleValue/s rule Properties collection rule JS rule Sections collection rule JS rule

How to parse languages?

Interpreting language  Bytecode interpreters  Highly optimized machine independent code (Java/.NET/Emacs Lisp)  Abstract Syntax Tree interpreters  Keeps relations between statements  Allows to perform better analysis during runtime  Just-in-time compilation  Some representation of program is compiled to native code at runtime  Self-interpreter

Config files Parse config files Template Parse template Execute Execute template file Result Stack trace of failed rules

Template file Template model Exe. model Config file 01Config model Abstract model (JSON) Config file 02Config model Abstract model (JSON) Config file 03Config model Abstract model (JSON) Config file …Config model Abstract model (JSON) Config file xxConfig model Abstract model (JSON) … …

Config 01 Thread 1 Config 02 Thread 2 Config … Thread … Config xx Thread T Shared Template engine

How language design influences its execution? A LOT

Config 01 Thread 1 Config 02 Thread 2 Config … Thread … Config xx Thread T Shared Template engine

Interpreting parts of AST with JavaScript NashornJavaScript Config template “Template engine”AST Virtual machine JVMbytecode Hardware CPUassembler