Group 6: JIST: Java with Lists

Download Report

Transcript Group 6: JIST: Java with Lists

James McCliggott
Geoff Stoker
Joel Winstead
Greg Yukl
WHAT IS JIST????
“Java with lists”
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();
//Creating an empty Jist
Jist <int> J;
//Adding some elements
v.addElement(1);
v.addElement(2);
v.addElement(“three”);
v.addElement(4);
//Adding some elements
J = [1, 2, “three”, 4];
// . . . Possibly much later
int i = (int) v.elementAt(2);
//Runtime Error
//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
JIST
PARSER
JAVA
TRANSFORMER
CODE
GENERATOR
PARSING A JIST
jist:
LBRACK!
( expression ( COMMA! expression )* )?
RBRACK!
{ #jist = #( #[JIST,”JIST”], jist ); }
;
JIST
[ 1, 2, 3 ]
EXPR
EXPR
EXPR
1
2
3
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
REACTION
QUESTIONS