-
Notifications
You must be signed in to change notification settings - Fork 0
milenakrawczyk/interpreter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
1. General description miLatte is an imperative programming language based on Latte (https://www.mimuw.edu.pl/~ben/Zajecia/Mrj2011/Latte/). The following features has been added: - multidimensional arrays - arguments passed by reference - function as parameter - lambda functions - static type validator - break and continue 2. Detailed description The syntax is very similar to that of Java. Below is a more detailed description of the key features. a) Arrays - arrays can be mutidimensional and are declared like in Java: int a[4][5][6]; There is no declaration with assignment so the assignment must be a separate statement e.g. a[0][0][0] = 42; Arrays are passed by value (like in Java). b) Function arguments - variables are passed by reference so that they can be changed inside the function. Arrays and lambdas are passed by value. c) Function environment - when a function is called a new environment is created. The environment contains all the functions withtin a scope. The variables are not in the scope, except for the variables passed as argument (by reference): int a; void testEnv() { int a = 4; //no error because the function environment does not inherit variables } void testEnv2(int b) { b = 4; //no error because the function environment does not inherit variables } testEnv2(a); //now the variable a equals 4 void testEnv3() { testEnv(); //function in scope so no error } d) Printing - the build-in functions void print(...) supports strings, bool, ints and array cells e.g.: boolean flag = true; print(flag); //prints "true" int a[10]; a[5] = 42; print(a[5]); //prints "42" string msg = "Hello World!"; prints(msg); //prints "Hello World!" e) Lambdas and functions as params - lambdas have the following syntax int(string, int) x; x = int (string a, int b) => {print(a); return b;}; int functionAsParamTest(int(string,int) param1) { return param1("WOW",4); //prints "WOW" and returns 4 } f) Break and continue - they work in a standard way: while(true) { break; //the loop won't loop infinitely } int i = 0; while (i < 4) { i++; continue; print("This part of while loop is never executed and thus never printed"); //continue makes skip this part } g) Static types validator - validates types before executing the program 3. The contents of this directory. There are two directories: a) good - with good (working) examples b) bad - with bad (not-working) examples to show how error handling works 4. Running - running is standard: a) make b) ./Interpreter program
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published