TyCL The TyCL interpreter/compiler: its advantages and limitations Andres Buss Otlet Technologies.

Slides:



Advertisements
Similar presentations
Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
Advertisements

Programming Languages and Paradigms
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
Structure of a C program
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Procedures and Functions Computing Module 1. What is modular programming? Most programs written for companies will have thousands of lines of code. Most.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Introduction to Scheme Lectures on The Scheme Programming Language, 2 nd Ed. R. Kent Dybvig.
CS 153: Concepts of Compiler Design October 5 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
I Power Higher Computing Software Development High Level Language Constructs.
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
An Introduction to Java – Part 1 Erin Hamalainen CS 265 Sec 001 October 20, 2010.
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
COMPILERS Semantic Analysis hussein suleman uct csc3003s 2009.
Lecture 9 Symbol Table and Attributed Grammars
C++ LANGUAGE MULTIPLE CHOICE QUESTION SET-3
C++ Lesson 1.
ARRAYS (Extra slides) Arrays are objects that help us organize large amounts of information.
Chapter VII: Arrays.
CSC 211 Java I for loops and arrays.
Information and Computer Sciences University of Hawaii, Manoa
Pointers What is the data type of pointer variables?
Stack and Heap Memory Stack resident variables include:
Lesson #8 Structures Linked Lists Command Line Arguments.
Test 2 Review Outline.
Data Type and Function Prepared for CSB210 Pemrograman Berorientasi Objek By Indriani Noor Hapsari, ST, MT Source: study.
The Machine Model Memory
Chapter 6 – Data Types CSCE 343.
CSC215 Lecture Advanced Pointers.
Chapter 10-1: Structure.
Java Primer 1: Types, Classes and Operators
C Programming Tutorial – Part I
Chapter 14 Templates C++ How to Program, 8/e
An interpreter/compiler of a typed language implementation of Tcl/Tk
CS 153: Concepts of Compiler Design October 3 Class Meeting
Run-Time Storage Organization
Run-Time Storage Organization
Function There are two types of Function User Defined Function
C Basics.
Methods and Parameters
CSC 253 Lecture 8.
Arrays, For loop While loop Do while loop
CSC 253 Lecture 8.
CS 240 – Lecture 18 Command-line Arguments, Typedef, Union, Bit Fields, Pointers to Functions.
CMPE 152: Compiler Design October 2 Class Meeting
CMPE 152: Compiler Design October 4 Class Meeting
More About Data Types & Functions
Built-In (a.k.a. Native) Types in C++
Arrays We often want to organize objects or primitive data in a way that makes them easy to access and change. An array is simple but powerful way to.
Lecture 18 Arrays and Pointer Arithmetic
Pointers C#, pointers can only be declared to hold the memory addresses of value types int i = 5; int *p; p = &i; *p = 10; // changes the value of i to.
PZ09A - Activation records
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
Activation records Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Building Java Programs
CS 432: Compiler Construction Lecture 11
CSC 253 Lecture 2.
CMPE 152: Compiler Design March 7 Class Meeting
Java Programming Language
Course Overview PART I: overview material PART II: inside a compiler
C++ Programming Basics
COMPILERS Semantic Analysis
CMPE 152: Compiler Design March 7 Class Meeting
C Language B. DHIVYA 17PCA140 II MCA.
Variables and Constants
Activation records Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
INTRODUCTION TO C.
SPL – PS2 C++ Memory Handling.
Presentation transcript:

TyCL The TyCL interpreter/compiler: its advantages and limitations Andres Buss Otlet Technologies

Needed for better description of data to the compiler Optional in source-code (always present internally) Core types: boolean, integer, real, array, tarray, string, char, struct, list, group, enum, union, object, proc hash (numeric hash) dict (string hash) cproc The Type system

A value's type is declared as a cast: set a struct:{ int:x f64:y } Variables can be constrained by a type: define a struct:{ int:x f64:y } Variables can reference another variable: let a b set a 3 ;# 3 → a → b The Type system TYPE:VALUE

