| summaryrefslogtreecommitdiff |
diff options
10 files changed, 545 insertions, 0 deletions
diff --git a/src/core/src/tonkadur/wyrd/v1/error/UnhandledASTElementException.java b/src/core/src/tonkadur/wyrd/v1/error/UnhandledASTElementException.java new file mode 100644 index 0000000..152c75c --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/error/UnhandledASTElementException.java @@ -0,0 +1,13 @@ +package tonkadur.wyrd.v1.error; + +import tonkadur.error.Error; +import tonkadur.error.ErrorLevel; +import tonkadur.error.ErrorCategory; + +public class UnhandledASTElementException extends Error +{ + public UnhandledASTElementException () + { + super(ErrorLevel.FATAL, ErrorCategory.PROGRAMMING_ERROR); + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/Sequence.java b/src/core/src/tonkadur/wyrd/v1/lang/Sequence.java new file mode 100644 index 0000000..3cae8f9 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/Sequence.java @@ -0,0 +1,27 @@ +package tonkadur.wyrd.v1.lang; + +import java.util.List; + +import tonkadur.wyrd.v1.lang.meta.Instruction; + +public class Sequence +{ + protected final String name; + protected final List<Instruction> content; + + public Sequence (final String name, final List<Instruction> content) + { + this.name = name; + this.content = content; + } + + public String get_name () + { + return name; + } + + public List<Instruction> get_content () + { + return content; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/Variable.java b/src/core/src/tonkadur/wyrd/v1/lang/Variable.java new file mode 100644 index 0000000..2ee4495 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/Variable.java @@ -0,0 +1,32 @@ +package tonkadur.wyrd.v1.lang; + +import tonkadur.wyrd.v1.lang.type.Type; + +public class Variable +{ + protected final String scope; + protected final String name; + protected final Type type; + + public Variable (final String name, final String scope, final Type type) + { + this.name = name; + this.scope = scope; + this.type = type; + } + + public String get_name () + { + return name; + } + + public String get_scope () + { + return scope; + } + + public Type get_type () + { + return type; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/World.java b/src/core/src/tonkadur/wyrd/v1/lang/World.java new file mode 100644 index 0000000..08ba218 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/World.java @@ -0,0 +1,37 @@ +package tonkadur.wyrd.v1.lang; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import tonkadur.wyrd.v1.lang.Variable; +import tonkadur.wyrd.v1.lang.Sequence; + +import tonkadur.wyrd.v1.lang.type.DictType; + +import tonkadur.wyrd.v1.lang.meta.Instruction; + +public class World +{ + protected final Set<String> required_extensions; + + protected final Map<String, Variable> variables; + protected final Map<String, Sequence> sequences; + protected final Map<String, DictType> dict_types; + + protected final List<Instruction> global_instructions; + + public World () + { + required_extensions = new HashSet<String>(); + + variables = new HashMap<String, Variable>(); + sequences = new HashMap<String, Sequence>(); + dict_types = new HashMap<String, DictType>(); + + global_instructions = new ArrayList<Instruction>(); + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/meta/Computation.java b/src/core/src/tonkadur/wyrd/v1/lang/meta/Computation.java new file mode 100644 index 0000000..793bb0a --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/meta/Computation.java @@ -0,0 +1,7 @@ +package tonkadur.wyrd.v1.lang.meta; + +public abstract class Computation +{ + /* Do we need to know the type? */ + /* protected final Type type; */ +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/meta/Instruction.java b/src/core/src/tonkadur/wyrd/v1/lang/meta/Instruction.java new file mode 100644 index 0000000..5ca1859 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/meta/Instruction.java @@ -0,0 +1,5 @@ +package tonkadur.wyrd.v1.lang.meta; + +public abstract class Instruction +{ +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/type/CollectionType.java b/src/core/src/tonkadur/wyrd/v1/lang/type/CollectionType.java new file mode 100644 index 0000000..8c63e2f --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/type/CollectionType.java @@ -0,0 +1,50 @@ +package tonkadur.wyrd.v1.lang.type; + +public class CollectionType extends Type +{ + public static final CollectionType BOOLEAN_BAG; + public static final CollectionType FLOAT_BAG; + public static final CollectionType INT_BAG; + public static final CollectionType STRING_BAG; + + public static final CollectionType BOOLEAN_SET; + public static final CollectionType FLOAT_SET; + public static final CollectionType INT_SET; + public static final CollectionType STRING_SET; + + static + { + BOOLEAN_BAG = new CollectionType(Type.BOOLEAN, true); + FLOAT_BAG = new CollectionType(Type.FLOAT, true); + INT_BAG = new CollectionType(Type.INT, true); + STRING_BAG = new CollectionType(Type.STRING, true); + + BOOLEAN_SET = new CollectionType(Type.BOOLEAN, false); + FLOAT_SET = new CollectionType(Type.FLOAT, false); + INT_SET = new CollectionType(Type.INT, false); + STRING_SET = new CollectionType(Type.STRING, false); + } + + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Type member_type; + protected final boolean is_bag; + + protected CollectionType (final Type member_type, final boolean is_bag) + { + super("(" + (is_bag ? "bag " : "set ") + member_type.name + ")"); + this.member_type = member_type; + this.is_bag = is_bag; + } + + public Type get_member_type () + { + return member_type; + } + + public boolean is_bag () + { + return is_bag; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/type/DictType.java b/src/core/src/tonkadur/wyrd/v1/lang/type/DictType.java new file mode 100644 index 0000000..064e412 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/type/DictType.java @@ -0,0 +1,20 @@ +package tonkadur.wyrd.v1.lang.type; + +import java.util.Map; + +public class DictType extends Type +{ + protected Map<String, Type> fields; + + public DictType (final String name, final Map<String, Type> fields) + { + super(name); + + this.fields = fields; + } + + public Map<String, Type> get_fields () + { + return fields; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/type/Type.java b/src/core/src/tonkadur/wyrd/v1/lang/type/Type.java new file mode 100644 index 0000000..0eff344 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/type/Type.java @@ -0,0 +1,32 @@ +package tonkadur.wyrd.v1.lang.type; + +public class Type +{ + public static final Type BOOLEAN; + public static final Type FLOAT; + public static final Type INT; + public static final Type STRING; + + static + { + BOOLEAN = new Type("boolean"); + FLOAT = new Type("float"); + INT = new Type("int"); + STRING = new Type("string"); + } + + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected String name; + + protected Type (final String name) + { + this.name = name; + } + + public String get_name () + { + return name; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/visitor/fate/v1/FateVisitor.java b/src/core/src/tonkadur/wyrd/v1/visitor/fate/v1/FateVisitor.java new file mode 100644 index 0000000..dfc655c --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/visitor/fate/v1/FateVisitor.java @@ -0,0 +1,322 @@ +package tonkadur.wyrd.v1.visitor.fate.v1; + +import tonkadur.wyrd.v1.error.UnhandledASTElementException; + +import tonkadur.fate.v1.lang.meta.NodeVisitor; + +public abstract class FateVisitor implements NodeVisitor +{ + public void visit_world (final tonkadur.fate.v1.lang.World w) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + /* Instruction Nodes */ + public void visit_add_element + ( + final tonkadur.fate.v1.lang.instruction.AddElement ae + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_assert (final tonkadur.fate.v1.lang.instruction.Assert a) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_clear (final tonkadur.fate.v1.lang.instruction.Clear c) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_cond_instruction + ( + final tonkadur.fate.v1.lang.instruction.CondInstruction ci + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_display (final tonkadur.fate.v1.lang.instruction.Display n) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_event_call + ( + final tonkadur.fate.v1.lang.instruction.EventCall n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_if_else_instruction + ( + final tonkadur.fate.v1.lang.instruction.IfElseInstruction n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_if_instruction + ( + final tonkadur.fate.v1.lang.instruction.IfInstruction n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_instruction_list + ( + final tonkadur.fate.v1.lang.instruction.InstructionList n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_macro_call + ( + final tonkadur.fate.v1.lang.instruction.MacroCall n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_player_choice + ( + final tonkadur.fate.v1.lang.instruction.PlayerChoice n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_player_choice_list + ( + final tonkadur.fate.v1.lang.instruction.PlayerChoiceList n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_remove_all_of_element + ( + final tonkadur.fate.v1.lang.instruction.RemoveAllOfElement n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_remove_element + ( + final tonkadur.fate.v1.lang.instruction.RemoveElement n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_sequence_call + ( + final tonkadur.fate.v1.lang.instruction.SequenceCall n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_set_value + ( + final tonkadur.fate.v1.lang.instruction.SetValue n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + /* Valued Nodes */ + public void visit_at_reference + ( + final tonkadur.fate.v1.lang.valued_node.AtReference n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_cast + ( + final tonkadur.fate.v1.lang.valued_node.Cast n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_cond_value + ( + final tonkadur.fate.v1.lang.valued_node.CondValue n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_constant + ( + final tonkadur.fate.v1.lang.valued_node.Constant n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_count_operator + ( + final tonkadur.fate.v1.lang.valued_node.CountOperator n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_field_reference + ( + final tonkadur.fate.v1.lang.valued_node.FieldReference n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_if_else_value + ( + final tonkadur.fate.v1.lang.valued_node.IfElseValue n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_is_member_operator + ( + final tonkadur.fate.v1.lang.valued_node.IsMemberOperator n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_macro_value_call + ( + final tonkadur.fate.v1.lang.valued_node.MacroValueCall n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_newline + ( + final tonkadur.fate.v1.lang.valued_node.Newline n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_operation + ( + final tonkadur.fate.v1.lang.valued_node.Operation n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_paragraph + ( + final tonkadur.fate.v1.lang.valued_node.Paragraph n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_parameter_reference + ( + final tonkadur.fate.v1.lang.valued_node.ParameterReference n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_ref_operator + ( + final tonkadur.fate.v1.lang.valued_node.RefOperator n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_sentence + ( + final tonkadur.fate.v1.lang.valued_node.Sentence n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_space + ( + final tonkadur.fate.v1.lang.valued_node.Space n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_text_with_effect + ( + final tonkadur.fate.v1.lang.valued_node.TextWithEffect n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_value_to_text + ( + final tonkadur.fate.v1.lang.valued_node.ValueToText n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } + + public void visit_variable_reference + ( + final tonkadur.fate.v1.lang.valued_node.VariableReference n + ) + throws Throwable + { + throw new UnhandledASTElementException(); + } +} |


