Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
maxjf1 committed Nov 18, 2020
1 parent c8fa6cb commit bf14e4c
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/main/java/lexlang/ArrayValue.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/
Expand Down Expand Up @@ -45,7 +45,7 @@ public boolean add(Value value) {
return values.add(value);
}

private void checkIndexBounds(int i){
private void checkIndexBounds(int i) {
if (values.size() <= i)
throw new LangException("Index " + i + " out of bounds for length " + values.size());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lexlang/Data.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lexlang/FunctionScope.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/lexlang/LangInterpreter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Maxwell Souza 201435009
* Rodolpho Rossete 201435032
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/


Expand Down Expand Up @@ -36,9 +36,8 @@ public LangInterpreter(SemanticAnalyzer analyzer) {
/**
* Run a program
*/
public Value run() {
public void run() {
runFunction("main", null);
return null;
}

// Memory management
Expand Down Expand Up @@ -387,7 +386,7 @@ public Value visitReadCmd(LexLangParser.ReadCmdContext ctx) {
String response = reader.nextLine();
int val;
try {
val = Integer.valueOf(response);
val = Integer.parseInt(response);
} catch (Exception e) {
throw new LangException("Read error: 'Int' expected, received '" + response + "'", ctx);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/lexlang/LangRunner.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Maxwell Souza 201435009
* Rodolpho Rossete 201435032
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lexlang/Main.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lexlang/Scope.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/lexlang/Value.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/**
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/



package lexlang;

public class Value {
final Object primitive;

public static Value VOID = new Value(null);
public static Value EMPTY_CHAR = new Value((Character)Character.MIN_VALUE);
public static Value EMPTY_CHAR = new Value(Character.MIN_VALUE);

public Value(Object value) {
this.primitive = value;
Expand Down Expand Up @@ -44,14 +43,15 @@ public Data getData() {
return (Data) primitive;
}

public ArrayValue getArray(){
public ArrayValue getArray() {
return (ArrayValue) primitive;
}

@Override
public boolean equals(Object o) {
if (primitive == o) return true;
// if (value == null || o == null || o.getClass() != value.getClass()) return false;
// if (value == null || o == null || o.getClass() != value.getClass()) return false;
if (!(o instanceof Value)) return false;
Value comparedValue = (Value) o;
if (comparedValue.getRawValue() instanceof Number && this.primitive instanceof Number)
return this.getFloat().equals(comparedValue.getFloat());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/semantics/DataDeclaration.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Maxwell Souza 201435009
* Rodolpho Rossete 201435032
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/


Expand Down
6 changes: 3 additions & 3 deletions src/main/java/semantics/DefaultTypes.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Maxwell Souza 201435009
* Rodolpho Rossete 201435032
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/

package semantics;
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/semantics/FunctionDeclaration.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/**
* Maxwell Souza 201435009
* Rodolpho Rossete 201435032
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/


package semantics;

import lexlang.LexLangParser;
import semantics.Type;

import java.util.ArrayList;
import java.util.List;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/semantics/FunctionManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Maxwell Souza 201435009
* Rodolpho Rossete 201435032
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/

package semantics;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/semantics/LangException.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Maxwell Souza 201435009
* Rodolpho Rossete 201435032
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/


Expand Down
6 changes: 3 additions & 3 deletions src/main/java/semantics/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public int hashCode() {

@Override
public String toString() {
String arrayDepth = "";
for (int i = 0; i < depth; i++) arrayDepth += "[]";
StringBuilder arrayDepth = new StringBuilder();
for (int i = 0; i < depth; i++) arrayDepth.append("[]");
if (isData()) return data.getId() + arrayDepth;
return type + arrayDepth;
return type + arrayDepth.toString();
}
}
6 changes: 3 additions & 3 deletions src/main/java/semantics/Validator.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Maxwell Souza 201435009
* Rodolpho Rossete 201435032
/*
Maxwell Souza 201435009
Rodolpho Rossete 201435032
*/

package semantics;
Expand Down

0 comments on commit bf14e4c

Please sign in to comment.