140 likes | 261 Vues
JIST. James McCliggott Geoff Stoker Joel Winstead Greg Yukl. “Java with lists”. WHAT IS JIST????. or. “ J ist I s S ome T ranslator”. OUTLINE. Why we did it What we did How we did it What we learned Reaction. WHY WE DID IT. Current mechanisms cumbersome
E N D
JIST James McCliggott Geoff Stoker Joel Winstead Greg Yukl
“Java with lists” WHAT IS JIST???? or “Jist Is Some Translator”
OUTLINE • Why we did it • What we did • How we did it • What we learned • Reaction
WHY WE DID IT • Current mechanisms cumbersome • No need to declare data structures that are only used once -- anonymous • Static type checking • Natural representation for functions that take/return tuples
WHAT WE DID • Add lists to Java as first class entities • Ada/Java/C++/C vs. Lisp/Perl/Shell/TCL • Won’t break existing code
JIST EXAMPLES L = [ 1, 2, 3 ]; L = [ 1, 3+4, i*j ]; L = [ 1, 2, 3, [ 4, [ 5, 6 ] ], 7 ]; Jist<Integer> intjist; intjist = [ 1, 2, 3 ]; int seconds, milliseconds; [ seconds, milliseconds ] = getTimeOfDay();
//Creating an empty vector Vector v = new Vector(); //Adding some elements v.addElement(1); v.addElement(2); v.addElement(“three”); v.addElement(4); // . . . Possibly much later int i = (int) v.elementAt(2); //Runtime Error //Creating an empty Jist Jist <int> J; //Adding some elements J = [1, 2, “three”, 4]; //Compile time error
FORMAL SEMANTICS L = [a0, ... , an]; i , ai == literal | expression | Jist --- i, value(L[i]) == value(ai) L[i] = j; j == literal | expression | Jist --- value(L[i]) == value(j) [a0, ..., an] = [b0,..., bm]; n == m For all i, type(ai) == type(bi) --- i, value(ai) == value(bi) where ai is assigned to bi before ai+1 is assigned to bi+1
HOW WE DID IT • Implementation is a translator • Antlr Parser Generator • More powerful than yacc • LL(k) grammars vs. LR • Grammar inheritance • Tree parsers • Antlr is cool!
DOING IT PARSER TRANSFORMER JIST CODE GENERATOR JAVA
JIST EXPR EXPR EXPR [ 1, 2, 3 ] 1 2 3 PARSING A JIST jist: LBRACK! ( expression ( COMMA! expression )* )? RBRACK! { #jist = #( #[JIST,”JIST”], jist ); } ;
WHAT WE LEARNED • Antlr is cool + Lists are cool => Jist is cool • Possible to make changes that don’t complicate a language • Our changes do not break existing code
? ? ? QUESTIONS