Test update

This commit is contained in:
Julian Murek 2024-07-03 14:48:38 +02:00
parent 888534955a
commit 384a5e9066
4 changed files with 77 additions and 17 deletions

View File

@ -1,5 +1,11 @@
package TypeCheck;
public class TypeCheckResult {
public TypeCheckResult(){}
public TypeCheckResult(String type) {
this.type = type;
}
public String type;
}

View File

@ -1,6 +1,6 @@
class Dijkstra {
void main() {
public static void main(String[] args) {
Vertex v1 = new Vertex(1);
Graph g = new Graph(v1);
Vertex v2 = new Vertex(2);
@ -91,7 +91,7 @@ class Graph {
}
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).setPrevious(null);
Vertex current = calcList.get(source.id);
@ -100,7 +100,6 @@ class Graph {
current.setVisited(true);
VertexSet currentAdjanceyList = current.getAdjanceyList();
if (currentAdjanceyList != null) {
int i = 0;
int i = 0;
while (i < currentAdjanceyList.size()) {
Vertex adjancey = currentAdjanceyList.getFromIndex(i);
@ -118,7 +117,7 @@ class Graph {
}
} else {
}
current = calcList.getNextSmallestUnvisited();
current = calcList.getNextSmallestUnvisited(calcList);
}
Vertex previous = calcList.get(destination.id);
if (previous == null) {
@ -190,8 +189,8 @@ class Vertex {
}
}
public Vertex copy() {
return new Vertex(this);
public Vertex copy(Vertex vertex) {
return new Vertex(vertex);
}
public boolean isDirect(Vertex v) {
@ -221,16 +220,16 @@ class VertexSet {
}
public VertexSet(VertexSet vertexList) {
this.vertex = vertexList.vertex.copy();
this.vertex = vertexList.vertex.copy(vertexList.vertex);
if (vertexList.next != null) {
this.next = vertexList.next.copy();
this.next = new VertexSet(vertexList.next);
} else {
this.next = null;
}
}
public Vertex getNextSmallestUnvisited() {
VertexSet v = this.getUnvisited();
public Vertex getNextSmallestUnvisited(VertexSet currenVertexSet) {
VertexSet v = this.getUnvisited(currenVertexSet);
if (v == null) {
return null;
} else {
@ -250,10 +249,10 @@ class VertexSet {
return smallest;
}
public VertexSet getUnvisited() {
public VertexSet getUnvisited(VertexSet currenVertexSet) {
VertexSet unvisited = null;
VertexSet current = this;
VertexSet current = currenVertexSet;
while (current != null) {
if (!current.vertex.isVisited()) {
if (unvisited == null) {
@ -295,8 +294,8 @@ class VertexSet {
}
}
public VertexSet copy() {
return new VertexSet(this);
public VertexSet copy(VertexSet currenVertexSet) {
return new VertexSet(currenVertexSet);
}
public boolean contains(Vertex v) {
@ -328,7 +327,6 @@ class VertexSet {
return null;
}
}
}
class IntStack {

View File

@ -5,6 +5,7 @@ Int: "int"
Identifier: "foo"
OpenRoundBracket: "("
Int: "int"
Identifier: "i"
ClosedRoundBracket: ")"
OpenCurlyBracket: "{"
Int: "int"
@ -12,3 +13,40 @@ Identifier: "result"
Assign: "="
IntValue: "0"
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>"

View File

@ -3,7 +3,7 @@ Identifier: "FourClasses"
OpenCurlyBracket: "{"
AccessModifierPublic: "public"
Int: "int"
Identifier: "main"
Identifier: "method"
OpenRoundBracket: "("
Int: "int"
Identifier: "i"
@ -41,6 +41,24 @@ OpenRoundBracket: "("
ClosedRoundBracket: ")"
Semicolon: ";"
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: "}"
Class: "class"
Identifier: "Test"