What is a type? @exec } The Type system

Values in memory VARIABLE DATA (64-bits) Extra Desc. (32-bits) TYPE+FLAGS (32-bits) RAW DATA INDEX TO TYPE DESCRIPTOR EXTRA DESCRIPTIONS FLAGS DATA MODES

Values in memory a Pointer (64-bits) Index (32-bits) TYPE+FLAGS (32-bits) INDEX TO TYPE GROUP INDEX TO TYPE INTEGER FLAGS:0 MODES:? set a {group:integer}:{ integer:”67” integer:4.3}

TyCL supports the global and local scopes but not namespaces yet, however the syntax to reference such variables is a bit different Local variables: They are just as Tcl's ones Accessed inside execution blocks only TyCL's Scopes & data access

Global variables: Variables stored at the root of the calling stack TyCL has its own way to reference this variables from any part of the program without using the command: global (as Tcl does) by prefixing the name with a dot (.) TyCL's Scopes data & access

Global variables (example): set a 4; # global variable proc foo {x} { set.a $x; # the global 'a' is accessed } foo 99;# actually: 'a' is set to the value: 99 TyCL's Scopes & data access

Accessing internal members: Types such as struct, object, or enum, have internal members (or fields), these members can be accessed by joining the variable's name and the member's name with a dot (.) and by following the previous rules if the variable is global or local. If the access to an object's member is present inside one of its own methods, a new prefix: 'my' must be used to indicate that such member is present inside itself. TyCL's Scopes & data access

Struct's fields (example): set point struct:{ float:x float:y } set point.x 88;# access to point's field: x set point.y 314;# access to point's field: w TyCL's Scopes & data access

Object's members (example): set a object:{ x 0 ~count {} { incr my.x 1 ;# access to a.x puts “call number: $my.x”;# access to a.x } a.count;# It should print: 'call number: 1' a.count;# It should print: 'call number: 2' TyCL's Scopes & data access

A new syntax was created to handle indexes an ranges for data-types that support them, which account for all except objects and structs # for indexes VARIABLE_NAME(INDEX) # for ranges VARIABLE_NAME(INITIAL_INDEX.. FINAL_INDEX) TyCL's Indexes and Ranges

Integers: gets or sets particular bits. Floats: gets or sets particular bits. Boolean: gets or sets bits, but the complete values is stored always as 0 or 1. Chars: gets or sets particular bits. Strings: gets or sets particular characters. Arrays: gets or sets particular values. Lists: gets or sets particular values. Groups: gets or sets particular values. TyCL's Indexes and Ranges

Using indexes to insert, append replace data # inserts the value before index set VARIABLE_NAME(*INDEX) VALUE # inserts the value after the index set VARIABLE_NAME(INDEX*) VALUE if the index is -1, it references the last item in the content, thus an append would be written as: set VARIABLE_NAME(-1*) VALUE ;# this is an append Expansion: by prefixing the index with a plus-sign '+' set VARIABLE_NAME(+-1*) VALUE ;# this is an append # and expand TyCL's Indexes and Ranges (cont.)

proc FUNCTION_NAME PARAMETERS BODY [proc PARAMETERS BODY] Parameters: Return value: TYPE:* Required: exactly as TCL's Optional: exactly as TCL's Named: -PARAMETER Flags: --FLAG Boolean variables which are false by default Procedures (functions) What is different? Parameters can be typed

funcname 1 2 list:{a 4 5.7} -x 99 --nocount All arguments are passed by reference … except for native types: boolean, integer, real but, … not exactly! proc func {...BODY...} Calling a proc

Architecture TyCL Source code Application Lexical Parser TIR Binary Tree WordCo de Generato r WordCode Binary Machine Code Generato r Virtual Machine Binary code Code+Tables

Status The project is close to have a working (basic and naive compiler) version on Linux i386 Only the compiler Next: On-the-fly interpreter A port to Linux on ARM and X86_64 The posibility to run TyCL code in compiling time...this allows the modification of the whole compiler right at the spot.

To anyone interested … in any way :)