Skip to content

Commit

Permalink
Version 0.9.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
nsensfel committed Aug 25, 2020
1 parent f745cf1 commit 8f17022
Show file tree
Hide file tree
Showing 29 changed files with 126 additions and 71 deletions.
17 changes: 17 additions & 0 deletions src/core/src/tonkadur/RuntimeParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

public class RuntimeParameters
{
protected static final String version;
protected static final List<String> include_directories;
protected static final Collection<ErrorCategory> disabled_errors;
protected static final Collection<ErrorCategory> tolerated_errors;
Expand All @@ -19,6 +20,7 @@ public class RuntimeParameters

static
{
version = "0.9.0";
include_directories = new ArrayList<String>();
disabled_errors = new HashSet<ErrorCategory>();
tolerated_errors = new HashSet<ErrorCategory>();
Expand Down Expand Up @@ -60,6 +62,7 @@ public static void add_include_directory (final String name)
final Collection<TonkadurPlugin> plugins
)
{
System.out.println("Tonkadur version " + version);
System.out.println("Usage: tonkadur [<options>] <file>");
System.out.println("Options:");
System.out.println
Expand All @@ -78,6 +81,10 @@ public static void add_include_directory (final String name)
(
" -se|--silence-error <name>\tErrors of type <name> are ignored."
);
System.out.println
(
" --legal \t\t\tPrints the relevant licenses."
);

for (final TonkadurPlugin plugin: plugins)
{
Expand Down Expand Up @@ -182,8 +189,18 @@ else if (option.equals("-se") || option.equals("--silence-error"))

disabled_errors.add(er);
}
else if (option.equals("--legal"))
{
print_license();
}
}

return true;
}

