| summaryrefslogtreecommitdiff |
diff options
37 files changed, 844 insertions, 201 deletions
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Display.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Display.java index ed87078..e383a0d 100644 --- a/src/core/src/tonkadur/fate/v1/lang/instruction/Display.java +++ b/src/core/src/tonkadur/fate/v1/lang/instruction/Display.java @@ -10,14 +10,14 @@ import tonkadur.fate.v1.lang.type.Type; import tonkadur.fate.v1.lang.meta.NodeVisitor; import tonkadur.fate.v1.lang.meta.InstructionNode; -import tonkadur.fate.v1.lang.meta.TextNode; +import tonkadur.fate.v1.lang.meta.RichTextNode; public class Display extends InstructionNode { /***************************************************************************/ /**** MEMBERS **************************************************************/ /***************************************************************************/ - protected final TextNode content; + protected final RichTextNode content; /***************************************************************************/ /**** PROTECTED ************************************************************/ @@ -26,7 +26,7 @@ public class Display extends InstructionNode public Display ( final Origin origin, - final TextNode content + final RichTextNode content ) { super(origin); @@ -47,7 +47,7 @@ public class Display extends InstructionNode nv.visit_display(this); } - public TextNode get_content () + public RichTextNode get_content () { return content; } diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/PlayerChoice.java b/src/core/src/tonkadur/fate/v1/lang/instruction/PlayerChoice.java index e85a8de..e57fe2a 100644 --- a/src/core/src/tonkadur/fate/v1/lang/instruction/PlayerChoice.java +++ b/src/core/src/tonkadur/fate/v1/lang/instruction/PlayerChoice.java @@ -8,14 +8,14 @@ import tonkadur.fate.v1.lang.type.Type; import tonkadur.fate.v1.lang.meta.NodeVisitor; import tonkadur.fate.v1.lang.meta.InstructionNode; -import tonkadur.fate.v1.lang.meta.TextNode; +import tonkadur.fate.v1.lang.meta.RichTextNode; public class PlayerChoice extends InstructionNode { /***************************************************************************/ /**** MEMBERS **************************************************************/ /***************************************************************************/ - protected final TextNode text; + protected final RichTextNode text; protected final List<InstructionNode> effects; /***************************************************************************/ @@ -25,7 +25,7 @@ public class PlayerChoice extends InstructionNode public PlayerChoice ( final Origin origin, - final TextNode text, + final RichTextNode text, final List<InstructionNode> effects ) { @@ -44,7 +44,7 @@ public class PlayerChoice extends InstructionNode nv.visit_player_choice(this); } - public TextNode get_text () + public RichTextNode get_text () { return text; } diff --git a/src/core/src/tonkadur/fate/v1/lang/meta/NodeVisitor.java b/src/core/src/tonkadur/fate/v1/lang/meta/NodeVisitor.java index 0d90192..3b9527c 100644 --- a/src/core/src/tonkadur/fate/v1/lang/meta/NodeVisitor.java +++ b/src/core/src/tonkadur/fate/v1/lang/meta/NodeVisitor.java @@ -102,16 +102,10 @@ public interface NodeVisitor public void visit_ref_operator (final RefOperator n) throws Throwable; - public void visit_sentence (final Sentence n) - throws Throwable; - - public void visit_space (final Space n) - throws Throwable; - public void visit_text_with_effect (final TextWithEffect n) throws Throwable; - public void visit_value_to_text (final ValueToText n) + public void visit_value_to_rich_text (final ValueToRichText n) throws Throwable; public void visit_variable_reference (final VariableReference n) diff --git a/src/core/src/tonkadur/fate/v1/lang/meta/TextNode.java b/src/core/src/tonkadur/fate/v1/lang/meta/RichTextNode.java index fe4a829..7a4a44d 100644 --- a/src/core/src/tonkadur/fate/v1/lang/meta/TextNode.java +++ b/src/core/src/tonkadur/fate/v1/lang/meta/RichTextNode.java @@ -5,15 +5,15 @@ import tonkadur.parser.Origin; import tonkadur.fate.v1.lang.type.Type; -public abstract class TextNode extends ValueNode +public abstract class RichTextNode extends ValueNode { /***************************************************************************/ /**** PROTECTED ************************************************************/ /***************************************************************************/ /**** Constructors *********************************************************/ - protected TextNode (final Origin origin) + protected RichTextNode (final Origin origin) { - super(origin, Type.STRING); + super(origin, Type.RICH_TEXT); } /***************************************************************************/ diff --git a/src/core/src/tonkadur/fate/v1/lang/type/Type.java b/src/core/src/tonkadur/fate/v1/lang/type/Type.java index ec961d8..0cf19b4 100644 --- a/src/core/src/tonkadur/fate/v1/lang/type/Type.java +++ b/src/core/src/tonkadur/fate/v1/lang/type/Type.java @@ -25,8 +25,9 @@ public class Type extends DeclaredEntity public static final Type FLOAT; public static final Type INT; public static final Type LIST; - public static final Type SET; public static final Type REF; + public static final Type RICH_TEXT; + public static final Type SET; public static final Type STRING; public static final Set<Type> NUMBER_TYPES; @@ -49,8 +50,9 @@ public class Type extends DeclaredEntity FLOAT = new Type(base, null, "float"); INT = new Type(base, null, "int"); LIST = new Type(base, null, "list"); - SET = new Type(base, null, "set"); REF = new Type(base, null, "ref"); + RICH_TEXT = new Type(base, null, "rich text"); + SET = new Type(base, null, "set"); STRING = new Type(base, null, "string"); NUMBER_TYPES = new HashSet<Type>(); diff --git a/src/core/src/tonkadur/fate/v1/lang/valued_node/Constant.java b/src/core/src/tonkadur/fate/v1/lang/valued_node/Constant.java index 2fe40cc..abfe38d 100644 --- a/src/core/src/tonkadur/fate/v1/lang/valued_node/Constant.java +++ b/src/core/src/tonkadur/fate/v1/lang/valued_node/Constant.java @@ -43,6 +43,15 @@ public class Constant extends ValueNode return new Constant(origin, Type.BOOLEAN, value ? "true" : "false"); } + public static Constant build_string + ( + final Origin origin, + final String value + ) + { + return new Constant(origin, Type.STRING, value); + } + public static Constant build (final Origin origin, final String as_string) { try diff --git a/src/core/src/tonkadur/fate/v1/lang/valued_node/Newline.java b/src/core/src/tonkadur/fate/v1/lang/valued_node/Newline.java index 45d00ec..5698dc3 100644 --- a/src/core/src/tonkadur/fate/v1/lang/valued_node/Newline.java +++ b/src/core/src/tonkadur/fate/v1/lang/valued_node/Newline.java @@ -3,9 +3,9 @@ package tonkadur.fate.v1.lang.valued_node; import tonkadur.parser.Origin; import tonkadur.fate.v1.lang.meta.NodeVisitor; -import tonkadur.fate.v1.lang.meta.TextNode; +import tonkadur.fate.v1.lang.meta.RichTextNode; -public class Newline extends TextNode +public class Newline extends RichTextNode { /***************************************************************************/ /**** PUBLIC ***************************************************************/ diff --git a/src/core/src/tonkadur/fate/v1/lang/valued_node/Paragraph.java b/src/core/src/tonkadur/fate/v1/lang/valued_node/Paragraph.java index 358dc5f..5b022f9 100644 --- a/src/core/src/tonkadur/fate/v1/lang/valued_node/Paragraph.java +++ b/src/core/src/tonkadur/fate/v1/lang/valued_node/Paragraph.java @@ -5,14 +5,14 @@ import java.util.List; import tonkadur.parser.Origin; import tonkadur.fate.v1.lang.meta.NodeVisitor; -import tonkadur.fate.v1.lang.meta.TextNode; +import tonkadur.fate.v1.lang.meta.RichTextNode; -public class Paragraph extends TextNode +public class Paragraph extends RichTextNode { /***************************************************************************/ /**** MEMBERS **************************************************************/ /***************************************************************************/ - protected final List<TextNode> content; + protected final List<RichTextNode> content; /***************************************************************************/ /**** PROTECTED ************************************************************/ @@ -26,7 +26,7 @@ public class Paragraph extends TextNode public Paragraph ( final Origin origin, - final List<TextNode> content + final List<RichTextNode> content ) { super(origin); @@ -42,7 +42,7 @@ public class Paragraph extends TextNode nv.visit_paragraph(this); } - public List<TextNode> get_content () + public List<RichTextNode> get_content () { return content; } @@ -55,7 +55,7 @@ public class Paragraph extends TextNode sb.append("(Paragraph "); - for (final TextNode text: content) + for (final RichTextNode text: content) { sb.append(content.toString()); } diff --git a/src/core/src/tonkadur/fate/v1/lang/valued_node/Sentence.java b/src/core/src/tonkadur/fate/v1/lang/valued_node/Sentence.java deleted file mode 100644 index 5166fd9..0000000 --- a/src/core/src/tonkadur/fate/v1/lang/valued_node/Sentence.java +++ /dev/null @@ -1,62 +0,0 @@ -package tonkadur.fate.v1.lang.valued_node; - -import tonkadur.parser.Origin; - -import tonkadur.fate.v1.lang.type.Type; - -import tonkadur.fate.v1.lang.meta.NodeVisitor; -import tonkadur.fate.v1.lang.meta.TextNode; - -public class Sentence extends TextNode -{ - /***************************************************************************/ - /**** MEMBERS **************************************************************/ - /***************************************************************************/ - protected final String text; - - /***************************************************************************/ - /**** PROTECTED ************************************************************/ - /***************************************************************************/ - /**** Constructors *********************************************************/ - - /***************************************************************************/ - /**** PUBLIC ***************************************************************/ - /***************************************************************************/ - /**** Constructors *********************************************************/ - public Sentence - ( - final Origin origin, - final String text - ) - { - super(origin); - - this.text = text; - } - - /**** Accessors ************************************************************/ - @Override - public void visit (final NodeVisitor nv) - throws Throwable - { - nv.visit_sentence(this); - } - - public String get_text () - { - return text; - } - - /**** Misc. ****************************************************************/ - @Override - public String toString () - { - final StringBuilder sb = new StringBuilder(); - - sb.append("(Sentence "); - sb.append(text); - sb.append(")"); - - return sb.toString(); - } -} diff --git a/src/core/src/tonkadur/fate/v1/lang/valued_node/Space.java b/src/core/src/tonkadur/fate/v1/lang/valued_node/Space.java deleted file mode 100644 index a6d60ca..0000000 --- a/src/core/src/tonkadur/fate/v1/lang/valued_node/Space.java +++ /dev/null @@ -1,33 +0,0 @@ -package tonkadur.fate.v1.lang.valued_node; - -import tonkadur.parser.Origin; - -import tonkadur.fate.v1.lang.meta.NodeVisitor; -import tonkadur.fate.v1.lang.meta.TextNode; - -public class Space extends TextNode -{ - /***************************************************************************/ - /**** PUBLIC ***************************************************************/ - /***************************************************************************/ - /**** Constructors *********************************************************/ - public Space (final Origin origin) - { - super(origin); - } - - /**** Accessors ************************************************************/ - @Override - public void visit (final NodeVisitor nv) - throws Throwable - { - nv.visit_space(this); - } - - /**** Misc. ****************************************************************/ - @Override - public String toString () - { - return "(Space)"; - } -} diff --git a/src/core/src/tonkadur/fate/v1/lang/valued_node/TextWithEffect.java b/src/core/src/tonkadur/fate/v1/lang/valued_node/TextWithEffect.java index 68413d4..457258a 100644 --- a/src/core/src/tonkadur/fate/v1/lang/valued_node/TextWithEffect.java +++ b/src/core/src/tonkadur/fate/v1/lang/valued_node/TextWithEffect.java @@ -19,17 +19,17 @@ import tonkadur.fate.v1.lang.TextEffect; import tonkadur.fate.v1.lang.type.Type; import tonkadur.fate.v1.lang.meta.NodeVisitor; -import tonkadur.fate.v1.lang.meta.TextNode; +import tonkadur.fate.v1.lang.meta.RichTextNode; import tonkadur.fate.v1.lang.meta.ValueNode; -public class TextWithEffect extends TextNode +public class TextWithEffect extends RichTextNode { /***************************************************************************/ /**** MEMBERS **************************************************************/ /***************************************************************************/ protected final TextEffect effect; protected final List<ValueNode> parameters; - protected final TextNode text; + protected final RichTextNode text; /***************************************************************************/ /**** PROTECTED ************************************************************/ @@ -40,7 +40,7 @@ public class TextWithEffect extends TextNode final Origin origin, final TextEffect effect, final List<ValueNode> parameters, - final TextNode text + final RichTextNode text ) { super(origin); @@ -59,7 +59,7 @@ public class TextWithEffect extends TextNode final Origin origin, final TextEffect effect, final List<ValueNode> parameters, - final TextNode text + final RichTextNode text ) throws Throwable { @@ -156,7 +156,7 @@ public class TextWithEffect extends TextNode return parameters; } - public TextNode get_text () + public RichTextNode get_text () { return text; } diff --git a/src/core/src/tonkadur/fate/v1/lang/valued_node/ValueToText.java b/src/core/src/tonkadur/fate/v1/lang/valued_node/ValueToRichText.java index a8b4df6..1a84986 100644 --- a/src/core/src/tonkadur/fate/v1/lang/valued_node/ValueToText.java +++ b/src/core/src/tonkadur/fate/v1/lang/valued_node/ValueToRichText.java @@ -8,10 +8,10 @@ import tonkadur.fate.v1.error.IncomparableTypeException; import tonkadur.fate.v1.lang.type.Type; import tonkadur.fate.v1.lang.meta.NodeVisitor; -import tonkadur.fate.v1.lang.meta.TextNode; +import tonkadur.fate.v1.lang.meta.RichTextNode; import tonkadur.fate.v1.lang.meta.ValueNode; -public class ValueToText extends TextNode +public class ValueToRichText extends RichTextNode { /***************************************************************************/ /**** MEMBERS **************************************************************/ @@ -22,7 +22,7 @@ public class ValueToText extends TextNode /**** PROTECTED ************************************************************/ /***************************************************************************/ /**** Constructors *********************************************************/ - protected ValueToText (final ValueNode value) + protected ValueToRichText (final ValueNode value) { super(value.get_origin()); @@ -33,7 +33,7 @@ public class ValueToText extends TextNode /**** PUBLIC ***************************************************************/ /***************************************************************************/ /**** Constructors *********************************************************/ - public static ValueToText build (final ValueNode value) + public static ValueToRichText build (final ValueNode value) throws IncompatibleTypeException, IncomparableTypeException @@ -44,11 +44,11 @@ public class ValueToText extends TextNode if (value_base_type.equals(Type.STRING)) { - return new ValueToText(value); + return new ValueToRichText(value); } return - new ValueToText + new ValueToRichText ( Cast.build ( @@ -65,7 +65,7 @@ public class ValueToText extends TextNode public void visit (final NodeVisitor nv) throws Throwable { - nv.visit_value_to_text(this); + nv.visit_value_to_rich_text(this); } public ValueNode get_value () @@ -79,7 +79,7 @@ public class ValueToText extends TextNode { final StringBuilder sb = new StringBuilder(); - sb.append("(ValueToText "); + sb.append("(ValueToRichText "); sb.append(value.toString()); sb.append(")"); diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 index 2a08b9e..f9d9638 100644 --- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 +++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 @@ -1053,10 +1053,10 @@ catch [final Throwable e] } paragraph -returns [TextNode result] +returns [RichTextNode result] @init { - final List<TextNode> content = new ArrayList(); + final List<RichTextNode> content = new ArrayList(); } : first=text @@ -1068,7 +1068,17 @@ returns [TextNode result] { if (!(content.get(content.size() - 1) instanceof Newline)) { - content.add(new Space(($next_a.result.get_origin()))); + content.add + ( + ValueToRichText.build + ( + Constant.build_string + ( + $next_a.result.get_origin(), + " " + ) + ) + ); } content.add(($next_a.result)); @@ -1095,9 +1105,20 @@ returns [TextNode result] } } ; +catch [final Throwable e] +{ + if ((e.getMessage() == null) || !e.getMessage().startsWith("Require")) + { + throw new ParseCancellationException(CONTEXT.toString() + ((e.getMessage() == null) ? "" : e.getMessage()), e); + } + else + { + throw new ParseCancellationException(e); + } +} text -returns [TextNode result]: +returns [RichTextNode result]: sentence { $result = ($sentence.result); @@ -1182,7 +1203,7 @@ returns [TextNode result]: | non_text_value { - $result = ValueToText.build(($non_text_value.result)); + $result = ValueToRichText.build(($non_text_value.result)); } ; catch [final Throwable e] @@ -1198,7 +1219,7 @@ catch [final Throwable e] } sentence -returns [TextNode result] +returns [RichTextNode result] @init { final StringBuilder string_builder = new StringBuilder(); @@ -1218,17 +1239,31 @@ returns [TextNode result] )* { $result = - new Sentence + ValueToRichText.build ( - CONTEXT.get_origin_at + Constant.build_string ( - ($first_word.getLine()), - ($first_word.getCharPositionInLine()) - ), - string_builder.toString() + CONTEXT.get_origin_at + ( + ($first_word.getLine()), + ($first_word.getCharPositionInLine()) + ), + string_builder.toString() + ) ); } ; +catch [final Throwable e] +{ + if ((e.getMessage() == null) || !e.getMessage().startsWith("Require")) + { + throw new ParseCancellationException(CONTEXT.toString() + ((e.getMessage() == null) ? "" : e.getMessage()), e); + } + else + { + throw new ParseCancellationException(e); + } +} type returns [Type result] diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/AbsoluteRef.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/AbsoluteRef.java new file mode 100644 index 0000000..f0d6009 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/AbsoluteRef.java @@ -0,0 +1,39 @@ +package tonkadur.wyrd.v1.lang.computation; + +import java.util.List; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class AbsoluteRef extends Computation +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final List<String> accesses; + protected final Type target_type; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public AbsoluteRef (final List<String> accesses, final Type target_type) + { + super(Type.POINTER); + + this.accesses = accesses; + this.target_type = target_type; + } + + /**** Accessors ************************************************************/ + public List<String> get_accesses () + { + return accesses; + } + + public Type get_target_type () + { + return target_type; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/AddRichTextEffect.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/AddRichTextEffect.java new file mode 100644 index 0000000..318e418 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/AddRichTextEffect.java @@ -0,0 +1,52 @@ +package tonkadur.wyrd.v1.lang.computation; + +import java.util.List; +import java.util.Map; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class AddRichTextEffect extends Computation +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final String effect_name; + protected final List<Computation> effect_parameters; + protected final List<Computation> content; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public AddRichTextEffect + ( + final String effect_name, + final List<Computation> effect_parameters, + final List<Computation> content + ) + { + super(Type.RICH_TEXT); + + this.effect_name = effect_name; + this.effect_parameters = effect_parameters; + this.content = content; + } + + /**** Accessors ************************************************************/ + public String get_effect_name () + { + return effect_name; + } + + public List<Computation> get_effect_parameters () + { + return effect_parameters; + } + + public List<Computation> get_content () + { + return content; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/Cast.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/Cast.java new file mode 100644 index 0000000..a84e77e --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/Cast.java @@ -0,0 +1,30 @@ +package tonkadur.wyrd.v1.lang.computation; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class Cast extends Computation +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation parent; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public Cast (final Computation parent, final Type to) + { + super(to); + + this.parent = parent; + } + + /**** Accessors ************************************************************/ + public Computation get_parent () + { + return parent; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/Constant.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/Constant.java new file mode 100644 index 0000000..283f567 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/Constant.java @@ -0,0 +1,30 @@ +package tonkadur.wyrd.v1.lang.computation; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class Constant extends Computation +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final String as_string; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public Constant (final Type type, final String as_string) + { + super(type); + + this.as_string = as_string; + } + + /**** Accessors ************************************************************/ + public String get_as_string () + { + return as_string; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/IfElseComputation.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/IfElseComputation.java new file mode 100644 index 0000000..ef3cf06 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/IfElseComputation.java @@ -0,0 +1,49 @@ +package tonkadur.wyrd.v1.lang.computation; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class IfElseComputation extends Computation +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation condition; + protected final Computation if_true; + protected final Computation if_false; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public IfElseComputation + ( + final Computation condition, + final Computation if_true, + final Computation if_false + ) + { + super(if_true.get_type()); + + this.condition = condition; + this.if_true = if_true; + this.if_false = if_false; + } + + /**** Accessors ************************************************************/ + public Computation get_condition () + { + return condition; + } + + public Computation get_if_true () + { + return if_true; + } + + public Computation get_if_false () + { + return if_false; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/Newline.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/Newline.java new file mode 100644 index 0000000..aa561b0 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/Newline.java @@ -0,0 +1,21 @@ +package tonkadur.wyrd.v1.lang.computation; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class Newline extends Computation +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public Newline () + { + super(Type.STRING); + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/Operation.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/Operation.java new file mode 100644 index 0000000..994138a --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/Operation.java @@ -0,0 +1,39 @@ +package tonkadur.wyrd.v1.lang.computation; + +import java.util.List; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class Operation extends Computation +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final String operator; + protected final List<Computation> parameters; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public Operation + ( + final Type result_type, + final String operator, + final List<Computation> parameters + ) + { + super(result_type); + + this.operator = operator; + this.parameters = parameters; + } + + /**** Accessors ************************************************************/ + public List<Computation> get_parameters () + { + return parameters; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/RelativeRef.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/RelativeRef.java new file mode 100644 index 0000000..2de3a5d --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/RelativeRef.java @@ -0,0 +1,51 @@ +package tonkadur.wyrd.v1.lang.computation; + +import java.util.List; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class RelativeRef extends Computation +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation parent; + protected final List<String> accesses; + protected final Type target_type; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public RelativeRef + ( + final Computation parent, + final List<String> accesses, + final Type target_type + ) + { + super(Type.POINTER); + + this.parent = parent; + this.accesses = accesses; + this.target_type = target_type; + } + + /**** Accessors ************************************************************/ + public Computation get_parent () + { + return parent; + } + + public List<String> get_accesses () + { + return accesses; + } + + public Type get_target_type () + { + return target_type; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/Size.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/Size.java new file mode 100644 index 0000000..22286d6 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/Size.java @@ -0,0 +1,33 @@ +package tonkadur.wyrd.v1.lang.computation; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class Size extends Computation +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation collection; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public Size + ( + final Computation collection + ) + { + super(Type.INT); + + this.collection = collection; + } + + /**** Accessors ************************************************************/ + public Computation get_collection () + { + return collection; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/ValueOf.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/ValueOf.java new file mode 100644 index 0000000..7d214d8 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/ValueOf.java @@ -0,0 +1,30 @@ +package tonkadur.wyrd.v1.lang.computation; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class ValueOf extends Computation +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation parent; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public ValueOf (final Computation parent, final Type to) + { + super(to); + + this.parent = parent; + } + + /**** Accessors ************************************************************/ + public Computation get_parent () + { + return parent; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/AddChoice.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/AddChoice.java new file mode 100644 index 0000000..2b93cab --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/AddChoice.java @@ -0,0 +1,36 @@ +package tonkadur.wyrd.v1.lang.instruction; + +import java.util.List; + +import tonkadur.wyrd.v1.lang.meta.Computation; +import tonkadur.wyrd.v1.lang.meta.Instruction; + +public class AddChoice extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation label; + protected final List<Instruction> effect; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public AddChoice (final Computation label, final List<Instruction> effect) + { + this.label = label; + this.effect = effect; + } + + /**** Accessors ************************************************************/ + public Computation get_label () + { + return label; + } + + public List<Instruction> get_effect () + { + return effect; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/Assert.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/Assert.java new file mode 100644 index 0000000..2ec3869 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/Assert.java @@ -0,0 +1,27 @@ +package tonkadur.wyrd.v1.lang.instruction; + +import tonkadur.wyrd.v1.lang.meta.Computation; +import tonkadur.wyrd.v1.lang.meta.Instruction; + +public class Assert extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation condition; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public Assert (final Computation condition) + { + this.condition = condition; + } + + /**** Accessors ************************************************************/ + public Computation get_condition () + { + return condition; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/Display.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/Display.java new file mode 100644 index 0000000..3cae965 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/Display.java @@ -0,0 +1,29 @@ +package tonkadur.wyrd.v1.lang.instruction; + +import java.util.List; + +import tonkadur.wyrd.v1.lang.meta.Computation; +import tonkadur.wyrd.v1.lang.meta.Instruction; + +public class Display extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final List<Computation> content; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public Display (final List<Computation> content) + { + this.content = content; + } + + /**** Accessors ************************************************************/ + public List<Computation> get_content () + { + return content; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/EventCall.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/EventCall.java new file mode 100644 index 0000000..0dabde8 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/EventCall.java @@ -0,0 +1,36 @@ +package tonkadur.wyrd.v1.lang.instruction; + +import java.util.List; + +import tonkadur.wyrd.v1.lang.meta.Computation; +import tonkadur.wyrd.v1.lang.meta.Instruction; + +public class EventCall extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final String name; + protected final List<Computation> parameters; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public EventCall (final String name, final List<Computation> parameters) + { + this.name = name; + this.parameters = parameters; + } + + /**** Accessors ************************************************************/ + public String get_name () + { + return name; + } + + public List<Computation> get_parameters () + { + return parameters; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/IfElseInstruction.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/IfElseInstruction.java new file mode 100644 index 0000000..3ea99f3 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/IfElseInstruction.java @@ -0,0 +1,50 @@ +package tonkadur.wyrd.v1.lang.computation; + +import java.util.List; + +import tonkadur.wyrd.v1.lang.type.Type; + +import tonkadur.wyrd.v1.lang.meta.Instruction; +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class IfElseInstruction extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation condition; + protected final List<Instruction> if_true; + protected final List<Instruction> if_false; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public IfElseInstruction + ( + final Computation condition, + final List<Instruction> if_true, + final List<Instruction> if_false + ) + { + this.condition = condition; + this.if_true = if_true; + this.if_false = if_false; + } + + /**** Accessors ************************************************************/ + public Computation get_condition () + { + return condition; + } + + public List<Instruction> get_if_true () + { + return if_true; + } + + public List<Instruction> get_if_false () + { + return if_false; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/NOP.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/NOP.java new file mode 100644 index 0000000..46f7b3f --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/NOP.java @@ -0,0 +1,19 @@ +package tonkadur.wyrd.v1.lang.instruction; + +import tonkadur.wyrd.v1.lang.meta.Instruction; + +public class NOP extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public NOP () + { + } + +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/ResolveChoices.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/ResolveChoices.java new file mode 100644 index 0000000..9963a05 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/ResolveChoices.java @@ -0,0 +1,18 @@ +package tonkadur.wyrd.v1.lang.instruction; + +import tonkadur.wyrd.v1.lang.meta.Instruction; + +public class ResolveChoices extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public ResolveChoices () + { + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/SequenceCall.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/SequenceCall.java new file mode 100644 index 0000000..51a6265 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/SequenceCall.java @@ -0,0 +1,26 @@ +package tonkadur.wyrd.v1.lang.instruction; + +import tonkadur.wyrd.v1.lang.meta.Instruction; + +public class SequenceCall extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final String name; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public SequenceCall (final String name) + { + this.name = name; + } + + /**** Accessors ************************************************************/ + public String get_name () + { + return name; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/SetValue.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/SetValue.java new file mode 100644 index 0000000..5842874 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/SetValue.java @@ -0,0 +1,34 @@ +package tonkadur.wyrd.v1.lang.computation; + +import tonkadur.wyrd.v1.lang.meta.Instruction; +import tonkadur.wyrd.v1.lang.meta.Computation; + +public class SetValue extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation reference; + protected final Computation value; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public SetValue (final Computation reference, final Computation value) + { + this.reference = reference; + this.value = value; + } + + /**** Accessors ************************************************************/ + public Computation get_reference () + { + return reference; + } + + public Computation get_value () + { + return value; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/While.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/While.java new file mode 100644 index 0000000..baaa8ed --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/While.java @@ -0,0 +1,40 @@ +package tonkadur.wyrd.v1.lang.instruction; + +import java.util.List; + +import tonkadur.wyrd.v1.lang.meta.Computation; +import tonkadur.wyrd.v1.lang.meta.Instruction; + +public class While extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation condition; + protected final List<Instruction> body; + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public While + ( + final Computation condition, + final List<Instruction> body + ) + { + this.condition = condition; + this.body = body; + } + + /**** Accessors ************************************************************/ + public Computation get_condition () + { + return condition; + } + + public List<Instruction> get_body () + { + return body; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/meta/Computation.java b/src/core/src/tonkadur/wyrd/v1/lang/meta/Computation.java index 793bb0a..8745b24 100644 --- a/src/core/src/tonkadur/wyrd/v1/lang/meta/Computation.java +++ b/src/core/src/tonkadur/wyrd/v1/lang/meta/Computation.java @@ -1,7 +1,29 @@ package tonkadur.wyrd.v1.lang.meta; +import tonkadur.wyrd.v1.lang.type.Type; + public abstract class Computation { - /* Do we need to know the type? */ - /* protected final Type type; */ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Type type; + + /***************************************************************************/ + /**** PROTECTED ************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + protected Computation (final Type type) + { + this.type = type; + } + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Accessors ************************************************************/ + public Type get_type () + { + return type; + } } diff --git a/src/core/src/tonkadur/wyrd/v1/lang/type/CollectionType.java b/src/core/src/tonkadur/wyrd/v1/lang/type/CollectionType.java deleted file mode 100644 index 8c63e2f..0000000 --- a/src/core/src/tonkadur/wyrd/v1/lang/type/CollectionType.java +++ /dev/null @@ -1,50 +0,0 @@ -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/MapType.java b/src/core/src/tonkadur/wyrd/v1/lang/type/MapType.java new file mode 100644 index 0000000..c80a78a --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/lang/type/MapType.java @@ -0,0 +1,33 @@ +package tonkadur.wyrd.v1.lang.type; + +public class MapType extends Type +{ + public static final MapType MAP_TO_BOOLEAN; + public static final MapType MAP_TO_FLOAT; + public static final MapType MAP_TO_INT; + public static final MapType MAP_TO_STRING; + + static + { + MAP_TO_BOOLEAN = new MapType(Type.BOOLEAN); + MAP_TO_FLOAT = new MapType(Type.FLOAT); + MAP_TO_INT = new MapType(Type.INT); + MAP_TO_STRING = new MapType(Type.STRING); + } + + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Type member_type; + + protected MapType (final Type member_type) + { + super("(Map String->" + member_type.name + ")"); + this.member_type = member_type; + } + + public Type get_member_type () + { + return member_type; + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/type/Type.java b/src/core/src/tonkadur/wyrd/v1/lang/type/Type.java index 0eff344..8bb2aa8 100644 --- a/src/core/src/tonkadur/wyrd/v1/lang/type/Type.java +++ b/src/core/src/tonkadur/wyrd/v1/lang/type/Type.java @@ -5,6 +5,8 @@ public class Type public static final Type BOOLEAN; public static final Type FLOAT; public static final Type INT; + public static final Type POINTER; + public static final Type RICH_TEXT; public static final Type STRING; static @@ -12,6 +14,8 @@ public class Type BOOLEAN = new Type("boolean"); FLOAT = new Type("float"); INT = new Type("int"); + POINTER = new Type("pointer"); + RICH_TEXT = new Type("rich_text"); STRING = new Type("string"); } |


