circline an easy graph language
play

Circline -- An Easy Graph Language Haikuo Liu Jia zhang Qing Lan - PowerPoint PPT Presentation

Circline -- An Easy Graph Language Haikuo Liu Jia zhang Qing Lan Zehao Song Language Summary Basic: Integer, Floating Point 64 bit, Boolean, String, Null Data Structure: List, Dict, Node, Graph Operations: Arithmetic Operation, Logic


  1. Circline -- An Easy Graph Language Haikuo Liu Jia zhang Qing Lan Zehao Song

  2. Language Summary Basic: Integer, Floating Point 64 bit, Boolean, String, Null Data Structure: List, Dict, Node, Graph Operations: Arithmetic Operation, Logic Operation, Conditional Operation, Graph Operation

  3. Language Feature ● Native Support on Node, Edge and Graph Definition & Operation ● Function and variables declared everywhere, Support nested function ● Support List, Hashmap basic Data structure Circle + Line =

  4. Node & Graph - Merge Graph node a = node(“a”); a c graph g1 = a -> b -> c; + graph g2 = c -> [d, e]; b c d e graph gh = g1 + g2; a -> b -> c c -> [d, e] a -> (b -> c)

  5. Node & Graph - Merge Graph node a = node(“a”); a graph g1 = a -> b -> c; b c graph g2 = c -> [d, e]; graph gh = g1 + g2; d e a -> b -> c -> [d, e]

  6. Node & Graph - Graph Subtraction a a c - = b c b c d e d e d e a -> b -> c - c -> [d, e] = list<graph> -> [d -> e, e]

  7. Node & Graph - Node Removal a a - = c b b c d e d e a -> b -> c - c = list<graph> -> [d -> e, e]

  8. Node & Graph - Neighbors a graph gh = a -> b -> [c, d, e] gh @ a => [ b ] b gh @ b => [c, d, e] e c gh @ c => [] d

  9. Node & Graph - Edge Value graph gh = a -> 1&b -> [2&c, 3&d, 4&e] a graph gh = a -> 1&b -> [2,3,4]& [c,d,e] 1 gh @ (a, b) => 1 b 2 4 gh @ (b, a) => null e c 3 gh @ (b, d) => 3 d

  10. List Array ❖ list<int> li = [ 1, 2, 3]; ➢ get() set() ➢ Queue ❖ Auto Conversion add() ➢ ➢ remove() list<float> lf = [1, 1.2, 3]; Stack ❖ push() ➢ list<graph> lg = [a, a -> b]; pop() ➢

  11. Dict Map ❖ node a = node("a"); put() ➢ node b = node("b"); get() ➢ ❖ Set dict<node> set = { a: a }; has() ➢ set.has(a) => true keys() ➢ set.get(b) => false set.get(a) => 1

  12. Nested Functions int d = 1; int b(int c) { ❖ Access Outer Variables int d = 2; int a() { Scoping - Static ❖ return d + c; } return a(); } print( b(3) ); /* Output 5 */ print( d ); /* Output 1 */

  13. System Architechture

  14. Scanner/Parser

  15. Organizer ● A bridge between Circline and C ● Format the functions and variables

  16. Semantic Check The cast returned by Organizer is a list of function objects. cast: [func1, func2, …, funcn] Loop through all function objects and check each function objects. For nest scope situation, we try to search in parent scope if the variable is not found in current scope.

  17. Code Generation - CAST to LLVM Assembly declare external functions (C Libraries) CAST for function in program: declare all variables in function Code Generator for statement in function: for expression in statement: codegen( expression ) LLVM Assembly

  18. Code Generator - C Library utils.ll code.ll define i32 @show(i32) #0 { declare i32 @show(i32) %2 = alloca i32, align 4 %tmp = call i32 @show(i32 1) store i32 %0, i32* %2, align 4 %3 = load i32, i32* %2, align 4 %4 = add nsw i32 %3, 1 ret i32 %4 } code clang utils.bc code.ll Executable clang -S -emit-llvm utils.c clang -emit-llvm int show(int a) { Bytecode return a+1; } utils.bc

  19. Automated Build and Test -- Save Time! Makefile: make all/test (Find target and build build build) Travis-CI Online Code check

  20. Compile & Run source sh circline.sh <code> Scan/Parse/Codegen circline.native Let’s try to run it! source.ll Link utils.bc source.exe Run

  21. Case Study -- BFS & DFS DFS Code BFS Printout BFS Code DFS Printout

  22. Case Study -- Dijkstra Algorithm

  23. Project Timeline & Contribution

  24. With Special Thanks to Alexandra, our TA who continuously support our project

Recommend


More recommend