protected static void print_license ()
{
System.out.println("Tonkadur is released under an Apache license. Go to https://tonkadur.of.tacticians.online/LICENSE to consult it.");
System.out.println("Tonkadur uses and ships with a copy of ANTLR 4. Go to https://www.antlr.org/license.html to see ANTLR's license.");
}
}
2 changes: 1 addition & 1 deletion src/core/src/tonkadur/fate/v1/lang/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ protected void add_base_types ()
{
try
{
type_collection.add(Type.BOOLEAN);
type_collection.add(Type.BOOL);
//type_collection.add(Type.DICT);
type_collection.add(Type.FLOAT);
type_collection.add(Type.INT);
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/tonkadur/fate/v1/lang/computation/Cast.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class Cast extends Computation

allowed_type_changes.put
(
Type.BOOLEAN,
Type.BOOL,
Collections.emptySet()
);

Expand All @@ -71,7 +71,7 @@ public class Cast extends Computation
allowed_type_changes.put
(
Type.STRING,
Type.SIMPLE_BASE_TYPES
Type.COMPARABLE_TYPES
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/src/tonkadur/fate/v1/lang/computation/CondValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public class CondValue extends Computation

for (final Cons<Computation, Computation> entry: branches)
{
if (!entry.get_car().get_type().can_be_used_as(Type.BOOLEAN))
if (!entry.get_car().get_type().can_be_used_as(Type.BOOL))
{
ErrorManager.handle
(
new InvalidTypeException
(
entry.get_car().get_origin(),
entry.get_car().get_type(),
Collections.singleton(Type.BOOLEAN)
Collections.singleton(Type.BOOL)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class Constant extends Computation
final boolean value
)
{
return new Constant(origin, Type.BOOLEAN, value ? "true" : "false");
return new Constant(origin, Type.BOOL, value ? "true" : "false");
}

public static Constant build_string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ public class IfElseValue extends Computation
final Type if_true_type;
final Type if_false_type;

if (!condition.get_type().can_be_used_as(Type.BOOLEAN))
if (!condition.get_type().can_be_used_as(Type.BOOL))
{
ErrorManager.handle
(
new InvalidTypeException
(
condition.get_origin(),
condition.get_type(),
Collections.singleton(Type.BOOLEAN)
Collections.singleton(Type.BOOL)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class IsMemberOperator extends Computation
final Computation collection
)
{
super(origin, Type.BOOLEAN);
super(origin, Type.BOOL);

this.collection = collection;
this.element = element;
Expand Down
20 changes: 10 additions & 10 deletions src/core/src/tonkadur/fate/v1/lang/computation/Operator.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ public class Operator
new Operator("rand", 2, 2, Collections.singleton(Type.INT), null);

AND =
new Operator("and", 2, 0, Collections.singleton(Type.BOOLEAN), null);
new Operator("and", 2, 0, Collections.singleton(Type.BOOL), null);
OR =
new Operator("or", 2, 0, Collections.singleton(Type.BOOLEAN), null);
new Operator("or", 2, 0, Collections.singleton(Type.BOOL), null);
NOT =
new Operator("not", 1, 1, Collections.singleton(Type.BOOLEAN), null);
new Operator("not", 1, 1, Collections.singleton(Type.BOOL), null);
IMPLIES =
new Operator
(
"implies",
2,
2,
Collections.singleton(Type.BOOLEAN),
Collections.singleton(Type.BOOL),
null
);
ONE_IN =
Expand All @@ -76,20 +76,20 @@ public class Operator
"one_in",
1,
0,
Collections.singleton(Type.BOOLEAN),
Collections.singleton(Type.BOOL),
null
);

EQUALS =
new Operator("equals", 2, 0, Type.ALL_TYPES, Type.BOOLEAN);
new Operator("equals", 2, 0, Type.ALL_TYPES, Type.BOOL);
LOWER_THAN =
new Operator("<", 2, 2, Type.SIMPLE_BASE_TYPES, Type.BOOLEAN);
new Operator("<", 2, 2, Type.COMPARABLE_TYPES, Type.BOOL);
LOWER_EQUAL_THAN =
new Operator("=<", 2, 2, Type.SIMPLE_BASE_TYPES, Type.BOOLEAN);
new Operator("=<", 2, 2, Type.COMPARABLE_TYPES, Type.BOOL);
GREATER_EQUAL_THAN =
new Operator(">=", 2, 2, Type.SIMPLE_BASE_TYPES, Type.BOOLEAN);
new Operator(">=", 2, 2, Type.COMPARABLE_TYPES, Type.BOOL);
GREATER_THAN =
new Operator(">", 2, 2, Type.SIMPLE_BASE_TYPES, Type.BOOLEAN);
new Operator(">", 2, 2, Type.COMPARABLE_TYPES, Type.BOOL);
}

final protected String name;
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/tonkadur/fate/v1/lang/instruction/Assert.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public class Assert extends Instruction
)
throws InvalidTypeException
{
if (!condition.get_type().get_base_type().equals(Type.BOOLEAN))
if (!condition.get_type().get_base_type().equals(Type.BOOL))
{
ErrorManager.handle
(
new InvalidTypeException
(
condition.get_origin(),
condition.get_type(),
Collections.singleton(Type.BOOLEAN)
Collections.singleton(Type.BOOL)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public class CondInstruction extends Instruction
{
for (final Cons<Computation, Instruction> branch: branches)
{
if (!branch.get_car().get_type().get_base_type().equals(Type.BOOLEAN))
if (!branch.get_car().get_type().get_base_type().equals(Type.BOOL))
{
ErrorManager.handle
(
new InvalidTypeException
(
branch.get_car().get_origin(),
branch.get_car().get_type(),
Collections.singleton(Type.BOOLEAN)
Collections.singleton(Type.BOOL)
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/tonkadur/fate/v1/lang/instruction/DoWhile.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public class DoWhile extends Instruction
)
throws InvalidTypeException
{
if (!condition.get_type().get_base_type().equals(Type.BOOLEAN))
if (!condition.get_type().get_base_type().equals(Type.BOOL))
{
ErrorManager.handle
(
new InvalidTypeException
(
condition.get_origin(),
condition.get_type(),
Collections.singleton(Type.BOOLEAN)
Collections.singleton(Type.BOOL)
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/tonkadur/fate/v1/lang/instruction/For.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ public class For extends Instruction
)
throws InvalidTypeException
{
if (!condition.get_type().get_base_type().equals(Type.BOOLEAN))
if (!condition.get_type().get_base_type().equals(Type.BOOL))
{
ErrorManager.handle
(
new InvalidTypeException
(
condition.get_origin(),
condition.get_type(),
Collections.singleton(Type.BOOLEAN)
Collections.singleton(Type.BOOL)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public class IfElseInstruction extends Instruction
)
throws InvalidTypeException
{
if (!condition.get_type().get_base_type().equals(Type.BOOLEAN))
if (!condition.get_type().get_base_type().equals(Type.BOOL))
{
ErrorManager.handle
(
new InvalidTypeException
(
condition.get_origin(),
condition.get_type(),
Collections.singleton(Type.BOOLEAN)
Collections.singleton(Type.BOOL)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public class IfInstruction extends Instruction
)
throws InvalidTypeException
{
if (!condition.get_type().get_base_type().equals(Type.BOOLEAN))
if (!condition.get_type().get_base_type().equals(Type.BOOL))
{
ErrorManager.handle
(
new InvalidTypeException
(
condition.get_origin(),
condition.get_type(),
Collections.singleton(Type.BOOLEAN)
Collections.singleton(Type.BOOL)
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/tonkadur/fate/v1/lang/instruction/While.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public class While extends Instruction
)
throws InvalidTypeException
{
if (!condition.get_type().get_base_type().equals(Type.BOOLEAN))
if (!condition.get_type().get_base_type().equals(Type.BOOL))
{
ErrorManager.handle
(
new InvalidTypeException
(
condition.get_origin(),
condition.get_type(),
Collections.singleton(Type.BOOLEAN)
Collections.singleton(Type.BOOL)
)
);
}
Expand Down
12 changes: 10 additions & 2 deletions src/core/src/tonkadur/fate/v1/lang/type/CollectionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public class CollectionType extends Type
{
if
(
!Type.SIMPLE_BASE_TYPES.contains
is_set
&&
!Type.COMPARABLE_TYPES.contains
(
content_type.get_act_as_type()
)
Expand All @@ -44,7 +46,7 @@ public class CollectionType extends Type
(
origin,
content_type,
Type.SIMPLE_BASE_TYPES
Type.COMPARABLE_TYPES
)
);
}
Expand Down Expand Up @@ -120,6 +122,12 @@ public DeclaredEntity generate_comparable_to (final DeclaredEntity de)


/**** Misc. ****************************************************************/
@Override
public Type generate_alias (final Origin origin, final String name)
{
return new CollectionType(origin, content_type, is_set, name);
}

@Override
public String toString ()
{
Expand Down
6 changes: 6 additions & 0 deletions src/core/src/tonkadur/fate/v1/lang/type/DictType.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ public Type get_act_as_type ()
}

/**** Misc. ****************************************************************/
@Override
public Type generate_alias (final Origin origin, final String name)
{
return new DictType(origin, field_types, name);
}

@Override
public String toString ()
{
Expand Down
6 changes: 6 additions & 0 deletions src/core/src/tonkadur/fate/v1/lang/type/LambdaType.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ public Type get_act_as_type ()
}

/**** Misc. ****************************************************************/
@Override
public Type generate_alias (final Origin origin, final String name)
{
return new LambdaType(origin, return_type, name, signature);
}

@Override
public String toString ()
{
Expand Down
6 changes: 6 additions & 0 deletions src/core/src/tonkadur/fate/v1/lang/type/PointerType.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public Type get_act_as_type ()
}

/**** Misc. ****************************************************************/
@Override
public Type generate_alias (final Origin origin, final String name)
{
return new PointerType(origin, referenced_type, name);
}

@Override
public String toString ()
{
Expand Down
Loading

0 comments on commit 8f17022

Please sign in to comment.