refactor packages, add package-info

This commit is contained in:
User 2019-02-07 02:15:07 +01:00
parent 846df01b11
commit ec8617354e
18 changed files with 108 additions and 70 deletions

View File

@ -7,6 +7,7 @@ import org.antlr.v4.runtime.tree.ParseTreeProperty;
import pp.iloc.model.Reg;
import pp.s1184725.boppi.type.*;
import pp.s1184725.boppi.symboltable.*;
/**
* This class holds properties of all AST nodes during compilation.

View File

@ -10,6 +10,7 @@ import pp.s1184725.boppi.antlr.*;
import pp.s1184725.boppi.antlr.BoppiParser.*;
import pp.s1184725.boppi.exception.*;
import pp.s1184725.boppi.type.*;
import pp.s1184725.boppi.symboltable.*;
/**
* This class performs type checking and variable assignment on a bare parse
@ -394,7 +395,7 @@ public class BoppiChecker extends BoppiBaseVisitor<Type> {
@Override
public Type visitTypeFunction(TypeFunctionContext ctx) {
return new FunctionType(visit(ctx.type(1)), visit(ctx.type(0)));
return new FunctionType(visit(ctx.type(0)), visit(ctx.type(1)));
}
@Override

View File

@ -13,7 +13,7 @@ import pp.iloc.model.*;
import pp.s1184725.boppi.antlr.*;
import pp.s1184725.boppi.antlr.BoppiParser.*;
import pp.s1184725.boppi.type.*;
import pp.s1184725.boppi.util.RegisterPool;
import pp.s1184725.boppi.symboltable.*;
/**
* The generator stage of the Boppi toolchain.

View File

@ -1,4 +1,4 @@
package pp.s1184725.boppi.util;
package pp.s1184725.boppi;
import java.util.*;
import java.util.function.*;

View File

@ -0,0 +1,5 @@
/**
* This package contains the Boppi language grammar and, after ANTLR
* generation, the lexer, parser and visitor classes.
*/
package pp.s1184725.boppi.antlr;

View File

@ -1,6 +1,6 @@
package pp.s1184725.boppi.exception;
import pp.s1184725.boppi.CachingSymbolTable;
import pp.s1184725.boppi.symboltable.CachingSymbolTable;
/**
* Exceptions that may be thrown by the {@link CachingSymbolTable}.

View File

@ -0,0 +1,5 @@
/**
* This package contains custom exceptions for
* {@link pp.s1184725.boppi.CachingSymbolTable}.
*/
package pp.s1184725.boppi.exception;

View File

@ -0,0 +1,5 @@
/**
* This package contains the main Boppi classes: a checker, generator,
* toolchain and supporting classes.
*/
package pp.s1184725.boppi;

View File

@ -1,8 +1,9 @@
package pp.s1184725.boppi;
package pp.s1184725.boppi.symboltable;
import java.util.*;
import java.util.function.Supplier;
import pp.s1184725.boppi.Messages;
import pp.s1184725.boppi.exception.*;
import pp.s1184725.boppi.type.*;

View File

@ -1,4 +1,4 @@
package pp.s1184725.boppi;
package pp.s1184725.boppi.symboltable;
import pp.s1184725.boppi.exception.*;
import pp.s1184725.boppi.type.*;

View File

@ -1,4 +1,4 @@
package pp.s1184725.boppi;
package pp.s1184725.boppi.symboltable;
import java.util.*;
import java.util.stream.Collectors;

View File

@ -1,4 +1,4 @@
package pp.s1184725.boppi;
package pp.s1184725.boppi.symboltable;
/**
* This class tracks a variable's properties. It is agnostic of the type system

View File

@ -0,0 +1,4 @@
/**
* This package contains a symbol table implementation.
*/
package pp.s1184725.boppi.symboltable;

View File

@ -8,7 +8,7 @@ import java.util.logging.Level;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import pp.s1184725.boppi.util.RegisterPool;
import pp.s1184725.boppi.RegisterPool;
/**
* Test cases for the basic expression language.
@ -63,6 +63,7 @@ public class ExpressionTest {
public void wrongExpressionChecking() {
BoppiTests.checkString("+true");
assertThat(BoppiTests.log, hasSize(1));
BoppiTests.printOutput();
BoppiTests.checkString("5 || true");
assertThat(BoppiTests.log, hasSize(1));
@ -85,6 +86,7 @@ public class ExpressionTest {
BoppiTests.compileAndRunString("print(5*3)");
assertThat(BoppiTests.log, is(empty()));
assertThat(BoppiTests.out, is(arrayContaining("15")));
BoppiTests.printOutput();
BoppiTests.compileAndRunString("print('T', 'e', 's', 't', '!')");
assertThat(BoppiTests.log, is(empty()));

View File

@ -0,0 +1,4 @@
/**
* This package contains JUnit tests for Boppi features and memlib.
*/
package pp.s1184725.boppi.test;

View File

@ -0,0 +1,5 @@
/**
* This package contains the types in Boppi. Type unification and checking is
* currently performed in {@link pp.s1184725.boppi.BoppiChecker}.
*/
package pp.s1184725.boppi.type;

View File

@ -0,0 +1,5 @@
/**
* This package provides a command-line interface for compiling Boppi code
* and a rudimentary REPL.
*/
package pp.s1184725.boppi.util;