1 / 11

Lattakia (A language for Lattices)

Lattakia (A language for Lattices). Wael Salloum Hebatallah Elfardy Katherine Scott Li Yifan. What’s a lattice?. A more detailed example. Conditioned predicate. x : 5. [x> y] x= x-y. y: 10. z: x. x=y-x. Unconditioned predicate. Altlat. Labeled lattice. Seqlat.

chaim
Télécharger la présentation

Lattakia (A language for Lattices)

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lattakia (A language for Lattices) WaelSalloum HebatallahElfardy Katherine Scott Li Yifan

  2. What’s a lattice?

  3. A more detailed example Conditioned predicate x: 5 [x> y] x= x-y y: 10 z: x x=y-x Unconditioned predicate Altlat Labeled lattice Seqlat ..Code for the above lattice x: 5; y: 10; [x>y ] x = x-y | y=y+5; z:x;

  4. Lattakia in a Nutshell ** A MULTI LINE COMMENT ** .. A single line comment foo = (1;2;3); .. a sequence lattice of integers bar = (1.0|2.0|3.0); .. an alternative lattice of floats baz = (a:1|b:2|c:3); .. a labeled alt lat print(baz.a); .. access a and print it print(foo{0}) .. Prints 1 print(bar[0]) .. Prints 1.00 deffnord(x;y) = ([x>=y] print(x); | print(y); ); .. a function definition herp = 10; derp = 20; let fnord(herp;derp); .. Function application prints 10 - MORE HERE 

  5. Quick Sort Example ** Perform quicksort on a seqlat of integer values. ** def quicksort(input) = ( let (less = (); greater = () ); .. create two local variables [input.length <= 1] return = input | .. if we have a single value return let pivot = input[0]; .. create a pivot let input[0] = epsilon; foreach(x; input; .. for each value in the array [x < pivot] less = (less; x) .. create a less than lattice | greater = (greater; x) .. and a greater than lattice ); .. now recursively sort the new lattices and return a lattice (quicksort(less); pivot; quicksort(greater)); ).return; .. return the input values = (42;7;18;6;1;-3;15;30); let sorted = quicksort(values); foreach(x; sorted; print(x); print("\n"); );

  6. Compiling & Running GCD ** GCD - calculate the greatest common denominator. ** defgcd(x; y) = ( [y == 0] x | [y != 0 ] gcd(y, x % y); ); a = 35; b = 49; print("GCD of 35 and 49 is "); print(gcd(a; b)); print("\n"); > ./latte < GCD.lat GCD of 35 and 49 is 7 >

  7. Initial Design Source Code Scanner (tokens) Parser (Build AST) Symbol Table Generation (from AST) Semantic Anal. (Clean AST & ST) Java Source Code Generation (from OCaml) JVM Execution AST & Symbol Table Result Latte Translator Lattakia Java Library

  8. Revised Design Source Code Scanner (tokens) Parser (Generate Lattice / AST) Semantic Analysis (cleaned lattice) Evaluation (evaluate lattice) Printer (print to stdout) Lattice & Symbol Table Result Latte Interpreter

  9. Lessons Learned • Writing a compiler isn’t that bad… writing one for a complex language is. • Ocaml is actually kinda cool. • Translation is difficult when you are trying to hit a moving target. • Things get done when you put everyone in a room. • Keep it simple stupid

  10. Lattice Construction LatticeType Lattice Fields DataStructTypeType altlatFields alternatives: latticeFields each: bool DataTypeType Int / Float / Boolean / String / General/UnresolvedType / Diverse / MismatchType latticeNatureType |DataLat | Hashtable | Object | Function seqlatFields expr: exprFields; elements: latticeFieldslist symbols: symbolTableType StructureTypeType Seq/ Alt / Wrd / Undetermined exprValueType |ConstValueconstantType | LatticeValuelatticeFields | NotEvaluated predicateFields expr: exprFields; condition: exprFields; exprFields exprDataStructType:dataStructTypeType exprCode: exprCodeTypeexprEval: exprValueTypeexprChanged: bool expDependers: exprFields expDependees: exprFields exprCodeType | ConstExprconstantType| OpExproperationType | NameListExprnameListType | LatticeExprlatticeFields operationType operator: operatorType operand1: exprFields operand2: exprFields constantType | StringLiteral | IntLiteral | FloatLiteral | Epsilon | Nil | True | False

  11. Environment / Symbol Table envType labelIdGenerator: int parentStackLabelIdGenerator: intlist errorTable: errorTypelist worningTable: errorTypelist namesOfCurrLat: symbolTableType lineNumber: int; charOffset: int errorType errMessage: errorMessageType errPlace: exprCodeTypeoption lineNum: int offset: int symbolTableType parent : symbolTableTypeoption hash : symbolTypeStringMap.t symbolType symName: string symDataStructType: dataStructTypeType symValue: symbolValueType symbolScope: symbolScopeType parameterNameList: string list option parameterTypeList: dataStructTypeTypelist dependers: exprFields ref list dependees: exprFields ref list errorMessageType | SemParamListTypeSignMismatch | SemUndefinedIdentifier | SemIdentifierMultipleDefinition | SemTypeMismatch | SemPredicateTypeNotBoolean | LexUndefinedSymbol | SynParseError errorCategoryType | Worning | Semantic | Syntactic | Lexical | Runtime symbolValueType | LabelIndex : int | LocalValueLattice: latticeFieldsref symbolScopeType |Label | Local | UnresolvedSymbol

More Related