Test update
This commit is contained in:
parent
888534955a
commit
384a5e9066
@ -1,5 +1,11 @@
|
|||||||
package TypeCheck;
|
package TypeCheck;
|
||||||
|
|
||||||
public class TypeCheckResult {
|
public class TypeCheckResult {
|
||||||
|
|
||||||
|
public TypeCheckResult(){}
|
||||||
|
public TypeCheckResult(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
public String type;
|
public String type;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
class Dijkstra {
|
class Dijkstra {
|
||||||
|
|
||||||
void main() {
|
public static void main(String[] args) {
|
||||||
Vertex v1 = new Vertex(1);
|
Vertex v1 = new Vertex(1);
|
||||||
Graph g = new Graph(v1);
|
Graph g = new Graph(v1);
|
||||||
Vertex v2 = new Vertex(2);
|
Vertex v2 = new Vertex(2);
|
||||||
@ -91,7 +91,7 @@ class Graph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getShortestPath(Vertex source, Vertex destination) {
|
public void getShortestPath(Vertex source, Vertex destination) {
|
||||||
VertexSet calcList = vertexList.copy();
|
VertexSet calcList = vertexList.copy(vertexList);
|
||||||
calcList.get(source.id).setDistance(0);
|
calcList.get(source.id).setDistance(0);
|
||||||
calcList.get(source.id).setPrevious(null);
|
calcList.get(source.id).setPrevious(null);
|
||||||
Vertex current = calcList.get(source.id);
|
Vertex current = calcList.get(source.id);
|
||||||
@ -100,7 +100,6 @@ class Graph {
|
|||||||
current.setVisited(true);
|
current.setVisited(true);
|
||||||
VertexSet currentAdjanceyList = current.getAdjanceyList();
|
VertexSet currentAdjanceyList = current.getAdjanceyList();
|
||||||
if (currentAdjanceyList != null) {
|
if (currentAdjanceyList != null) {
|
||||||
int i = 0;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < currentAdjanceyList.size()) {
|
while (i < currentAdjanceyList.size()) {
|
||||||
Vertex adjancey = currentAdjanceyList.getFromIndex(i);
|
Vertex adjancey = currentAdjanceyList.getFromIndex(i);
|
||||||
@ -118,7 +117,7 @@ class Graph {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
current = calcList.getNextSmallestUnvisited();
|
current = calcList.getNextSmallestUnvisited(calcList);
|
||||||
}
|
}
|
||||||
Vertex previous = calcList.get(destination.id);
|
Vertex previous = calcList.get(destination.id);
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
@ -190,8 +189,8 @@ class Vertex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vertex copy() {
|
public Vertex copy(Vertex vertex) {
|
||||||
return new Vertex(this);
|
return new Vertex(vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDirect(Vertex v) {
|
public boolean isDirect(Vertex v) {
|
||||||
@ -221,16 +220,16 @@ class VertexSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public VertexSet(VertexSet vertexList) {
|
public VertexSet(VertexSet vertexList) {
|
||||||
this.vertex = vertexList.vertex.copy();
|
this.vertex = vertexList.vertex.copy(vertexList.vertex);
|
||||||
if (vertexList.next != null) {
|
if (vertexList.next != null) {
|
||||||
this.next = vertexList.next.copy();
|
this.next = new VertexSet(vertexList.next);
|
||||||
} else {
|
} else {
|
||||||
this.next = null;
|
this.next = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vertex getNextSmallestUnvisited() {
|
public Vertex getNextSmallestUnvisited(VertexSet currenVertexSet) {
|
||||||
VertexSet v = this.getUnvisited();
|
VertexSet v = this.getUnvisited(currenVertexSet);
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
@ -250,10 +249,10 @@ class VertexSet {
|
|||||||
return smallest;
|
return smallest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VertexSet getUnvisited() {
|
public VertexSet getUnvisited(VertexSet currenVertexSet) {
|
||||||
VertexSet unvisited = null;
|
VertexSet unvisited = null;
|
||||||
|
|
||||||
VertexSet current = this;
|
VertexSet current = currenVertexSet;
|
||||||
while (current != null) {
|
while (current != null) {
|
||||||
if (!current.vertex.isVisited()) {
|
if (!current.vertex.isVisited()) {
|
||||||
if (unvisited == null) {
|
if (unvisited == null) {
|
||||||
@ -295,8 +294,8 @@ class VertexSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public VertexSet copy() {
|
public VertexSet copy(VertexSet currenVertexSet) {
|
||||||
return new VertexSet(this);
|
return new VertexSet(currenVertexSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Vertex v) {
|
public boolean contains(Vertex v) {
|
||||||
@ -328,7 +327,6 @@ class VertexSet {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class IntStack {
|
class IntStack {
|
||||||
|
@ -5,6 +5,7 @@ Int: "int"
|
|||||||
Identifier: "foo"
|
Identifier: "foo"
|
||||||
OpenRoundBracket: "("
|
OpenRoundBracket: "("
|
||||||
Int: "int"
|
Int: "int"
|
||||||
|
Identifier: "i"
|
||||||
ClosedRoundBracket: ")"
|
ClosedRoundBracket: ")"
|
||||||
OpenCurlyBracket: "{"
|
OpenCurlyBracket: "{"
|
||||||
Int: "int"
|
Int: "int"
|
||||||
@ -12,3 +13,40 @@ Identifier: "result"
|
|||||||
Assign: "="
|
Assign: "="
|
||||||
IntValue: "0"
|
IntValue: "0"
|
||||||
Semicolon: ";"
|
Semicolon: ";"
|
||||||
|
If: "if"
|
||||||
|
OpenRoundBracket: "("
|
||||||
|
Identifier: "i"
|
||||||
|
ComparisonOperator: "=="
|
||||||
|
IntValue: "1"
|
||||||
|
ClosedRoundBracket: ")"
|
||||||
|
OpenCurlyBracket: "{"
|
||||||
|
Identifier: "result"
|
||||||
|
Assign: "="
|
||||||
|
IntValue: "10"
|
||||||
|
Semicolon: ";"
|
||||||
|
ClosedCurlyBracket: "}"
|
||||||
|
Else: "else"
|
||||||
|
If: "if"
|
||||||
|
OpenRoundBracket: "("
|
||||||
|
Identifier: "i"
|
||||||
|
ComparisonOperator: "=="
|
||||||
|
IntValue: "2"
|
||||||
|
ClosedRoundBracket: ")"
|
||||||
|
OpenCurlyBracket: "{"
|
||||||
|
Return: "return"
|
||||||
|
IntValue: "20"
|
||||||
|
Semicolon: ";"
|
||||||
|
ClosedCurlyBracket: "}"
|
||||||
|
Else: "else"
|
||||||
|
OpenCurlyBracket: "{"
|
||||||
|
Identifier: "result"
|
||||||
|
Assign: "="
|
||||||
|
IntValue: "30"
|
||||||
|
Semicolon: ";"
|
||||||
|
ClosedCurlyBracket: "}"
|
||||||
|
Return: "return"
|
||||||
|
Identifier: "result"
|
||||||
|
Semicolon: ";"
|
||||||
|
ClosedCurlyBracket: "}"
|
||||||
|
ClosedCurlyBracket: "}"
|
||||||
|
EOF: "<EOF>"
|
@ -3,7 +3,7 @@ Identifier: "FourClasses"
|
|||||||
OpenCurlyBracket: "{"
|
OpenCurlyBracket: "{"
|
||||||
AccessModifierPublic: "public"
|
AccessModifierPublic: "public"
|
||||||
Int: "int"
|
Int: "int"
|
||||||
Identifier: "main"
|
Identifier: "method"
|
||||||
OpenRoundBracket: "("
|
OpenRoundBracket: "("
|
||||||
Int: "int"
|
Int: "int"
|
||||||
Identifier: "i"
|
Identifier: "i"
|
||||||
@ -41,6 +41,24 @@ OpenRoundBracket: "("
|
|||||||
ClosedRoundBracket: ")"
|
ClosedRoundBracket: ")"
|
||||||
Semicolon: ";"
|
Semicolon: ";"
|
||||||
ClosedCurlyBracket: "}"
|
ClosedCurlyBracket: "}"
|
||||||
|
MainMethodDecl: "public static void main(String[] args)"
|
||||||
|
OpenCurlyBracket: "{"
|
||||||
|
Identifier: "FourClasses"
|
||||||
|
Identifier: "fourClasses"
|
||||||
|
Assign: "="
|
||||||
|
New: "new"
|
||||||
|
Identifier: "FourClasses"
|
||||||
|
OpenRoundBracket: "("
|
||||||
|
ClosedRoundBracket: ")"
|
||||||
|
Semicolon: ";"
|
||||||
|
Identifier: "fourClasses"
|
||||||
|
Dot: "."
|
||||||
|
Identifier: "method"
|
||||||
|
OpenRoundBracket: "("
|
||||||
|
IntValue: "1"
|
||||||
|
ClosedRoundBracket: ")"
|
||||||
|
Semicolon: ";"
|
||||||
|
ClosedCurlyBracket: "}"
|
||||||
ClosedCurlyBracket: "}"
|
ClosedCurlyBracket: "}"
|
||||||
Class: "class"
|
Class: "class"
|
||||||
Identifier: "Test"
|
Identifier: "Test"
|
||||||
|
Loading…
Reference in New Issue
Block a user