summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/src/tonkadur/fate/v1/Utils.java38
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/Access.java2
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/AccessAsReference.java152
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/AccessPointer.java14
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/AtReference.java2
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/FieldAccess.java2
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/FieldReference.java152
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/LambdaEvaluation.java19
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/meta/Reference.java48
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/type/PointerType.java2
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/type/Type.java8
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateLexer.g4513
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateParser.g45232
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/Parser.java229
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java31
15 files changed, 1327 insertions, 5117 deletions
diff --git a/src/core/src/tonkadur/fate/v1/Utils.java b/src/core/src/tonkadur/fate/v1/Utils.java
index 9c7466d..4ab56e4 100644
--- a/src/core/src/tonkadur/fate/v1/Utils.java
+++ b/src/core/src/tonkadur/fate/v1/Utils.java
@@ -20,42 +20,4 @@ public class Utils
{
/* Utility class. */
private Utils () {}
-
- public static void add_file_content
- (
- final String filename,
- final Context context,
- final World world
- )
- throws IOException
- {
- add_file_content(filename, context, null, world);
- }
-
- public static void add_file_content
- (
- final String filename,
- final Context context,
- final Deque<Map<String, Variable>> local_variables,
- final World world
- )
- throws IOException
- {
- final CommonTokenStream tokens;
- final FateLexer lexer;
- final FateParser parser;
-
- lexer = new FateLexer(CharStreams.fromFileName(filename));
- tokens = new CommonTokenStream(lexer);
- parser = new FateParser(tokens);
-
- parser.fate_file(context, local_variables, world);
-
- world.add_loaded_file(filename);
-
- if (parser.getNumberOfSyntaxErrors() > 0)
- {
- throw new IOException("There were syntaxic errors in " + filename);
- }
- }
}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/Access.java b/src/core/src/tonkadur/fate/v1/lang/computation/Access.java
index f914b1c..843874c 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/Access.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/Access.java
@@ -58,7 +58,7 @@ public class Access extends Computation
current_type = parent.get_type();
- while (current_type.get_act_as_type().equals(Type.REF))
+ while (current_type.get_act_as_type().equals(Type.PTR))
{
parent = AtReference.build(origin, parent);
current_type = parent.get_type();
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/AccessAsReference.java b/src/core/src/tonkadur/fate/v1/lang/computation/AccessAsReference.java
deleted file mode 100644
index 1fe94a0..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/AccessAsReference.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collections;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-
-import tonkadur.error.ErrorManager;
-
-import tonkadur.fate.v1.error.InvalidTypeException;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Reference;
-
-import tonkadur.fate.v1.lang.type.CollectionType;
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.PointerType;
-
-public class AccessAsReference extends Reference
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Reference parent;
- protected final Computation index;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected AccessAsReference
- (
- final Origin origin,
- final Reference parent,
- final Type type,
- final Computation index
- )
- {
- super
- (
- origin,
- type,
- (parent.get_name() + "." + index.toString())
- );
-
- this.parent = parent;
- this.index = index;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static AccessAsReference build
- (
- final Origin origin,
- Reference parent,
- final Computation index
- )
- throws InvalidTypeException
- {
- Type current_type;
-
- current_type = parent.get_type();
-
- while (current_type.get_act_as_type().equals(Type.REF))
- {
- parent = AtReference.build(origin, parent);
- current_type = parent.get_type();
- }
-
- if (!index.get_type().can_be_used_as(Type.INT))
- {
- ErrorManager.handle
- (
- new InvalidTypeException
- (
- index.get_origin(),
- current_type,
- Collections.singleton(Type.INT),
- parent.get_name()
- )
- );
- }
-
- if (!(current_type instanceof CollectionType))
- {
- ErrorManager.handle
- (
- new InvalidTypeException
- (
- origin,
- current_type,
- Collections.singleton(Type.LIST),
- parent.get_name()
- )
- );
-
- current_type = Type.ANY;
- }
- else
- {
- current_type = ((CollectionType) current_type).get_content_type();
- }
-
- return
- new AccessAsReference
- (
- origin,
- parent,
- current_type,
- index
- );
- }
-
-
- /**** AccessAsReferenceors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_access_as_reference(this);
- }
-
- public Computation get_index ()
- {
- return index;
- }
-
- public Reference get_parent ()
- {
- return parent;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(AccessAsReference (");
- sb.append(type.get_name());
- sb.append(") ");
- sb.append(name);
- sb.append(".");
- sb.append(index.toString());
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/AccessPointer.java b/src/core/src/tonkadur/fate/v1/lang/computation/AccessPointer.java
index 22eabd6..fbc2ab7 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/AccessPointer.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/AccessPointer.java
@@ -11,7 +11,7 @@ import tonkadur.fate.v1.error.InvalidTypeException;
import tonkadur.fate.v1.lang.meta.ComputationVisitor;
import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Reference;
+import tonkadur.fate.v1.lang.meta.Computation;
import tonkadur.fate.v1.lang.type.CollectionType;
import tonkadur.fate.v1.lang.type.PointerType;
@@ -22,7 +22,7 @@ public class AccessPointer extends Computation
/***************************************************************************/
/**** MEMBERS **************************************************************/
/***************************************************************************/
- protected final Reference parent;
+ protected final Computation parent;
protected final Computation index;
/***************************************************************************/
@@ -32,7 +32,7 @@ public class AccessPointer extends Computation
protected AccessPointer
(
final Origin origin,
- final Reference parent,
+ final Computation parent,
final Type type,
final Computation index
)
@@ -54,7 +54,7 @@ public class AccessPointer extends Computation
public static AccessPointer build
(
final Origin origin,
- Reference parent,
+ Computation parent,
final Computation index
)
throws InvalidTypeException
@@ -63,9 +63,9 @@ public class AccessPointer extends Computation
current_type = parent.get_type();
- while (current_type.get_act_as_type().equals(Type.REF))
+ while (current_type.get_act_as_type().equals(Type.PTR))
{
- parent = AtReference.build(origin, parent);
+ parent = AtComputation.build(origin, parent);
current_type = parent.get_type();
}
@@ -120,7 +120,7 @@ public class AccessPointer extends Computation
return index;
}
- public Reference get_parent ()
+ public Computation get_parent ()
{
return parent;
}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/AtReference.java b/src/core/src/tonkadur/fate/v1/lang/computation/AtReference.java
index 7e68f11..7ae1e1f 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/AtReference.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/AtReference.java
@@ -65,7 +65,7 @@ public class AtReference extends Reference
(
origin,
current_type,
- Collections.singleton(Type.REF)
+ Collections.singleton(Type.PTR)
)
);
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/FieldAccess.java b/src/core/src/tonkadur/fate/v1/lang/computation/FieldAccess.java
index 3c4279d..56708ff 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/FieldAccess.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/FieldAccess.java
@@ -61,7 +61,7 @@ public class FieldAccess extends Computation
current_type = parent.get_type();
- while (current_type.get_act_as_type().equals(Type.REF))
+ while (current_type.get_act_as_type().equals(Type.PTR))
{
parent = AtReference.build(origin, (Reference) parent);
current_type = parent.get_type();
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/FieldReference.java b/src/core/src/tonkadur/fate/v1/lang/computation/FieldReference.java
deleted file mode 100644
index 1c9a592..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/FieldReference.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collections;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-
-import tonkadur.error.ErrorManager;
-
-import tonkadur.fate.v1.error.InvalidTypeException;
-import tonkadur.fate.v1.error.UnknownStructureFieldException;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.Computation;
-
-import tonkadur.fate.v1.lang.type.StructType;
-import tonkadur.fate.v1.lang.type.Type;
-
-public class FieldReference extends Reference
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation parent;
- protected final String field_name;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected FieldReference
- (
- final Origin origin,
- final Computation parent,
- final Type type,
- final String field_name
- )
- {
- super(origin, type, (parent.toString() + "." + field_name));
-
- this.parent = parent;
- this.field_name = field_name;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static FieldReference build
- (
- final Origin origin,
- Computation parent,
- final String field
- )
- throws
- InvalidTypeException,
- UnknownStructureFieldException
- {
- Type current_type;
-
- current_type = parent.get_type();
-
- while (current_type.get_act_as_type().equals(Type.REF))
- {
- parent = AtReference.build(origin, (Reference) parent);
- current_type = parent.get_type();
- }
-
- if (!(current_type instanceof StructType))
- {
- ErrorManager.handle
- (
- new InvalidTypeException
- (
- origin,
- current_type,
- Collections.singleton(Type.DICT),
- parent.toString()
- )
- );
-
- current_type = Type.ANY;
- }
- else
- {
- current_type = ((StructType) current_type).get_field_type(origin, field);
- }
-
- return new FieldReference(origin, parent, current_type, field);
- }
-
- public static FieldReference build
- (
- final Origin origin,
- Computation parent,
- final List<String> field_sequence
- )
- throws
- InvalidTypeException,
- UnknownStructureFieldException
- {
- for (final String field: field_sequence)
- {
- parent = build(origin, parent, field);
- }
-
- if (parent instanceof FieldReference)
- {
- return (FieldReference) parent;
- }
- else
- {
- return null;
- }
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_field_reference(this);
- }
-
- public String get_field_name ()
- {
- return field_name;
- }
-
- public Computation get_parent ()
- {
- return parent;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(FieldReference (");
- sb.append(type.get_name());
- sb.append(") ");
- sb.append(parent.toString());
- sb.append(" ");
- sb.append(field_name);
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/LambdaEvaluation.java b/src/core/src/tonkadur/fate/v1/lang/computation/LambdaEvaluation.java
index e29ac6b..fc66a49 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/LambdaEvaluation.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/LambdaEvaluation.java
@@ -10,7 +10,6 @@ import tonkadur.fate.v1.lang.type.LambdaType;
import tonkadur.fate.v1.lang.meta.ComputationVisitor;
import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Reference;
import tonkadur.fate.v1.lang.meta.RecurrentChecks;
public class LambdaEvaluation extends Computation
@@ -18,7 +17,7 @@ public class LambdaEvaluation extends Computation
/***************************************************************************/
/**** MEMBERS **************************************************************/
/***************************************************************************/
- protected final Reference lambda_function;
+ protected final Computation lambda_function;
protected final List<Computation> parameters;
/***************************************************************************/
@@ -28,7 +27,7 @@ public class LambdaEvaluation extends Computation
protected LambdaEvaluation
(
final Origin origin,
- final Reference lambda_function,
+ final Computation lambda_function,
final List<Computation> parameters,
final Type act_as
)
@@ -46,20 +45,24 @@ public class LambdaEvaluation extends Computation
public static LambdaEvaluation build
(
final Origin origin,
- final Reference reference,
+ final Computation lambda_function,
final List<Computation> parameters
)
throws ParsingError
{
- RecurrentChecks.assert_lambda_matches_computations(reference, parameters);
+ RecurrentChecks.assert_lambda_matches_computations
+ (
+ lambda_function,
+ parameters
+ );
return
new LambdaEvaluation
(
origin,
- reference,
+ lambda_function,
parameters,
- (((LambdaType) reference.get_type()).get_return_type())
+ (((LambdaType) lambda_function.get_type()).get_return_type())
);
}
@@ -71,7 +74,7 @@ public class LambdaEvaluation extends Computation
cv.visit_lambda_evaluation(this);
}
- public Reference get_lambda_function_reference ()
+ public Computation get_lambda_function ()
{
return lambda_function;
}
diff --git a/src/core/src/tonkadur/fate/v1/lang/meta/Reference.java b/src/core/src/tonkadur/fate/v1/lang/meta/Reference.java
deleted file mode 100644
index 52f9057..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/meta/Reference.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package tonkadur.fate.v1.lang.meta;
-
-import tonkadur.parser.Origin;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-public abstract class Reference extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final String name;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected Reference (final Origin origin, final Type type, final String name)
- {
- super(origin, type);
-
- this.name = name;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Accessors ************************************************************/
- public String get_name ()
- {
- return name;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(");
- sb.append(type.get_name());
- sb.append(" Reference ");
- sb.append(name);
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/type/PointerType.java b/src/core/src/tonkadur/fate/v1/lang/type/PointerType.java
index 57e3450..0269cf7 100644
--- a/src/core/src/tonkadur/fate/v1/lang/type/PointerType.java
+++ b/src/core/src/tonkadur/fate/v1/lang/type/PointerType.java
@@ -77,7 +77,7 @@ public class PointerType extends Type
@Override
public Type get_act_as_type ()
{
- return Type.REF;
+ return Type.PTR;
}
/**** Misc. ****************************************************************/
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 850afeb..4385ed0 100644
--- a/src/core/src/tonkadur/fate/v1/lang/type/Type.java
+++ b/src/core/src/tonkadur/fate/v1/lang/type/Type.java
@@ -27,7 +27,7 @@ public class Type extends DeclaredEntity
public static final Type INT;
public static final Type LAMBDA;
public static final Type LIST;
- public static final Type REF;
+ public static final Type PTR;
public static final Type TEXT;
public static final Type SEQUENCE;
public static final Type SET;
@@ -56,7 +56,7 @@ public class Type extends DeclaredEntity
INT = new Type(base, null, "int");
LAMBDA = new Type(base, null, "lambda");
LIST = new Type(base, null, "list");
- REF = new Type(base, null, "ref");
+ PTR = new Type(base, null, "ptr");
TEXT = new Type(base, null, "text");
SEQUENCE = new Type(base, null, "sequence");
SET = new Type(base, null, "set");
@@ -71,7 +71,7 @@ public class Type extends DeclaredEntity
ALL_TYPES.add(INT);
ALL_TYPES.add(LAMBDA);
ALL_TYPES.add(LIST);
- ALL_TYPES.add(REF);
+ ALL_TYPES.add(PTR);
ALL_TYPES.add(TEXT);
ALL_TYPES.add(SEQUENCE);
ALL_TYPES.add(SET);
@@ -90,7 +90,7 @@ public class Type extends DeclaredEntity
COMPARABLE_TYPES.add(LAMBDA);
COMPARABLE_TYPES.add(STRING);
COMPARABLE_TYPES.add(BOOL);
- COMPARABLE_TYPES.add(REF);
+ COMPARABLE_TYPES.add(PTR);
COLLECTION_TYPES = new HashSet<Type>();
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
index 9d822a7..92ca943 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
@@ -8,6 +8,10 @@ lexer grammar FateLexer;
fragment SEP: [ \t\r\n]+;
fragment US: '_'?;
+fragment DICT_NS: 'dict:';
+fragment LIST_NS: 'list:';
+fragment SET_NS: 'set:';
+fragment STRUCT_NS: 'struct:';
WS: SEP;
@@ -15,198 +19,359 @@ L_PAREN: '(';
R_PAREN: ')';
-ABS_KW: L_PAREN 'abs'('olute'?) SEP+;
-DICT_KW: L_PAREN 'dict'('ionary'?) SEP+;
-ACCESS_KW: L_PAREN 'access' SEP+;
-ACCESS_POINTER_KW: L_PAREN 'access'US('ptr'|'pointer') SEP+;
-ADD_KW: L_PAREN 'add'(US'element')? SEP+;
-IMP_ADD_KW: L_PAREN 'add'(US'element')?'!' SEP+;
-ADD_AT_KW: L_PAREN 'add'(US'element')?US'at' SEP+;
-IMP_ADD_AT_KW: L_PAREN 'add'(US'element')?US'at!' SEP+;
-ADD_ALL_KW: L_PAREN 'add'US'all'(US'elements')? SEP+;
-IMP_ADD_ALL_KW: L_PAREN 'add'US'all'(US'elements')?'!' SEP+;
-AND_KW: L_PAREN ('and'|'/\\') SEP+;
-IMP_ASSERT_KW: L_PAREN 'assert!' SEP+;
-AT_KW: L_PAREN 'at' SEP+;
-IMP_BREAK_KW: L_PAREN 'break'('!'?) SEP* R_PAREN;
-CAR_KW: L_PAREN 'car' SEP+;
-CAST_KW: L_PAREN 'cast' SEP+;
-CDR_KW: L_PAREN 'cdr' SEP+;
-IMP_CLEAR_KW: L_PAREN 'clear!' SEP+;
-COND_KW: L_PAREN 'cond' SEP+;
-CONS_KW: L_PAREN 'cons' SEP+;
-COUNT_KW: L_PAREN 'count' SEP+;
+
+
+FATE_VERSION_KW: L_PAREN 'fate'US'version' SEP+;
+
+
+
+
DECLARE_ALIAS_TYPE_KW:
- L_PAREN ((('declare'|'define'|'def')US(('sub'|'alias')US)?'type')|'typedef') SEP+;
-DECLARE_STRUCT_TYPE_KW: L_PAREN
- ('declare'|'define'|'def')US('struct''ure'?)(US'type')? SEP+;
-DECLARE_EXTRA_INSTRUCTION_KW: L_PAREN ('declare'|'define'|'def')US'extra'US'instruction' SEP+;
-DECLARE_EXTRA_COMPUTATION_KW: L_PAREN ('declare'|'define'|'def')US'extra'US'computation' SEP+;
-DECLARE_EXTRA_TYPE_KW: L_PAREN ('declare'|'define'|'def')US'extra'US'type' SEP+;
-DECLARE_EVENT_TYPE_KW: L_PAREN ('declare'|'define'|'def')(US'input')?US'event'(US'type')? SEP+;
-DECLARE_TEXT_EFFECT_KW: L_PAREN ('declare'|'define'|'def')US'text'US'effect' SEP+;
-DECLARE_VARIABLE_KW: L_PAREN 'global' SEP+;
-LOCAL_KW: L_PAREN 'local' SEP+;
-EXTERNAL_KW: L_PAREN 'extern'('al'?) SEP+;
-DEFAULT_KW: L_PAREN 'default' SEP+;
-DEFINE_SEQUENCE_KW: L_PAREN ('declare'|'define'|'def')US(('seq'('uence')?)|('proc'('edure'?))) SEP+;
-DIVIDE_KW: L_PAREN ('divide'|'/'|'div') SEP+;
-DICT_TO_LIST_KW:
- L_PAREN
- (('dict'('ionary'?)US'to'US'list')|('list'US'from'US'dict'('ionary'?)))
- SEP+;
-DICT_FROM_LIST_KW:
L_PAREN
- (('dict'('ionary'?)US'from'US'list')|('list'US'to'US'dict'('ionary'?)))
+ ((('declare'|('def''ine'?))US(('sub'|'alias')US)?'type')|'typedef')
SEP+;
-DICT_KEYS_KW: L_PAREN (('get'US)?'dict'('ionary'?)US'keys') SEP+;
-DICT_VALUES_KW: L_PAREN (('get'US)?'dict'('ionary'?)US'values') SEP+;
-DICT_MERGE_KW: L_PAREN ('dict'('ionary'?)US'merge') SEP+;
-DICT_MAP_KW: L_PAREN ('dict'('ionary'?)US'map') SEP+;
-DICT_FILTER_KW: L_PAREN ('dict'('ionary'?)US'filter') SEP+;
-DICT_SET_KW: L_PAREN ('dict'('ionary'?)US'set') SEP+;
-DICT_REMOVE_KW: L_PAREN ('dict'('ionary'?)US'remove') SEP+;
-DICT_HAS_KW: L_PAREN ('dict'('ionary'?)US'has') SEP+;
-DICT_GET_KW: L_PAREN ('dict'('ionary'?)US'get') SEP+;
-DICT_GET_POINTER_KW: L_PAREN ('dict'('ionary'?)US'get'US('ptr'|'pointer')) SEP+;
+DECLARE_STRUCT_TYPE_KW:
+ L_PAREN ('declare'|('def''ine'?))US('struct''ure'?)(US'type')? SEP+;
+DECLARE_EXTRA_INSTRUCTION_KW:
+ L_PAREN ('declare'|('def''ine'?))US'extra'US'instruction' SEP+;
+DECLARE_EXTRA_COMPUTATION_KW:
+ L_PAREN ('declare'|('def''ine'?))US'extra'US'computation' SEP+;
+DECLARE_EXTRA_TYPE_KW:
+ L_PAREN ('declare'|('def''ine'?))US'extra'US'type' SEP+;
+DECLARE_EVENT_TYPE_KW:
+ L_PAREN ('declare'|('def''ine'?))(US'input')?US'event'(US'type')? SEP+;
+DECLARE_TEXT_EFFECT_KW:
+ L_PAREN ('declare'|('def''ine'?))US'text'US'effect' SEP+;
+DECLARE_GLOBAL_VARIABLE_KW: L_PAREN 'global' SEP+;
+DECLARE_EXTERNAL_VARIABLE_KW: L_PAREN 'extern'('al'?) SEP+;
-IMP_DICT_TO_LIST_KW:
- L_PAREN
- (('dict'('ionary'?)US'to'US'list')|('list'US'from'US'dict'('ionary'?)))'!'
- SEP+;
-IMP_DICT_FROM_LIST_KW:
+DEFINE_SEQUENCE_KW:
L_PAREN
- (('dict'('ionary'?)US'from'US'list')|('list'US'to'US'dict'('ionary'?)))'!'
+ ('declare'|('def''ine'?))US(('seq'('uence'?))|('proc'('edure'?)))
SEP+;
-IMP_DICT_KEYS_KW: L_PAREN (('get'US)?'dict'('ionary'?)US'keys')'!' SEP+;
-IMP_DICT_VALUES_KW: L_PAREN (('get'US)?'dict'('ionary'?)US'values')'!' SEP+;
-IMP_DICT_MERGE_KW: L_PAREN ('dict'('ionary'?)US'merge')'!' SEP+;
-IMP_DICT_MAP_KW: L_PAREN ('dict'('ionary'?)US'map')'!' SEP+;
-IMP_DICT_FILTER_KW: L_PAREN ('dict'('ionary'?)US'filter')'!' SEP+;
-IMP_DICT_SET_KW: L_PAREN ('dict'('ionary'?)US'set')'!' SEP+;
-IMP_DICT_REMOVE_KW: L_PAREN ('dict'('ionary'?)US'remove')'!' SEP+;
-IMP_DICT_HAS_KW: L_PAREN ('dict'('ionary'?)US'has')'!' SEP+;
-IMP_DICT_GET_KW: L_PAREN ('dict'('ionary'?)US'get')'!' SEP+;
-IMP_DICT_GET_POINTER_KW:
- L_PAREN ('dict'('ionary'?)US'get'US('ptr'|'pointer'))'!' SEP+;
-DO_WHILE_KW: L_PAREN ('do'US'while') SEP+;
-ENABLE_TEXT_EFFECT_KW: L_PAREN 'text'US'effect' SEP+;
-END_KW: L_PAREN 'end'('!'?) SEP* R_PAREN;
-EQUALS_KW: L_PAREN ('equals'|'='|'=='|'eq') SEP+;
-EXTENSION_FIRST_LEVEL_KW: L_PAREN '@';
-EXTRA_INSTRUCTION_KW: L_PAREN '#';
-JOIN_KW: L_PAREN ('text'US)? 'join' SEP+;
-EXTRA_COMPUTATION_KW: L_PAREN '$';
-FALSE_KW: L_PAREN 'false' SEP* R_PAREN;
-IGNORE_ERROR_KW: L_PAREN 'ignore'US('error'|'warning') SEP+;
+
IMP_IGNORE_ERROR_KW: L_PAREN 'ignore'US('error'|'warning')'!' SEP+;
-FATE_VERSION_KW: L_PAREN 'fate'US'version' SEP+;
-FIELD_KW: L_PAREN 'field' SEP+;
-FIELD_ACCESS_KW: L_PAREN (('get'US'field')|('field'US'access')) SEP+;
-FILTER_KW: L_PAREN 'filter' SEP+;
-INDEXED_FILTER_KW: L_PAREN 'indexed'US'filter' SEP+;
-IMP_FILTER_KW: L_PAREN 'filter!' SEP+;
-IMP_INDEXED_FILTER_KW: L_PAREN 'indexed'US'filter!' SEP+;
-FOR_EACH_KW: L_PAREN ('for'US'each') SEP+;
-FOR_KW: L_PAREN 'for' SEP+;
-FOLDR_KW: L_PAREN 'foldr' SEP+;
-FOLDL_KW: L_PAREN 'foldl' SEP+;
-FREE_KW: L_PAREN ('free!'|'release!'|'destroy!') SEP+;
-GREATER_EQUAL_THAN_KW: L_PAREN ('greater'US'equal'US'than'|'>='|'ge') SEP+;
-GREATER_THAN_KW: L_PAREN ('greater'US'than'|'>'|'gt') SEP+;
-IF_ELSE_KW: L_PAREN ('if'US'else') SEP+;
-IF_KW: L_PAREN 'if' SEP+;
-IMPLIES_KW: L_PAREN ('implies'|'=>'|'->') SEP+;
+REQUIRE_EXTENSION_KW: L_PAREN 'require'US'extension' SEP+;
+REQUIRE_KW: L_PAREN 'require' SEP+;
INCLUDE_KW: L_PAREN 'include' SEP+;
-INDEX_OF_KW: L_PAREN ('index'US'of') SEP+;
-INDEXED_MAP_KW: L_PAREN 'indexed'US'map' SEP+;
-IMP_INDEXED_MAP_KW: L_PAREN 'indexed'US'map!' SEP+;
-IS_MEMBER_KW: L_PAREN ('is'US'member'|'contains'|'has') SEP+;
-IS_EMPTY_KW: L_PAREN 'is'US'empty' SEP+;
-LOWER_EQUAL_THAN_KW: L_PAREN ('lower'US'equal'US'than'|'=<'|'<='|'le') SEP+;
-LOWER_THAN_KW: L_PAREN ('lower'US'than'|'<'|'lt') SEP+;
-LET_KW: L_PAREN 'let' SEP+;
+
+
+
+
+DECLARE_LOCAL_VARIABLE_KW: L_PAREN 'local' SEP+;
+
+
+
+
+ABS_KW: L_PAREN 'abs'('olute'?) SEP+;
+CLAMP_KW: L_PAREN ('clamp') SEP+;
+DIVIDE_KW: L_PAREN (('div''ide'?)|'/') SEP+;
+MAX_KW: L_PAREN ('max'('imum'?)) SEP+;
MINUS_KW: L_PAREN ('minus'|'-') SEP+;
MIN_KW: L_PAREN ('min'('imum'?)) SEP+;
-MAP_KW: L_PAREN 'map' SEP+;
-STRING_KW: L_PAREN 'string' SEP+;
-IMP_MAP_KW: L_PAREN 'map!' SEP+;
-MAX_KW: L_PAREN ('max'('imum'?)) SEP+;
-LAMBDA_KW: L_PAREN 'lambda' SEP+;
-EVAL_KW: L_PAREN 'eval'('uate'?) SEP+;
-CLAMP_KW: L_PAREN ('clamp') SEP+;
-MODULO_KW: L_PAREN ('modulo'|'%'|'mod') SEP+;
-MERGE_TO_LIST_KW : L_PAREN 'merge'US'to'US'list' SEP+;
-MERGE_TO_SET_KW : L_PAREN 'merge'US'to'US'set' SEP+;
-INDEXED_MERGE_TO_LIST_KW : L_PAREN 'indexed'US'merge'US'to'US'list' SEP+;
-INDEXED_MERGE_TO_SET_KW : L_PAREN 'indexed'US'merge'US'to'US'set' SEP+;
-IMP_MERGE_KW : L_PAREN 'merge!' SEP+;
-IMP_INDEXED_MERGE_KW : L_PAREN 'indexed'US'merge!' SEP+;
-SAFE_MERGE_TO_LIST_KW : L_PAREN 'safe'US'merge'US'to'US'list' SEP+;
-SAFE_MERGE_TO_SET_KW : L_PAREN 'safe'US'merge'US'to'US'set' SEP+;
-SAFE_INDEXED_MERGE_TO_LIST_KW : L_PAREN (('safe'US'indexed')|('indexed'US'safe'))US'merge'US'to'US'list' SEP+;
-SAFE_INDEXED_MERGE_TO_SET_KW : L_PAREN (('safe'US'indexed')|('indexed'US'safe'))US'merge'US'to'US'set' SEP+;
-SAFE_IMP_MERGE_KW : L_PAREN 'safe'US'merge!' SEP+;
-SAFE_IMP_INDEXED_MERGE_KW : L_PAREN (('indexed'US'safe')|('safe'US'indexed'))US'merge!' SEP+;
-NEWLINE_KW: L_PAREN 'newline' SEP* R_PAREN;
-ALLOCATE_KW: L_PAREN (('alloc''ate'?)|'malloc'|'new')'!' SEP+;
+MODULO_KW: L_PAREN (('mod''ulo'?)|'%') SEP+;
+PLUS_KW: L_PAREN ('plus'|'+') SEP+;
+POWER_KW: L_PAREN (('pow''er'?)|'^'|'**'|) SEP+;
+RANDOM_KW: L_PAREN (('rand''om'?)|'rnd') SEP+;
+TIMES_KW: L_PAREN ('times'|'*') SEP+;
+
+
+
+
+DICT_KW: L_PAREN 'dict'('ionary'?) SEP+;
+DICT_FILTER_KW: L_PAREN DICT_NS 'filter' SEP+;
+DICT_FOLD_KW: L_PAREN DICT_NS 'fold' SEP+;
+DICT_FROM_LIST_KW:
+ L_PAREN ((DICT_NS'from'US'list')|(LIST_NS'to'US'dict'('ionary'?))) SEP+;
+DICT_GET_KW: L_PAREN DICT_NS 'get' SEP+;
+DICT_HAS_KW: L_PAREN DICT_NS 'has' SEP+;
+DICT_KEYS_KW: L_PAREN DICT_NS ('get'US)?'keys' SEP+;
+DICT_MAP_KW: L_PAREN DICT_NS 'map' SEP+;
+DICT_MERGE_KW: L_PAREN DICT_NS 'merge' SEP+;
+DICT_REMOVE_KW: L_PAREN DICT_NS ('rm'|'remove'|'del'|'delete') SEP+;
+DICT_SET_KW: L_PAREN DICT_NS 'set' SEP+;
+DICT_SIZE_KW: L_PAREN DICT_NS 'size' SEP+;
+DICT_TO_LIST_KW:
+ L_PAREN ((DICT_NS'to'US'list')|(LIST_NS'from'US'dict'('ionary'?))) SEP+;
+DICT_VALUES_KW: L_PAREN DICT_NS ('get'US)?'values' SEP+;
+IMP_DICT_FILTER_KW: L_PAREN DICT_NS 'filter''!' SEP+;
+IMP_DICT_FOLD_KW: L_PAREN DICT_NS 'fold''!' SEP+;
+IMP_DICT_FROM_LIST_KW:
+ L_PAREN ((DICT_NS'from'US'list')|(LIST_NS'to'US'dict'('ionary'?)))'!' SEP+;
+IMP_DICT_GET_KW: L_PAREN DICT_NS 'get''!' SEP+;
+IMP_DICT_HAS_KW: L_PAREN DICT_NS 'has''!' SEP+;
+IMP_DICT_KEYS_KW: L_PAREN DICT_NS ('get'US)?'keys''!' SEP+;
+IMP_DICT_MAP_KW: L_PAREN DICT_NS 'map''!' SEP+;
+IMP_DICT_MERGE_KW: L_PAREN DICT_NS 'merge''!' SEP+;
+IMP_DICT_REMOVE_KW: L_PAREN DICT_NS ('rm'|'remove'|'del'|'delete')'!' SEP+;
+IMP_DICT_SET_KW: L_PAREN DICT_NS 'set''!' SEP+;
+IMP_DICT_TO_LIST_KW:
+ L_PAREN ((DICT_NS'to'US'list')|(LIST_NS'from'US'dict'('ionary'?)))'!' SEP+;
+IMP_DICT_VALUES_KW: L_PAREN DICT_NS ('get'US)?'values''!' SEP+;
+
+
+
+
+LIST_KW: L_PAREN 'list' SEP+;
+LIST_ADD_ALL_KW: L_PAREN LIST_NS 'add'US'all'(US'elements')? SEP+;
+LIST_ADD_ALL_KW: L_PAREN LIST_NS 'add'US'all'(US'elements')? SEP+;
+LIST_ADD_AT_KW: L_PAREN LIST_NS 'add'(US'element')?US'at' SEP+;
+LIST_ADD_KW: L_PAREN LIST_NS 'add'(US'element')? SEP+;
+LIST_COUNT_KW: L_PAREN LIST_NS 'count' SEP+;
+LIST_FILTER_KW: L_PAREN LIST_NS 'filter' SEP+;
+LIST_FOLDL_KW: L_PAREN LIST_NS 'foldl' SEP+;
+LIST_FOLDR_KW: L_PAREN LIST_NS 'foldr' SEP+;
+LIST_GET_KW: L_PAREN LIST_NS 'get' SEP+;
+LIST_INDEXED_FILTER_KW: L_PAREN LIST_NS 'indexed'US'filter' SEP+;
+LIST_INDEXED_MAP_KW: L_PAREN LIST_NS 'indexed'US'map' SEP+;
+LIST_INDEXED_MERGE_KW: L_PAREN LIST_NS 'indexed'US'merge' SEP+;
+LIST_INDEXED_PARTITION_KW: L_PAREN LIST_NS 'indexed'US'partition' SEP+;
+LIST_INDEX_OF_KW: L_PAREN LIST_NS 'index'US'of' SEP+;
+LIST_IS_EMPTY_KW: L_PAREN LIST_NS 'is'US'empty' SEP+;
+LIST_IS_MEMBER_KW: L_PAREN LIST_NS (('is'US'member')|'contains'|'has') SEP+;
+LIST_MAP_KW: L_PAREN LIST_NS 'map' SEP+;
+LIST_MERGE_KW: L_PAREN LIST_NS 'merge' SEP+;
+LIST_PARTITION_KW: L_PAREN LIST_NS 'partition' SEP+;
+LIST_POP_LEFT_KW: L_PAREN LIST_NS 'pop'US'left' SEP+;
+LIST_POP_RIGHT_KW: L_PAREN LIST_NS 'pop'US'right' SEP+;
+LIST_PUSH_LEFT_KW: L_PAREN LIST_NS 'push'US'left' SEP+;
+LIST_PUSH_RIGHT_KW: L_PAREN LIST_NS 'push'US'right' SEP+;
+LIST_RANGE_KW: L_PAREN LIST_NS 'range' SEP+;
+LIST_REMOVE_ALL_KW: L_PAREN LIST_NS 'remove'US'all' SEP+;
+LIST_REMOVE_AT_KW: L_PAREN LIST_NS 'remove'US('element'?US)?'at' SEP+;
+LIST_REMOVE_ONE_KW: L_PAREN LIST_NS 'remove'US'one' SEP+;
+LIST_REVERSE_KW: L_PAREN LIST_NS 'reverse'(US'list')? SEP+;
+LIST_SAFE_INDEXED_MERGE_KW:
+ L_PAREN LIST_NS (('safe'US'indexed')|('indexed'US'safe'))US'merge' SEP+;
+LIST_SAFE_MERGE_KW: L_PAREN LIST_NS 'safe'US'merge' SEP+;
+LIST_SET_KW: L_PAREN LIST_NS 'set' SEP+;
+LIST_SHUFFLE_KW: L_PAREN LIST_NS 'shuffle' SEP+;
+LIST_SIZE_KW: L_PAREN LIST_NS 'size' SEP+;
+LIST_SORT_KW: L_PAREN LIST_NS 'sort' SEP+;
+LIST_SUB_LIST_KW: L_PAREN LIST_NS 'sub'US'list' SEP+;
+IMP_LIST_ADD_ALL_KW: L_PAREN LIST_NS 'add'US'all'(US'elements')?'!' SEP+;
+IMP_LIST_ADD_AT_KW: L_PAREN LIST_NS 'add'(US'element')?US'at!' SEP+;
+IMP_LIST_ADD_KW: L_PAREN LIST_NS 'add'(US'element')?'!' SEP+;
+IMP_LIST_CLEAR_KW: L_PAREN LIST_NS 'clear!' SEP+;
+IMP_LIST_FILTER_KW: L_PAREN LIST_NS 'filter!' SEP+;
+IMP_LIST_INDEXED_FILTER_KW: L_PAREN LIST_NS 'indexed'US'filter!' SEP+;
+IMP_LIST_INDEXED_MAP_KW: L_PAREN LIST_NS 'indexed'US'map!' SEP+;
+IMP_LIST_INDEXED_MERGE_KW: L_PAREN LIST_NS 'indexed'US'merge!' SEP+;
+IMP_LIST_INDEXED_PARTITION_KW: L_PAREN LIST_NS 'indexed'US'partition!' SEP+;
+IMP_LIST_MAP_KW: L_PAREN LIST_NS 'map!' SEP+;
+IMP_LIST_MERGE_KW: L_PAREN LIST_NS 'merge!' SEP+;
+IMP_LIST_PARTITION_KW: L_PAREN LIST_NS 'partition!' SEP+;
+IMP_LIST_POP_LEFT_KW: L_PAREN LIST_NS 'pop'US'left!' SEP+;
+IMP_LIST_POP_RIGHT_KW: L_PAREN LIST_NS 'pop'US'right!' SEP+;
+IMP_LIST_PUSH_LEFT_KW: L_PAREN LIST_NS 'push'US'left!' SEP+;
+IMP_LIST_PUSH_RIGHT_KW: L_PAREN LIST_NS 'push'US'right!' SEP+;
+IMP_LIST_REMOVE_ALL_KW: L_PAREN LIST_NS 'remove'US'all!' SEP+;
+IMP_LIST_REMOVE_AT_KW: L_PAREN LIST_NS ('remove'US('elem''ent'?US)?'at!') SEP+;
+IMP_LIST_REMOVE_ONE_KW: L_PAREN LIST_NS 'remove'US'one!' SEP+;
+IMP_LIST_REVERSE_KW: L_PAREN LIST_NS 'reverse'(US'list')?'!' SEP+;
+IMP_LIST_SAFE_INDEXED_MERGE_KW:
+ L_PAREN LIST_NS (('indexed'US'safe')|('safe'US'indexed'))US'merge!' SEP+;
+IMP_LIST_SAFE_MERGE_KW: L_PAREN LIST_NS 'safe'US'merge!' SEP+;
+IMP_LIST_SET_KW: L_PAREN LIST_NS 'set!' SEP+;
+IMP_LIST_SHUFFLE_KW: L_PAREN LIST_NS 'shuffle!' SEP+;
+IMP_LIST_SORT_KW: L_PAREN LIST_NS 'sort!' SEP+;
+IMP_LIST_SUB_LIST_KW: L_PAREN LIST_NS 'sub'US'list!' SEP+;
+
+
+
+
+SET_KW: L_PAREN 'set' SEP+;
+SET_ADD_ALL_KW: L_PAREN SET_NS 'add'US'all'(US'elements')? SEP+;
+SET_ADD_KW: L_PAREN SET_NS 'add'(US'element')? SEP+;
+SET_COUNT_KW: L_PAREN SET_NS 'count' SEP+;
+SET_FILTER_KW: L_PAREN SET_NS 'filter' SEP+;
+SET_FOLDL_KW: L_PAREN SET_NS foldl' SEP+;
+SET_FOLDR_KW: L_PAREN SET_NS 'foldr' SEP+;
+SET_GET_KW: L_PAREN SET_NS 'get' SEP+;
+SET_INDEXED_FILTER_KW: L_PAREN SET_NS 'indexed'US'filter' SEP+;
+SET_INDEXED_MAP_KW: L_PAREN SET_NS 'indexed'US'map' SEP+;
+SET_INDEXED_MERGE_KW: L_PAREN SET_NS 'indexed'US'merge' SEP+;
+SET_INDEXED_PARTITION_KW: L_PAREN SET_NS 'indexed'US'partition' SEP+;
+SET_INDEX_OF_KW: L_PAREN SET_NS 'index'US'of' SEP+;
+SET_IS_EMPTY_KW: L_PAREN SET_NS 'is'US'empty' SEP+;
+SET_IS_MEMBER_KW: L_PAREN SET_NS ('is'US'member'|'contains'|'has') SEP+;
+SET_MAP_KW: L_PAREN SET_NS 'map' SEP+;
+SET_MERGE_KW: L_PAREN SET_NS 'merge' SEP+;
+SET_PARTITION_KW: L_PAREN SET_NS 'partition' SEP+;
+SET_POP_LEFT_KW: L_PAREN SET_NS 'pop'US'left' SEP+;
+SET_POP_RIGHT_KW: L_PAREN SET_NS 'pop'US'right' SEP+;
+SET_RANGE_KW: L_PAREN SET_NS 'range' SEP+;
+SET_REMOVE_AT_KW: L_PAREN SET_NS ('remove'US('elem'('ent')?US)?'at') SEP+;
+SET_REMOVE_ONE_KW: L_PAREN SET_NS 'remove'US'one' SEP+;
+SET_SAFE_INDEXED_MERGE_KW:
+ L_PAREN SET_NS (('safe'US'indexed')|('indexed'US'safe'))US'merge' SEP+;
+SET_SAFE_MERGE_KW: L_PAREN SET_NS 'safe'US'merge' SEP+;
+SET_SET_KW: L_PAREN SET_NS 'set' SEP+;
+SET_SIZE_KW: L_PAREN SET_NS 'size' SEP+;
+IMP_SET_ADD_ALL_KW: L_PAREN SET_NS 'add'US'all'(US'elements')?'!' SEP+;
+IMP_SET_ADD_KW: L_PAREN SET_NS 'add'(US'element')?'!' SEP+;
+IMP_SET_CLEAR_KW: L_PAREN SET_NS 'clear!' SEP+;
+IMP_SET_FILTER_KW: L_PAREN SET_NS 'filter!' SEP+;
+IMP_SET_INDEXED_FILTER_KW: L_PAREN SET_NS 'indexed'US'filter!' SEP+;
+IMP_SET_INDEXED_MAP_KW: L_PAREN SET_NS 'indexed'US'map!' SEP+;
+IMP_SET_INDEXED_MERGE_KW: L_PAREN SET_NS 'indexed'US'merge!' SEP+;
+IMP_SET_INDEXED_PARTITION_KW: L_PAREN SET_NS 'indexed'US'partition!' SEP+;
+IMP_SET_MAP_KW: L_PAREN SET_NS 'map!' SEP+;
+IMP_SET_MERGE_KW: L_PAREN SET_NS 'merge!' SEP+;
+IMP_SET_PARTITION_KW: L_PAREN SET_NS 'partition!' SEP+;
+IMP_SET_POP_LEFT_KW: L_PAREN SET_NS 'pop'US'left!' SEP+;
+IMP_SET_POP_RIGHT_KW: L_PAREN SET_NS 'pop'US'right!' SEP+;
+IMP_SET_REMOVE_AT_KW: L_PAREN SET_NS ('remove'US('elem'('ent')?US)?'at!') SEP+;
+IMP_SET_REMOVE_ONE_KW: L_PAREN SET_NS 'remove'US'one!' SEP+;
+IMP_SET_SAFE_INDEXED_MERGE_KW:
+ L_PAREN SET_NS (('indexed'US'safe')|('safe'US'indexed'))US'merge!' SEP+;
+IMP_SET_SAFE_MERGE_KW: L_PAREN SET_NS 'safe'US'merge!' SEP+;
+
+
+
+
+AND_KW: L_PAREN ('and'|'/\\') SEP+;
+FALSE_KW: L_PAREN 'false' SEP* R_PAREN;
+IMPLIES_KW: L_PAREN ('implies'|'=>'|'->') SEP+;
NOT_KW: L_PAREN ('not'|'~'|'!') SEP+;
ONE_IN_KW: L_PAREN ('exactly'US)?'one'(US'in')? SEP+;
OR_KW: L_PAREN ('or'|'\\/') SEP+;
+TRUE_KW: L_PAREN 'true' SEP* R_PAREN;
+
+
+
+
+ENABLE_TEXT_EFFECT_KW: L_PAREN 'text'US'effect' SEP+;
+NEWLINE_KW: L_PAREN 'newline' SEP* R_PAREN;
+TEXT_JOIN_KW: L_PAREN TEXT_NS 'join' SEP+;
TEXT_KW: L_PAREN 'text' SEP+;
-PARTITION_KW: L_PAREN 'partition' SEP+;
-IMP_PARTITION_KW: L_PAREN 'partition!' SEP+;
-INDEXED_PARTITION_KW: L_PAREN 'indexed'US'partition' SEP+;
-IMP_INDEXED_PARTITION_KW: L_PAREN 'indexed'US'partition!' SEP+;
-POP_LEFT_KW: L_PAREN 'pop'US'left' SEP+;
-IMP_POP_LEFT_KW: L_PAREN 'pop'US'left!' SEP+;
-POP_RIGHT_KW: L_PAREN 'pop'US'right' SEP+;
-IMP_POP_RIGHT_KW: L_PAREN 'pop'US'right!' SEP+;
-PUSH_LEFT_KW: L_PAREN 'push'US'left' SEP+;
-IMP_PUSH_LEFT_KW: L_PAREN 'push'US'left!' SEP+;
-PUSH_RIGHT_KW: L_PAREN 'push'US'right' SEP+;
-IMP_PUSH_RIGHT_KW: L_PAREN 'push'US'right!' SEP+;
-PLAYER_CHOICE_KW: L_PAREN ('choice'|'user'US'choice'|'player'US'choice')'!' SEP+;
+
+
+
+
+
+
+
+CONS_KW: L_PAREN 'cons' SEP+;
+CAR_KW: L_PAREN 'car' SEP+;
+CDR_KW: L_PAREN 'cdr' SEP+;
+
+
+
+
+COND_KW: L_PAREN 'cond' SEP+;
+DO_WHILE_KW: L_PAREN 'do'US'while' SEP+;
+FOR_KW: L_PAREN 'for' SEP+;
+FOR_EACH_KW: L_PAREN 'for'US'each' SEP+;
+WHILE_KW: L_PAREN 'while' SEP+;
+SWITCH_KW: L_PAREN 'switch' SEP+;
+IMP_BREAK_KW: L_PAREN 'break'('!'?) SEP* R_PAREN;
+IMP_CONTINUE_KW: L_PAREN 'continue'('!'?) SEP* R_PAREN;
+
+
+
+
+IF_ELSE_KW: L_PAREN 'if'US'else' SEP+;
+IF_KW: L_PAREN 'if' SEP+;
+
+
+
+
+STRING_KW: L_PAREN 'string' SEP+;
+
+
+
+
+DEFAULT_KW: L_PAREN 'default' SEP+;
+CAST_KW: L_PAREN 'cast' SEP+;
+
+
+
+
+EQUALS_KW: L_PAREN ('equals'|'='|'=='|'eq') SEP+;
+GREATER_EQUAL_THAN_KW: L_PAREN (('greater'US'equal'US'than')|'>='|'ge') SEP+;
+GREATER_THAN_KW: L_PAREN (('greater'US'than')|'>'|'gt') SEP+;
+LOWER_EQUAL_THAN_KW: L_PAREN (('lower'US'equal'US'than')|'=<'|'<='|'le') SEP+;
+LOWER_THAN_KW: L_PAREN (('lower'US'than')|'<'|'lt') SEP+;
+
+
+
+
+IMP_ASSERT_KW: L_PAREN 'assert!' SEP+;
+IGNORE_ERROR_KW: L_PAREN 'ignore'US('error'|'warning') SEP+;
+
+
+
+
+EXTENSION_FIRST_LEVEL_KW: L_PAREN '@';
+EXTRA_INSTRUCTION_KW: L_PAREN '#';
+EXTRA_COMPUTATION_KW: L_PAREN '$';
+
+
+
+
+FIELD_KW: L_PAREN STRUCT_NS ('get'US)?'field' SEP+;
+SET_FIELDS_KW: L_PAREN STRUCT_NS 'set'US'fields' SEP+;
+IMP_SET_FIELDS_KW: L_PAREN STRUCT_NS 'set'US'fields!' SEP+;
+
+
+
+
+PLAYER_CHOICE_KW:
+ L_PAREN ('choice'|'user'US'choice'|'player'US'choice')'!' SEP+;
TEXT_OPTION_KW: L_PAREN ('option'|'user'US'option'|'player'US'option') SEP+;
EVENT_OPTION_KW: L_PAREN ('event'|'user'US'event'|'player'US'event') SEP+;
-PLUS_KW: L_PAREN ('plus'|'+') SEP+;
-POWER_KW: L_PAREN ('power'|'^'|'**'|'pow') SEP+;
-RANGE_KW: L_PAREN 'range' SEP+;
-RANDOM_KW: L_PAREN ('random'|'rand'|'rnd') SEP+;
-REF_KW: L_PAREN (((('ref'('erence'?))|'ptr'|'pointer')(US'to')?)|('addr'('ess'?)(US'of')?)) SEP+;
-REMOVE_ALL_KW: L_PAREN 'remove'US'all' SEP+;
-IMP_REMOVE_ALL_KW: L_PAREN 'remove'US'all!' SEP+;
-REVERSE_KW: L_PAREN 'reverse'(US'list')? SEP+;
-IMP_REVERSE_KW: L_PAREN 'reverse'(US'list')?'!' SEP+;
-REMOVE_ONE_KW: L_PAREN 'remove'US'one' SEP+;
-IMP_REMOVE_ONE_KW: L_PAREN 'remove'US'one!' SEP+;
-REMOVE_AT_KW: L_PAREN ('remove'US('elem'('ent')?US)?'at') SEP+;
-IMP_REMOVE_AT_KW: L_PAREN ('remove'US('elem'('ent')?US)?'at!') SEP+;
-REQUIRE_EXTENSION_KW: L_PAREN 'require'US'extension' SEP+;
-REQUIRE_KW: L_PAREN 'require' SEP+;
-PROMPT_STRING_KW: L_PAREN 'prompt_string!' SEP+;
-PROMPT_INTEGER_KW: L_PAREN 'prompt_int'('eger'?)'!' SEP+;
-SHUFFLE_KW: L_PAREN 'shuffle' SEP+;
-IMP_SHUFFLE_KW: L_PAREN 'shuffle!' SEP+;
-SORT_KW: L_PAREN 'sort' SEP+;
-IMP_SORT_KW: L_PAREN 'sort!' SEP+;
-SET_FIELDS_KW: L_PAREN 'set'US'fields' SEP+;
-IMP_SET_FIELDS_KW: L_PAREN 'set'US'fields!' SEP+;
+PROMPT_STRING_KW: L_PAREN 'prompt'US'str''ing'?'!' SEP+;
+PROMPT_INTEGER_KW: L_PAREN 'prompt'US'int''eger'?'!' SEP+;
+
+
+
+
+LET_KW: L_PAREN 'let' SEP+;
+AT_KW: L_PAREN 'at' SEP+;
+REF_KW:
+ L_PAREN
+ (
+ ((('ref''erence'?)|'ptr'|'pointer')(US'to')?)
+ |('addr''ess'?(US'of')?)
+ )
+ SEP+;
IMP_SET_KW: L_PAREN 'set'(US(('val''ue'?)|('var''iable'?)))?'!' SEP+;
-SUB_LIST_KW: L_PAREN 'sub'US'list' SEP+;
-IMP_SUB_LIST_KW: L_PAREN 'sub'US'list!' SEP+;
-LIST_KW: L_PAREN 'list' SEP+;
-SIZE_KW: L_PAREN 'size' SEP+;
-SEQUENCE_KW: L_PAREN ('seq'|'sequence') SEP+;
-SWITCH_KW: L_PAREN 'switch' SEP+;
-TIMES_KW: L_PAREN ('times'|'*') SEP+;
-TRUE_KW: L_PAREN 'true' SEP* R_PAREN;
+VARIABLE_KW: L_PAREN 'var''iable'? SEP+;
+
+
+
+
+ALLOCATE_KW: L_PAREN (('alloc''ate'?)|'malloc'|'new')'!' SEP+;
+FREE_KW: L_PAREN ('free!'|'release!'|'destroy!') SEP+;
+
+
+
+
+LAMBDA_KW: L_PAREN 'lambda' SEP+;
+EVAL_KW: L_PAREN 'eval''uate'? SEP+;
+
+
+
+
+
+
+
+
+SEQUENCE_KW: L_PAREN 'seq''uence'? SEP+;
DONE_KW: L_PAREN 'done''!'? SEP* R_PAREN;
-SET_KW: L_PAREN 'set' SEP+;
-VARIABLE_KW: L_PAREN ('variable'|'var') SEP+;
-VISIT_KW: L_PAREN ('call'|'visit')(US(('seq'('uence'?))|('proc'('edure'?))))?'!' SEP+;
-CONTINUE_AS_KW: L_PAREN (('continue'US('as'|'to'|'with'))|('jump'(US'to')?)|('go'US'to')|'exec')(US(('seq'('uence'?))|('proc'('edure'?))))?'!' SEP+;
-WHILE_KW: L_PAREN 'while' SEP+;
+VISIT_KW:
+ L_PAREN ('call'|'visit')(US(('seq''uence'?)|('proc''edure'?)))?'!' SEP+;
+CONTINUE_AS_KW:
+ L_PAREN
+ (('continue'US('as'|'to'|'with'))|('jump'(US'to')?)|('go'US'to')|'exec')
+ (US(('seq''uence'?)|('proc''edure'?)))?
+ '!'
+ SEP+;
+END_KW: L_PAREN 'end'('!'?) SEP* R_PAREN;
+
+
+
WORD: ((~([ \t\r\n()]))|'(lp)'|'(rp)'|'(sp)')+
{
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
index a467b2d..ff7ea40 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
@@ -1,8 +1,8 @@
-parser grammar FateParser;
+parser grammar TinyFateParser;
options
{
- tokenVocab = FateLexer;
+ tokenVocab = TinyFateLexer;
}
@header
@@ -46,54 +46,29 @@ options
@members
{
- Context CONTEXT;
- World WORLD;
- Deque<Map<String, Variable>> LOCAL_VARIABLES;
- Deque<List<String>> HIERARCHICAL_VARIABLES;
- int BREAKABLE_LEVELS;
- Deque<Collection<String>> CHOICE_LIMITED_VARIABLES;
+ Parser PARSER;
}
/******************************************************************************/
/******************************************************************************/
/******************************************************************************/
-fate_file
-[
- Context context,
- Deque<Map<String, Variable>> local_variables,
- World world
-]
+fate_file [Parser PARSER]
@init
{
- CONTEXT = context;
- WORLD = world;
+ PARSER = parser;
- if (local_variables == null)
- {
- LOCAL_VARIABLES = new ArrayDeque<Map<String, Variable>>();
- LOCAL_VARIABLES.push(new HashMap<String, Variable>());
- }
- else
- {
- LOCAL_VARIABLES = local_variables;
- }
-
- HIERARCHICAL_VARIABLES = new ArrayDeque<List<String>>();
- BREAKABLE_LEVELS = 0;
-
- HIERARCHICAL_VARIABLES.push(new ArrayList<String>());
- CHOICE_LIMITED_VARIABLES = new ArrayDeque<Collection<String>>();
+ PARSER.increase_local_variables_hierarchy();
}
:
WS* FATE_VERSION_KW WORD WS* R_PAREN WS*
(
(
- first_level_fate_instr
+ first_level_instruction
|
(
- general_fate_instr
+ instruction
{
- WORLD.add_global_instruction(($general_fate_instr.result));
+ PARSER.get_world().add_global_instruction(($instruction.result));
}
)
)
@@ -104,7 +79,7 @@ fate_file
}
;
-general_fate_sequence
+maybe_instruction_list
returns [List<Instruction> result]
@init
{
@@ -112,445 +87,326 @@ returns [List<Instruction> result]
}
:
(WS*
- general_fate_instr
+ instruction
{
- $result.add(($general_fate_instr.result));
+ $result.add(($instruction.result));
}
WS*)*
{
}
;
-first_level_fate_instr:
- DEFINE_SEQUENCE_KW
- new_reference_name
- WS*
- (
- L_PAREN WS* variable_list WS* R_PAREN
- {
- final Map<String, Variable> variable_map;
-
- variable_map = new HashMap<String, Variable>();
-
- variable_map.putAll(($variable_list.result).as_map());
-
- LOCAL_VARIABLES.push(variable_map);
- }
- )
- pre_sequence_point=WS+
- general_fate_sequence
- WS*
- R_PAREN
- {
- final Origin start_origin, sequence_origin;
- final Sequence new_sequence;
-
- start_origin =
- CONTEXT.get_origin_at
- (
- ($DEFINE_SEQUENCE_KW.getLine()),
- ($DEFINE_SEQUENCE_KW.getCharPositionInLine())
- );
-
- sequence_origin =
- CONTEXT.get_origin_at
- (
- ($pre_sequence_point.getLine()),
- ($pre_sequence_point.getCharPositionInLine())
- );
-
- new_sequence =
- new Sequence
- (
- start_origin,
- new InstructionList
- (
- sequence_origin,
- ($general_fate_sequence.result)
- ),
- ($new_reference_name.result),
- ($variable_list.result).get_entries()
- );
-
- WORLD.sequences().add(new_sequence);
- LOCAL_VARIABLES.pop();
- }
-
- | DECLARE_VARIABLE_KW
- type
- WS+
- name=new_reference_name
- WS*
- R_PAREN
- {
- final Origin start_origin, type_origin;
- final Variable new_variable;
-
- start_origin =
- CONTEXT.get_origin_at
- (
- ($DECLARE_VARIABLE_KW.getLine()),
- ($DECLARE_VARIABLE_KW.getCharPositionInLine())
- );
-
- new_variable =
- new Variable
- (
- start_origin,
- ($type.result),
- ($name.result),
- false
- );
-
- WORLD.variables().add(new_variable);
- }
-
- | EXTERNAL_KW
- type
- WS+
- name=new_reference_name
- WS*
- R_PAREN
+first_level_instruction
+@init
+{
+ Parser.LocalVariables previous_local_variables_stack;
+}
+:
+ DECLARE_ALIAS_TYPE_KW parent=type WS+ identifier WS* R_PAREN
{
- final Origin start_origin, type_origin;
- final Variable new_variable;
+ final Origin start_origin;
+ final Type new_type;
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($EXTERNAL_KW.getLine()),
- ($EXTERNAL_KW.getCharPositionInLine())
+ ($DECLARE_ALIAS_TYPE_KW.getLine()),
+ ($DECLARE_ALIAS_TYPE_KW.getCharPositionInLine())
);
- new_variable =
- new Variable
+ new_type =
+ ($parent.result).generate_alias
(
start_origin,
- ($type.result),
- ($name.result),
- true
+ ($identifier.result)
);
- WORLD.variables().add(new_variable);
+ PARSER.get_world().types().add(new_type);
}
- | IMP_IGNORE_ERROR_KW WORD WS+ first_level_fate_instr WS* R_PAREN
- {
- /* TODO: temporarily disable an compiler error category */
- }
-
- | DECLARE_TEXT_EFFECT_KW
- new_reference_name
- WS+
- params=type_list
- WS*
- R_PAREN
+ | DECLARE_STRUCT_TYPE_KW identifier WS* variable_list WS* R_PAREN
{
final Origin start_origin;
- final TextEffect new_text_effect;
-
- start_origin =
- CONTEXT.get_origin_at
- (
- ($DECLARE_TEXT_EFFECT_KW.getLine()),
- ($DECLARE_TEXT_EFFECT_KW.getCharPositionInLine())
- );
-
- new_text_effect =
- new TextEffect
- (
- start_origin,
- ($type_list.result),
- ($new_reference_name.result)
- );
+ final Type new_type;
+ final Map<String, Type> field_types;
- WORLD.text_effects().add(new_text_effect);
- }
+ field_types = new HashMap<String, Type>();
- | DECLARE_TEXT_EFFECT_KW
- new_reference_name
- WS*
- R_PAREN
- {
- final Origin start_origin;
- final TextEffect new_text_effect;
+ for (final Variable te: ($variable_list.result).get_entries())
+ {
+ field_types.put(te.get_name(), te.get_type());
+ }
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($DECLARE_TEXT_EFFECT_KW.getLine()),
- ($DECLARE_TEXT_EFFECT_KW.getCharPositionInLine())
+ ($DECLARE_STRUCT_TYPE_KW.getLine()),
+ ($DECLARE_STRUCT_TYPE_KW.getCharPositionInLine())
);
- new_text_effect =
- new TextEffect
+ new_type =
+ new StructType
(
start_origin,
- new ArrayList(),
- ($new_reference_name.result)
+ field_types,
+ ($identifier.result)
);
- WORLD.text_effects().add(new_text_effect);
+ PARSER.get_world().types().add(new_type);
}
- | REQUIRE_EXTENSION_KW WORD WS* R_PAREN
- {
- WORLD.add_required_extension(($WORD.text));
-
- /* TODO: error report if extension not explicitly enabled. */
- }
-
- | DECLARE_ALIAS_TYPE_KW parent=type WS+ new_reference_name WS* R_PAREN
+ | DECLARE_EXTRA_INSTRUCTION_KW identifier maybe_type_list WS* R_PAREN
{
final Origin start_origin;
- final Type new_type;
+ final ExtraInstruction extra_instruction;
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($DECLARE_ALIAS_TYPE_KW.getLine()),
- ($DECLARE_ALIAS_TYPE_KW.getCharPositionInLine())
+ ($DECLARE_EXTRA_INSTRUCTION_KW.getLine()),
+ ($DECLARE_EXTRA_INSTRUCTION_KW.getCharPositionInLine())
);
- new_type =
- ($parent.result).generate_alias
+ extra_instruction =
+ new ExtraInstruction
(
start_origin,
- ($new_reference_name.result)
+ ($identifier.result),
+ ($type_list.result)
);
- WORLD.types().add(new_type);
+ PARSER.get_world().extra_instructions().add(extra_instruction);
}
- | DECLARE_STRUCT_TYPE_KW
- new_reference_name
- WS*
- variable_list
- WS*
- R_PAREN
+ | DECLARE_EXTRA_COMPUTATION_KW
+ type WS+
+ identifier
+ maybe_type_list WS*
+ R_PAREN
{
final Origin start_origin;
- final Type new_type;
- final Map<String, Type> field_types;
-
- field_types = new HashMap<String, Type>();
-
- for
- (
- final Variable te:
- ($variable_list.result).get_entries()
- )
- {
- field_types.put(te.get_name(), te.get_type());
- }
+ final ExtraComputation extra_computation;
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($DECLARE_STRUCT_TYPE_KW.getLine()),
- ($DECLARE_STRUCT_TYPE_KW.getCharPositionInLine())
+ ($DECLARE_EXTRA_COMPUTATION_KW.getLine()),
+ ($DECLARE_EXTRA_COMPUTATION_KW.getCharPositionInLine())
);
- new_type =
- new StructType
+ extra_computation =
+ new ExtraComputation
(
start_origin,
- field_types,
- ($new_reference_name.result)
+ ($type.result),
+ ($identifier.result),
+ ($type_list.result)
);
- WORLD.types().add(new_type);
+ PARSER.get_world().extra_computations().add(extra_computation);
}
- | DECLARE_EXTRA_TYPE_KW new_reference_name WS* R_PAREN
+ | DECLARE_EXTRA_TYPE_KW identifier maybe_type_list WS* R_PAREN
{
final Origin start_origin;
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($DECLARE_EXTRA_TYPE_KW.getLine()),
($DECLARE_EXTRA_TYPE_KW.getCharPositionInLine())
);
- WORLD.types().add
+ PARSER.get_world().types().add
(
new ExtraType
(
start_origin,
- ($new_reference_name.result)
+ ($identifier.result),
+ ($maybe_type_list.result)
)
);
}
- | DECLARE_EXTRA_INSTRUCTION_KW new_reference_name WS* R_PAREN
+ | DECLARE_EVENT_TYPE_KW identifier maybe_type_list WS* R_PAREN
{
final Origin start_origin;
- final ExtraInstruction extra_instruction;
+ final Event new_event;
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($DECLARE_EXTRA_INSTRUCTION_KW.getLine()),
- ($DECLARE_EXTRA_INSTRUCTION_KW.getCharPositionInLine())
+ ($DECLARE_EVENT_TYPE_KW.getLine()),
+ ($DECLARE_EVENT_TYPE_KW.getCharPositionInLine())
);
- extra_instruction =
- new ExtraInstruction
+ new_event =
+ new Event
(
start_origin,
- ($new_reference_name.result),
- new ArrayList<Type>()
+ ($type_list.result),
+ ($identifier.result)
);
- WORLD.extra_instructions().add(extra_instruction);
+ PARSER.get_world().events().add(new_event);
}
- | DECLARE_EXTRA_INSTRUCTION_KW new_reference_name WS+ type_list WS* R_PAREN
+ | DECLARE_TEXT_EFFECT_KW identifier maybe_type_list WS* R_PAREN
{
final Origin start_origin;
- final ExtraInstruction extra_instruction;
+ final TextEffect new_text_effect;
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($DECLARE_EXTRA_INSTRUCTION_KW.getLine()),
- ($DECLARE_EXTRA_INSTRUCTION_KW.getCharPositionInLine())
+ ($DECLARE_TEXT_EFFECT_KW.getLine()),
+ ($DECLARE_TEXT_EFFECT_KW.getCharPositionInLine())
);
- extra_instruction =
- new ExtraInstruction
+ new_text_effect =
+ new TextEffect
(
start_origin,
- ($new_reference_name.result),
- ($type_list.result)
+ ($type_list.result),
+ ($identifier.result)
);
- WORLD.extra_instructions().add(extra_instruction);
+ PARSER.get_world().text_effects().add(new_text_effect);
}
- | DECLARE_EXTRA_COMPUTATION_KW type WS+ new_reference_name WS+ type_list WS* R_PAREN
+ | DECLARE_GLOBAL_VARIABLE_KW type WS+ name=identifier WS* R_PAREN
{
- final Origin start_origin;
- final ExtraComputation extra_computation;
+ final Origin start_origin, type_origin;
+ final Variable new_variable;
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($DECLARE_EXTRA_COMPUTATION_KW.getLine()),
- ($DECLARE_EXTRA_COMPUTATION_KW.getCharPositionInLine())
+ ($DECLARE_GLOBAL_VARIABLE_KW.getLine()),
+ ($DECLARE_GLOBAl_VARIABLE_KW.getCharPositionInLine())
);
- extra_computation =
- new ExtraComputation
+ new_variable =
+ new Variable
(
start_origin,
($type.result),
- ($new_reference_name.result),
- ($type_list.result)
+ ($name.result),
+ false
);
- WORLD.extra_computations().add(extra_computation);
+ PARSER.get_world().variables().add(new_variable);
}
- | DECLARE_EXTRA_COMPUTATION_KW type WS+ new_reference_name WS* R_PAREN
+ | DECLARE_EXTERNAL_VARIABLE_KW type WS+ name=identifier WS* R_PAREN
{
- final Origin start_origin;
- final ExtraComputation extra_computation;
+ final Origin start_origin, type_origin;
+ final Variable new_variable;
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($DECLARE_EXTRA_COMPUTATION_KW.getLine()),
- ($DECLARE_EXTRA_COMPUTATION_KW.getCharPositionInLine())
+ ($DECLARE_EXTERNAL_VARIABLE_KW.getLine()),
+ ($DECLARE_EXTERNAL_VARIABLE_KW.getCharPositionInLine())
);
- extra_computation =
- new ExtraComputation
+ new_variable =
+ new Variable
(
start_origin,
($type.result),
- ($new_reference_name.result),
- new ArrayList<Type>()
+ ($name.result),
+ true
);
- WORLD.extra_computations().add(extra_computation);
+ PARSER.get_world().variables().add(new_variable);
}
- | DECLARE_EVENT_TYPE_KW new_reference_name WS* R_PAREN
+ | DEFINE_SEQUENCE_KW
+ {
+ previous_local_variables_stack = PARSER.get_local_variables_stack();
+ PARSER.discard_local_variables_stack();
+ PARSER.increase_local_variables_herarchy();
+ }
+ identifier
+ WS*
+ (
+ L_PAREN WS* variable_list WS* R_PAREN
+ {
+ PARSER.add_local_variables(($variable_list.result).as_map());
+ PARSER.increase_local_variables_herarchy();
+ }
+ )
+ pre_sequence_point=WS+
+ maybe_instruction_list
+ WS*
+ R_PAREN
{
- final Origin start_origin;
- final Event new_event;
+ final Origin start_origin, sequence_origin;
+ final Sequence new_sequence;
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($DECLARE_EVENT_TYPE_KW.getLine()),
- ($DECLARE_EVENT_TYPE_KW.getCharPositionInLine())
+ ($DEFINE_SEQUENCE_KW.getLine()),
+ ($DEFINE_SEQUENCE_KW.getCharPositionInLine())
);
- new_event =
- new Event
+ sequence_origin =
+ PARSER.get_origin_at
+ (
+ ($pre_sequence_point.getLine()),
+ ($pre_sequence_point.getCharPositionInLine())
+ );
+
+ new_sequence =
+ new Sequence
(
start_origin,
- new ArrayList<Type>(),
- ($new_reference_name.result)
+ new InstructionList
+ (
+ sequence_origin,
+ ($maybe_instruction_list.result)
+ ),
+ ($identifier.result),
+ ($variable_list.result).get_entries()
);
- WORLD.events().add(new_event);
+ PARSER.get_world().sequences().add(new_sequence);
+ PARSER.restore_local_variables_stack(previous_local_variables_stack);
}
- | DECLARE_EVENT_TYPE_KW new_reference_name WS+ type_list WS* R_PAREN
+
+ | IMP_IGNORE_ERROR_KW WORD WS+ first_level_instruction WS* R_PAREN
{
- final Origin start_origin;
- final Event new_event;
+ /* TODO: temporarily disable an compiler error category */
+ }
- start_origin =
- CONTEXT.get_origin_at
- (
- ($DECLARE_EVENT_TYPE_KW.getLine()),
- ($DECLARE_EVENT_TYPE_KW.getCharPositionInLine())
- );
- new_event =
- new Event
- (
- start_origin,
- ($type_list.result),
- ($new_reference_name.result)
- );
+ | REQUIRE_EXTENSION_KW WORD WS* R_PAREN
+ {
+ WORLD.add_required_extension(($WORD.text));
- WORLD.events().add(new_event);
+ /* TODO: error report if extension not explicitly enabled. */
}
-
| REQUIRE_KW WORD WS* R_PAREN
{
final String filename;
- filename = Files.resolve_filename(CONTEXT, ($WORD.text));
+ filename = Files.resolve_filename(PARSER.get_context(), ($WORD.text));
- if (!WORLD.has_loaded_file(filename))
+ if (!PARSER.get_world().has_loaded_file(filename))
{
- CONTEXT.push
+ PARSER.add_file_content
(
- CONTEXT.get_location_at
+ PARSER.get_location_at
(
($REQUIRE_KW.getLine()),
($REQUIRE_KW.getCharPositionInLine())
),
filename
);
-
- tonkadur.fate.v1.Utils.add_file_content
- (
- filename,
- CONTEXT,
- LOCAL_VARIABLES,
- WORLD
- );
-
- CONTEXT.pop();
}
}
@@ -558,31 +414,21 @@ first_level_fate_instr:
{
final String filename;
- filename = Files.resolve_filename(CONTEXT, ($WORD.text));
+ filename = Files.resolve_filename(PARSER.get_context(), ($WORD.text));
- CONTEXT.push
+ PARSER.add_file_content
(
- CONTEXT.get_location_at
+ PARSER.get_location_at
(
($INCLUDE_KW.getLine()),
($INCLUDE_KW.getCharPositionInLine())
),
filename
);
-
- tonkadur.fate.v1.Utils.add_file_content
- (
- filename,
- CONTEXT,
- LOCAL_VARIABLES,
- WORLD
- );
-
- CONTEXT.pop();
}
/*
- | EXTENSION_FIRST_LEVEL_KW WORD WS+ general_fate_sequence WS* R_PAREN
+ | EXTENSION_FIRST_LEVEL_KW WORD WS+ instruction_list WS* R_PAREN
{
final Origin origin;
final ExtensionInstruction instr;
@@ -605,57 +451,59 @@ first_level_fate_instr:
}
else
{
- instr.build(WORLD, CONTEXT, origin, ($general_fate_sequence.result));
+ instr.build(WORLD, CONTEXT, origin, ($instruction_list.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);
- }
+ PARSER.handle_error(e);
}
/* Trying to get rule priorities right */
-general_fate_instr
+instruction
returns [Instruction result]
:
- L_PAREN WS+ general_fate_sequence WS+ R_PAREN
+ L_PAREN WS* maybe_instruction_list WS* R_PAREN
{
+ /*
+ * Don't define a local variable hierachy just for that group, as it would
+ * prevent things like
+ * (for
+ * (
+ * (local int i)
+ * (set i 0)
+ * )
+ * (< i 3)
+ * (set i (+ i 1))
+ * stuff
+ * )
+ *
+ */
$result =
new InstructionList
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($L_PAREN.getLine()),
($L_PAREN.getCharPositionInLine())
),
- ($general_fate_sequence.result)
+ ($maybe_instruction_list.result)
);
}
- | LOCAL_KW
- type
- WS+
- name=new_reference_name
- WS*
- R_PAREN
+ | DECLARE_LOCAL_VARIABLE_KW type WS+ name=identifier WS* R_PAREN
{
final Origin start_origin, type_origin;
final Variable new_variable;
final Map<String, Variable> variable_map;
start_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($LOCAL_KW.getLine()),
- ($LOCAL_KW.getCharPositionInLine())
+ ($DECLARE_LOCAL_VARIABLE_KW.getLine()),
+ ($DECLARE_LOCAL_VARIABLE_KW.getCharPositionInLine())
);
new_variable =
@@ -667,1120 +515,88 @@ returns [Instruction result]
false
);
- variable_map = LOCAL_VARIABLES.peekFirst();
-
- if (variable_map.containsKey(($name.result)))
- {
- ErrorManager.handle
- (
- new DuplicateLocalVariableException
- (
- variable_map.get(($name.result)),
- new_variable
- )
- );
- }
- else
- {
- variable_map.put(($name.result), new_variable);
- }
+ PARSER.add_local_variable(new_variable);
$result = new LocalVariable(new_variable);
-
- if (!HIERARCHICAL_VARIABLES.isEmpty())
- {
- HIERARCHICAL_VARIABLES.peekFirst().add(new_variable.get_name());
- }
}
- | PROMPT_STRING_KW
- targetv=non_text_value WS+
- min_size=non_text_value WS+
- max_size=non_text_value WS+
- paragraph WS*
- R_PAREN
- {
- $result =
- PromptString.build
- (
- CONTEXT.get_origin_at
- (
- ($PROMPT_STRING_KW.getLine()),
- ($PROMPT_STRING_KW.getCharPositionInLine())
- ),
- ($targetv.result),
- ($min_size.result),
- ($max_size.result),
- ($paragraph.result)
- );
- }
-
- | PROMPT_INTEGER_KW
- targetv=non_text_value WS+
- min_size=non_text_value WS+
- max_size=non_text_value WS+
- paragraph WS*
- R_PAREN
- {
- $result =
- PromptInteger.build
- (
- CONTEXT.get_origin_at
- (
- ($PROMPT_INTEGER_KW.getLine()),
- ($PROMPT_INTEGER_KW.getCharPositionInLine())
- ),
- ($targetv.result),
- ($min_size.result),
- ($max_size.result),
- ($paragraph.result)
- );
- }
-
- | IMP_DICT_SET_KW key=value WS+ val=value WS+ value_reference WS* R_PAREN
- {
- // TODO
- $result = null;
- /*
- SetEntry.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_DICT_SET_KW.getLine()),
- ($IMP_DICT_SET_KW.getCharPositionInLine())
- ),
- ($key.result),
- ($val.result)
- );
- */
- }
-
- | IMP_ADD_KW value_list WS+ value_reference WS* R_PAREN
- {
- final List<Instruction> add_instrs;
-
- add_instrs = new ArrayList<Instruction>();
-
- for (final Computation value: ($value_list.result))
- {
- add_instrs.add
- (
- AddElement.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_ADD_KW.getLine()),
- ($IMP_ADD_KW.getCharPositionInLine())
- ),
- value,
- ($value_reference.result)
- )
- );
- }
-
- $result =
- new InstructionList
- (
- CONTEXT.get_origin_at
- (
- ($IMP_ADD_KW.getLine()),
- ($IMP_ADD_KW.getCharPositionInLine())
- ),
- add_instrs
- );
- }
-
- | IMP_ADD_AT_KW
- index=non_text_value WS+
- element=value WS+
- value_reference WS*
- R_PAREN
- {
- $result =
- AddElementAt.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_ADD_AT_KW.getLine()),
- ($IMP_ADD_AT_KW.getCharPositionInLine())
- ),
- ($index.result),
- ($element.result),
- ($value_reference.result)
- );
- }
-
- | IMP_ADD_ALL_KW
- sourcev=non_text_value WS+
- target=value_reference WS*
- R_PAREN
- {
- $result =
- AddElementsOf.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_ADD_ALL_KW.getLine()),
- ($IMP_ADD_ALL_KW.getCharPositionInLine())
- ),
- ($sourcev.result),
- ($target.result)
- );
- }
-
- | END_KW
- {
- $result =
- new End
- (
- CONTEXT.get_origin_at
- (
- ($END_KW.getLine()),
- ($END_KW.getCharPositionInLine())
- )
- );
- }
-
- | DONE_KW
- {
- $result =
- new Done
- (
- CONTEXT.get_origin_at
- (
- ($DONE_KW.getLine()),
- ($DONE_KW.getCharPositionInLine())
- )
- );
- }
-
- | IMP_IGNORE_ERROR_KW WORD WS+ general_fate_instr WS* R_PAREN
- {
- /* TODO: temporarily disable an compiler error category */
- $result = ($general_fate_instr.result);
- }
-
- | IMP_DICT_REMOVE_KW
- value WS+
- value_reference WS*
- R_PAREN
- {
- // TODO
- $result = null;
- /*
- RemoveEntry.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_DICT_REMOVE_KW.getLine()),
- ($IMP_DICT_REMOVE_KW.getCharPositionInLine())
- ),
- ($value.result),
- ($value_reference.result)
- );
- */
- }
-
- | IMP_REMOVE_ONE_KW
- value WS+
- value_reference WS*
- R_PAREN
- {
- $result =
- RemoveElement.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_REMOVE_ONE_KW.getLine()),
- ($IMP_REMOVE_ONE_KW.getCharPositionInLine())
- ),
- ($value.result),
- ($value_reference.result)
- );
- }
-
- | IMP_REMOVE_AT_KW
- non_text_value WS+
- value_reference WS*
- R_PAREN
- {
- $result =
- RemoveElementAt.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_REMOVE_AT_KW.getLine()),
- ($IMP_REMOVE_AT_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result)
- );
- }
-
- | IMP_REMOVE_ALL_KW
- value WS+
- value_reference WS*
- R_PAREN
- {
- $result =
- RemoveAllOfElement.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_REMOVE_ALL_KW.getLine()),
- ($IMP_REMOVE_ALL_KW.getCharPositionInLine())
- ),
- ($value.result),
- ($value_reference.result)
- );
- }
-
- | IMP_CLEAR_KW value_reference WS* R_PAREN
- {
- $result =
- Clear.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_CLEAR_KW.getLine()),
- ($IMP_CLEAR_KW.getCharPositionInLine())
- ),
- ($value_reference.result)
- );
- }
-
- | IMP_REVERSE_KW value_reference WS* R_PAREN
- {
- $result =
- ReverseList.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_REVERSE_KW.getLine()),
- ($IMP_REVERSE_KW.getCharPositionInLine())
- ),
- ($value_reference.result)
- );
- }
-
- | IMP_PUSH_LEFT_KW value WS+ value_reference WS* R_PAREN
- {
- $result =
- PushElement.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_PUSH_LEFT_KW.getLine()),
- ($IMP_PUSH_LEFT_KW.getCharPositionInLine())
- ),
- ($value.result),
- ($value_reference.result),
- true
- );
- }
-
- | IMP_PUSH_RIGHT_KW value WS+ value_reference WS* R_PAREN
- {
- $result =
- PushElement.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_PUSH_RIGHT_KW.getLine()),
- ($IMP_PUSH_RIGHT_KW.getCharPositionInLine())
- ),
- ($value.result),
- ($value_reference.result),
- false
- );
- }
-
- | IMP_POP_RIGHT_KW value_reference WS+ non_text_value WS* R_PAREN
- {
- $result =
- PopElement.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_POP_RIGHT_KW.getLine()),
- ($IMP_POP_RIGHT_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- false
- );
- }
-
- | IMP_POP_LEFT_KW value_reference WS+ non_text_value WS* R_PAREN
- {
- $result =
- PopElement.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_POP_LEFT_KW.getLine()),
- ($IMP_POP_LEFT_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- true
- );
- }
-
- | IMP_MAP_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- $result =
- tonkadur.fate.v1.lang.instruction.Map.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_MAP_KW.getLine()),
- ($IMP_MAP_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- new ArrayList()
- );
- }
-
- | IMP_DICT_MAP_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- // TODO
- $result = null;
- /*
- DictMap.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_DICT_MAP_KW.getLine()),
- ($IMP_DICT_MAP_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- new ArrayList()
- );
- */
- }
-
-
- | IMP_MAP_KW non_text_value WS+ value_reference WS+ value_list WS* R_PAREN
- {
- $result =
- tonkadur.fate.v1.lang.instruction.Map.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_MAP_KW.getLine()),
- ($IMP_MAP_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- ($value_list.result)
- );
- }
-
- | IMP_INDEXED_MAP_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- $result =
- IndexedMap.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_INDEXED_MAP_KW.getLine()),
- ($IMP_INDEXED_MAP_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- new ArrayList()
- );
- }
-
- | IMP_INDEXED_MAP_KW
- non_text_value WS+
- value_reference WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedMap.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_INDEXED_MAP_KW.getLine()),
- ($IMP_INDEXED_MAP_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- ($value_list.result)
- );
- }
-
- | IMP_DICT_MERGE_KW
- fun=non_text_value WS+
- inv1=non_text_value WS+
- value_reference WS*
- R_PAREN
- {
- // TODO
- $result = null;
- /*
- DictMerge.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_DICT_MERGE_KW.getLine()),
- ($IMP_DICT_MERGE_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv1.result),
- ($value_reference.result),
- new ArrayList()
- );
- */
- }
-
- | IMP_DICT_MERGE_KW
- fun=non_text_value WS+
- inv1=non_text_value WS+
- value_reference WS+
- value_list WS*
- R_PAREN
- {
- // TODO
- $result = null;
- /*
- DictMerge.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_DICT_MERGE_KW.getLine()),
- ($IMP_DICT_MERGE_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv1.result),
- ($value_reference.result),
- ($value_list.result)
- );
- */
- }
-
- | IMP_MERGE_KW
- fun=non_text_value WS+
- inv1=non_text_value WS+
- value_reference WS*
- R_PAREN
- {
- $result =
- Merge.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_MERGE_KW.getLine()),
- ($IMP_MERGE_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv1.result),
- null,
- ($value_reference.result),
- null,
- new ArrayList()
- );
- }
-
- | IMP_MERGE_KW
- fun=non_text_value WS+
- inv1=non_text_value WS+
- value_reference WS+
- value_list WS*
- R_PAREN
- {
- $result =
- Merge.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_MERGE_KW.getLine()),
- ($IMP_MERGE_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv1.result),
- null,
- ($value_reference.result),
- null,
- ($value_list.result)
- );
- }
-
- | IMP_INDEXED_MERGE_KW
- fun=non_text_value WS+
- inv1=non_text_value WS+
- value_reference WS*
- R_PAREN
- {
- $result =
- IndexedMerge.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_INDEXED_MERGE_KW.getLine()),
- ($IMP_INDEXED_MERGE_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv1.result),
- null,
- ($value_reference.result),
- null,
- new ArrayList()
- );
- }
-
- | IMP_INDEXED_MERGE_KW
- fun=non_text_value WS+
- inv1=non_text_value WS+
- value_reference WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedMerge.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_INDEXED_MERGE_KW.getLine()),
- ($IMP_INDEXED_MERGE_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv1.result),
- null,
- ($value_reference.result),
- null,
- ($value_list.result)
- );
- }
-
- | SAFE_IMP_MERGE_KW
- fun=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS+
- def0=value WS+
- value_reference WS*
- R_PAREN
- {
- $result =
- Merge.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_IMP_MERGE_KW.getLine()),
- ($SAFE_IMP_MERGE_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv1.result),
- ($def1.result),
- ($value_reference.result),
- ($def0.result),
- new ArrayList()
- );
- }
-
- | SAFE_IMP_MERGE_KW
- fun=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS+
- def0=value WS+
- value_reference WS+
- value_list WS*
- R_PAREN
- {
- $result =
- Merge.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_IMP_MERGE_KW.getLine()),
- ($SAFE_IMP_MERGE_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv1.result),
- ($def1.result),
- ($value_reference.result),
- ($def0.result),
- ($value_list.result)
- );
- }
-
- | SAFE_IMP_INDEXED_MERGE_KW
- fun=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS+
- def0=value WS+
- value_reference WS*
- R_PAREN
- {
- $result =
- IndexedMerge.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_IMP_INDEXED_MERGE_KW.getLine()),
- ($SAFE_IMP_INDEXED_MERGE_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv1.result),
- ($def1.result),
- ($value_reference.result),
- ($def0.result),
- new ArrayList()
- );
- }
-
- | SAFE_IMP_INDEXED_MERGE_KW
- fun=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS+
- def0=value WS+
- value_reference WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedMerge.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_IMP_INDEXED_MERGE_KW.getLine()),
- ($SAFE_IMP_INDEXED_MERGE_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv1.result),
- ($def1.result),
- ($value_reference.result),
- ($def0.result),
- ($value_list.result)
- );
- }
-
- | IMP_SUB_LIST_KW
- vstart=non_text_value WS+
- vend=non_text_value WS+
- value_reference WS*
- R_PAREN
- {
- $result =
- SubList.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_SUB_LIST_KW.getLine()),
- ($IMP_SUB_LIST_KW.getCharPositionInLine())
- ),
- ($vstart.result),
- ($vend.result),
- ($value_reference.result)
- );
- }
-
- | IMP_FILTER_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- $result =
- Filter.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_FILTER_KW.getLine()),
- ($IMP_FILTER_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- new ArrayList()
- );
- }
-
- | IMP_FILTER_KW non_text_value WS+ value_reference WS+ value_list WS* R_PAREN
- {
- $result =
- Filter.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_FILTER_KW.getLine()),
- ($IMP_FILTER_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- ($value_list.result)
- );
- }
-
- | IMP_INDEXED_FILTER_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- $result =
- IndexedFilter.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_INDEXED_FILTER_KW.getLine()),
- ($IMP_INDEXED_FILTER_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- new ArrayList()
- );
- }
-
- | IMP_INDEXED_FILTER_KW
- non_text_value WS+
- value_reference WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedFilter.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_INDEXED_FILTER_KW.getLine()),
- ($IMP_INDEXED_FILTER_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- ($value_list.result)
- );
- }
-
- | IMP_PARTITION_KW
- non_text_value WS+
- iftrue=value_reference WS+
- iffalse=value_reference WS*
- R_PAREN
- {
- $result =
- Partition.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_PARTITION_KW.getLine()),
- ($IMP_PARTITION_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($iftrue.result),
- ($iffalse.result),
- new ArrayList()
- );
- }
-
- | IMP_PARTITION_KW
- non_text_value WS+
- iftrue=value_reference WS+
- iffalse=value_reference WS+
- value_list WS*
- R_PAREN
- {
- $result =
- Partition.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_PARTITION_KW.getLine()),
- ($IMP_PARTITION_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($iftrue.result),
- ($iffalse.result),
- ($value_list.result)
- );
- }
-
- | IMP_INDEXED_PARTITION_KW
- non_text_value WS+
- iftrue=value_reference WS+
- iffalse=value_reference WS*
- R_PAREN
- {
- $result =
- IndexedPartition.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_INDEXED_PARTITION_KW.getLine()),
- ($IMP_INDEXED_PARTITION_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($iftrue.result),
- ($iffalse.result),
- new ArrayList()
- );
- }
-
- | IMP_INDEXED_PARTITION_KW
- non_text_value WS+
- iftrue=value_reference WS+
- iffalse=value_reference WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedPartition.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_INDEXED_PARTITION_KW.getLine()),
- ($IMP_INDEXED_PARTITION_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($iftrue.result),
- ($iffalse.result),
- ($value_list.result)
- );
- }
-
- | IMP_SORT_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- $result =
- Sort.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_SORT_KW.getLine()),
- ($IMP_SORT_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- new ArrayList()
- );
- }
-
- | IMP_SORT_KW non_text_value WS+ value_reference WS+ value_list WS* R_PAREN
- {
- $result =
- Sort.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_SORT_KW.getLine()),
- ($IMP_SORT_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value_reference.result),
- ($value_list.result)
- );
- }
-
-
- | IMP_SHUFFLE_KW value_reference WS* R_PAREN
- {
- $result =
- Shuffle.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_SHUFFLE_KW.getLine()),
- ($IMP_SHUFFLE_KW.getCharPositionInLine())
- ),
- ($value_reference.result)
- );
- }
-
- | IMP_SET_KW value_reference WS+ value WS* R_PAREN
- {
- $result =
- SetValue.build
- (
- CONTEXT.get_origin_at
- (
- ($IMP_SET_KW.getLine()),
- ($IMP_SET_KW.getCharPositionInLine())
- ),
- ($value.result),
- ($value_reference.result)
- );
- }
-
- | ALLOCATE_KW value_reference WS* R_PAREN
- {
- final Origin origin;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($ALLOCATE_KW.getLine()),
- ($ALLOCATE_KW.getCharPositionInLine())
- );
-
- $result = Allocate.build(origin, ($value_reference.result));
- }
-
-
- | FREE_KW value_reference WS* R_PAREN
+/******************************************************************************/
+/**** LOOPS *******************************************************************/
+/******************************************************************************/
+ | COND_KW instruction_cond_list WS* R_PAREN
{
$result =
- new Free
- (
- CONTEXT.get_origin_at
- (
- ($FREE_KW.getLine()),
- ($FREE_KW.getCharPositionInLine())
- ),
- ($value_reference.result)
- );
- }
-
- | IMP_SET_FIELDS_KW value_reference WS* field_value_list WS* R_PAREN
- {
- /*
- * A bit of a lazy solution: build field references, then extract the data
- */
- final List<Cons<String, Computation>> assignments;
-
- assignments = new ArrayList<Cons<String, Computation>>();
-
- for
- (
- final Cons<Origin, Cons<String, Computation>> entry:
- ($field_value_list.result)
- )
- {
- final FieldReference fr;
- final Computation cp;
-
- fr =
- FieldReference.build
- (
- entry.get_car(),
- ($value_reference.result),
- entry.get_cdr().get_car()
- );
-
- cp = entry.get_cdr().get_cdr();
-
- RecurrentChecks.assert_can_be_used_as(cp, fr.get_type());
-
- assignments.add(new Cons(fr.get_field_name(), cp));
- }
-
- $result =
- new SetFields
+ CondInstruction.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($IMP_SET_FIELDS_KW.getLine()),
- ($IMP_SET_FIELDS_KW.getCharPositionInLine())
+ ($COND_KW.getLine()),
+ ($COND_KW.getCharPositionInLine())
),
- ($value_reference.result),
- assignments
+ ($instruction_cond_list.result)
);
}
- | WHILE_KW non_text_value WS*
- {
- BREAKABLE_LEVELS++;
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- general_fate_sequence
- {
- BREAKABLE_LEVELS--;
-
- for (final String s: HIERARCHICAL_VARIABLES.pop())
+ | DO_WHILE_KW computation WS*
{
- LOCAL_VARIABLES.peekFirst().remove(s);
+ PARSER.increment_breakable_levels();
+ PARSER.increment_continue_levels();
+ PARSER.increase_local_variables_hierarchy();
}
- }
- WS*
+ maybe_instruction_list WS*
R_PAREN
{
- $result =
- While.build
- (
- CONTEXT.get_origin_at
- (
- ($WHILE_KW.getLine()),
- ($WHILE_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($general_fate_sequence.result)
- );
- }
-
- | DO_WHILE_KW non_text_value WS*
- {
- BREAKABLE_LEVELS++;
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- general_fate_sequence
- {
- BREAKABLE_LEVELS--;
+ PARSER.decrease_local_variables_hierarchy();
+ PARSER.decrement_continue_levels();
+ PARSER.decrement_breakable_levels();
- for (final String s: HIERARCHICAL_VARIABLES.pop())
- {
- LOCAL_VARIABLES.peekFirst().remove(s);
- }
- }
- WS*
- R_PAREN
- {
$result =
DoWhile.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($DO_WHILE_KW.getLine()),
($DO_WHILE_KW.getCharPositionInLine())
),
- ($non_text_value.result),
- ($general_fate_sequence.result)
+ ($computation.result),
+ ($maybe_instruction_list.result)
);
}
- | {BREAKABLE_LEVELS > 0}? IMP_BREAK_KW
- {
- $result =
- new Break
- (
- CONTEXT.get_origin_at
- (
- ($IMP_BREAK_KW.getLine()),
- ($IMP_BREAK_KW.getCharPositionInLine())
- )
- );
- }
-
- | FOR_KW pre=general_fate_instr WS*
- non_text_value WS*
- post=general_fate_instr WS*
- {
- BREAKABLE_LEVELS++;
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- general_fate_sequence
- {
- BREAKABLE_LEVELS--;
-
- for (final String s: HIERARCHICAL_VARIABLES.pop())
+ | FOR_KW
{
- LOCAL_VARIABLES.peekFirst().remove(s);
+ PARSER.increase_local_variables_hierarchy();
}
- }
- WS* R_PAREN
+ pre=instruction WS* computation WS* post=instruction WS*
+ {
+ PARSER.increment_breakable_levels();
+ PARSER.increment_continue_levels();
+ }
+ maybe_instruction_list
+ WS*
+ R_PAREN
{
+ PARSER.decrement_continue_levels();
+ PARSER.decrement_breakable_levels();
+ PARSER.decrease_local_variables_hierarchy();
+
$result =
For.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($FOR_KW.getLine()),
($FOR_KW.getCharPositionInLine())
),
- ($non_text_value.result),
+ ($computation.result),
($pre.result),
- ($general_fate_sequence.result),
+ ($maybe_instruction_list.result),
($post.result)
);
}
- | FOR_EACH_KW
- coll=non_text_value WS+ new_reference_name
+ | FOR_EACH_KW coll=computation WS+ identifier
{
- final Map<String, Variable> variable_map;
final Variable new_variable;
final Type collection_type;
Type elem_type;
@@ -1789,6 +605,7 @@ returns [Instruction result]
collection_type = ($coll.result).get_type();
+ /* FIXME: This doesn't let you use it with a Dict. */
if (collection_type instanceof CollectionType)
{
elem_type = ((CollectionType) collection_type).get_content_type();
@@ -1799,7 +616,7 @@ returns [Instruction result]
(
new InvalidTypeException
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($FOR_EACH_KW.getLine()),
($FOR_EACH_KW.getCharPositionInLine())
@@ -1812,526 +629,317 @@ returns [Instruction result]
elem_type = Type.ANY;
}
-
new_variable =
new Variable
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($FOR_EACH_KW.getLine()),
($FOR_EACH_KW.getCharPositionInLine())
),
elem_type,
- ($new_reference_name.result),
+ ($identifier.result),
false
);
- variable_map = LOCAL_VARIABLES.peekFirst();
+ PARSER.increase_local_variables_hierarchy();
+ PARSER.increment_breakable_levels();
+ PARSER.increment_continue_levels();
- if (variable_map.containsKey(($new_reference_name.result)))
- {
- ErrorManager.handle
- (
- new DuplicateLocalVariableException
- (
- variable_map.get(($new_reference_name.result)),
- new_variable
- )
- );
- }
- else
- {
- variable_map.put(($new_reference_name.result), new_variable);
- }
- }
- WS+
- {
- BREAKABLE_LEVELS++;
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- general_fate_sequence
- {
- BREAKABLE_LEVELS--;
-
- for (final String s: HIERARCHICAL_VARIABLES.pop())
- {
- LOCAL_VARIABLES.peekFirst().remove(s);
- }
+ PARSER.add_local_variable(new_variable);
}
- WS*
- R_PAREN
+ WS+ maybe_instruction_list WS* R_PAREN
{
+ PARSER.decrement_continue_levels();
+ PARSER.decrement_breakable_levels();
+ PARSER.decrease_local_variables_hierarchy();
+
$result =
new ForEach
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($FOR_EACH_KW.getLine()),
($FOR_EACH_KW.getCharPositionInLine())
),
($coll.result),
- ($new_reference_name.result),
- ($general_fate_sequence.result)
+ ($identifier.result),
+ ($maybe_instruction_list.result)
);
-
- variable_map.remove(($new_reference_name.result));
}
- | EXTRA_INSTRUCTION_KW WORD WS+ value_list WS* R_PAREN
+ | WHILE_KW computation WS*
+ {
+ PARSER.increase_local_variables_hierarchy();
+ PARSER.increment_breakable_levels();
+ PARSER.increment_continue_levels();
+ }
+ maybe_instruction_list WS* R_PAREN
{
- final Origin origin;
- final ExtraInstruction extra_instruction;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($EXTRA_INSTRUCTION_KW.getLine()),
- ($EXTRA_INSTRUCTION_KW.getCharPositionInLine())
- );
-
- extra_instruction = WORLD.extra_instructions().get(origin, ($WORD.text));
+ PARSER.decrement_continue_levels();
+ PARSER.decrement_breakable_levels();
+ PARSER.decrease_local_variables_hierarchy();
$result =
- extra_instruction.instantiate
+ While.build
(
- WORLD,
- CONTEXT,
- origin,
- ($value_list.result)
+ PARSER.get_origin_at
+ (
+ ($WHILE_KW.getLine()),
+ ($WHILE_KW.getCharPositionInLine())
+ ),
+ ($computation.result),
+ ($maybe_instruction_list.result)
);
}
- | EXTRA_INSTRUCTION_KW WORD WS* R_PAREN
+ | SWITCH_KW computation WS*
+ {
+ PARSER.increment_breakable_levels();
+ }
+ instr_cond_list WS*
+ {
+ PARSER.increase_local_variables_hierarchy();
+ }
+ instruction WS*
+ R_PAREN
{
- final Origin origin;
- final ExtraInstruction extra_instruction;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($EXTRA_INSTRUCTION_KW.getLine()),
- ($EXTRA_INSTRUCTION_KW.getCharPositionInLine())
- );
-
- extra_instruction = WORLD.extra_instructions().get(origin, ($WORD.text));
+ PARSER.decrease_local_variables_hierarchy();
+ PARSER.decrement_breakable_levels();
$result =
- extra_instruction.instantiate
- (
- WORLD,
- CONTEXT,
- origin,
- new ArrayList<Computation>()
- );
- }
-
- | VISIT_KW WORD WS+ value_list WS* R_PAREN
- {
- final Origin origin;
- final String sequence_name;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($VISIT_KW.getLine()),
- ($VISIT_KW.getCharPositionInLine())
- );
-
- sequence_name = ($WORD.text);
-
- WORLD.add_sequence_use(origin, sequence_name, ($value_list.result));
-
- $result = new SequenceCall(origin, sequence_name, ($value_list.result));
- }
-
- | VISIT_KW WORD WS* R_PAREN
- {
- final Origin origin;
- final String sequence_name;
- final List<Computation> params;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($VISIT_KW.getLine()),
- ($VISIT_KW.getCharPositionInLine())
- );
-
- params = new ArrayList<Computation>();
-
- sequence_name = ($WORD.text);
-
- WORLD.add_sequence_use(origin, sequence_name, params);
-
- $result = new SequenceCall(origin, sequence_name, params);
- }
-
- | CONTINUE_AS_KW WORD WS+ value_list WS* R_PAREN
- {
- final Origin origin;
- final String sequence_name;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($CONTINUE_AS_KW.getLine()),
- ($CONTINUE_AS_KW.getCharPositionInLine())
- );
-
- sequence_name = ($WORD.text);
-
- WORLD.add_sequence_use(origin, sequence_name, ($value_list.result));
-
- $result = new SequenceJump(origin, sequence_name, ($value_list.result));
- }
-
- | CONTINUE_AS_KW WORD WS* R_PAREN
- {
- final Origin origin;
- final String sequence_name;
- final List<Computation> params;
-
- origin =
- CONTEXT.get_origin_at
+ SwitchInstruction.build
(
- ($CONTINUE_AS_KW.getLine()),
- ($CONTINUE_AS_KW.getCharPositionInLine())
+ PARSER.get_origin_at
+ (
+ ($SWITCH_KW.getLine()),
+ ($SWITCH_KW.getCharPositionInLine())
+ ),
+ ($computation.result),
+ ($instr_cond_list.result),
+ ($instruction.result)
);
-
- params = new ArrayList<Computation>();
-
- sequence_name = ($WORD.text);
-
- WORLD.add_sequence_use(origin, sequence_name, params);
-
- $result = new SequenceJump(origin, sequence_name, params);
}
- | VISIT_KW value WS+ value_list WS* R_PAREN
+/******************************************************************************/
+/**** IF ELSE *****************************************************************/
+/******************************************************************************/
+ | IF_KW computation WS*
+ {
+ PARSER.increase_local_variables_hierarchy();
+ }
+ maybe_instruction_list WS*
+ R_PAREN
{
- final Origin origin;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($VISIT_KW.getLine()),
- ($VISIT_KW.getCharPositionInLine())
- );
+ PARSER.decrease_local_variables_hierarchy();
$result =
- SequenceVariableCall.build
+ IfInstruction.build
(
- origin,
- ($value.result),
- ($value_list.result)
+ PARSER.get_origin_at
+ (
+ ($IF_KW.getLine()),
+ ($IF_KW.getCharPositionInLine())
+ ),
+ ($computation.result),
+ ($maybe_instruction_list.result)
);
}
- | VISIT_KW value WS* R_PAREN
+ | IF_ELSE_KW computation
+ {
+ PARSER.increase_local_variables_hierarchy();
+ }
+ WS* if_true=instruction
+ {
+ PARSER.decrease_local_variables_hierarchy();
+ PARSER.increase_local_variables_hierarchy();
+ }
+ WS* if_false=instruction WS*
+ R_PAREN
{
- final Origin origin;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($VISIT_KW.getLine()),
- ($VISIT_KW.getCharPositionInLine())
- );
+ PARSER.decrease_local_variables_hierarchy();
$result =
- SequenceVariableCall.build
+ IfElseInstruction.build
(
- origin,
- ($value.result),
- new ArrayList<Computation>()
+ PARSER.get_origin_at
+ (
+ ($IF_ELSE_KW.getLine()),
+ ($IF_ELSE_KW.getCharPositionInLine())
+ ),
+ ($computation.result),
+ ($if_true.result),
+ ($if_false.result)
);
}
- | CONTINUE_AS_KW value WS+ value_list WS* R_PAREN
- {
- final Origin origin;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($CONTINUE_AS_KW.getLine()),
- ($CONTINUE_AS_KW.getCharPositionInLine())
- );
-
- $result =
- SequenceVariableJump.build
- (
- origin,
- ($value.result),
- ($value_list.result)
- );
- }
+/******************************************************************************/
+/**** ERRORS ******************************************************************/
+/******************************************************************************/
- | CONTINUE_AS_KW value WS* R_PAREN
+ | IMP_IGNORE_ERROR_KW WORD WS+ instruction WS* R_PAREN
{
- final Origin origin;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($CONTINUE_AS_KW.getLine()),
- ($CONTINUE_AS_KW.getCharPositionInLine())
- );
-
- $result =
- SequenceVariableJump.build
- (
- origin,
- ($value.result),
- new ArrayList<Computation>()
- );
+ /* TODO: temporarily disable an compiler error category */
+ $result = ($instruction.result);
}
- | IMP_ASSERT_KW non_text_value WS+ paragraph WS* R_PAREN
+ | IMP_ASSERT_KW computation WS+ paragraph WS* R_PAREN
{
$result =
Assert.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($IMP_ASSERT_KW.getLine()),
($IMP_ASSERT_KW.getCharPositionInLine())
),
- ($non_text_value.result),
+ ($computation.result),
($paragraph.result)
);
}
- | IF_KW non_text_value WS*
- {
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- general_fate_sequence
+/******************************************************************************/
+/**** STRUCTURES **************************************************************/
+/******************************************************************************/
+
+ | IMP_SET_FIELDS_KW computation WS* field_value_list WS* R_PAREN
+ {
+ /*
+ * A bit of a lazy solution: build field references, then extract the data
+ */
+ final List<Cons<String, Computation>> assignments;
+
+ assignments = new ArrayList<Cons<String, Computation>>();
+
+ for
+ (
+ final Cons<Origin, Cons<String, Computation>> entry:
+ ($field_value_list.result)
+ )
{
- for (final String s: HIERARCHICAL_VARIABLES.pop())
- {
- LOCAL_VARIABLES.peekFirst().remove(s);
- }
+ final FieldReference fr;
+ final Computation cp;
+
+ fr =
+ FieldReference.build
+ (
+ entry.get_car(),
+ ($computation.result),
+ entry.get_cdr().get_car()
+ );
+
+ cp = entry.get_cdr().get_cdr();
+
+ RecurrentChecks.assert_can_be_used_as(cp, fr.get_type());
+
+ assignments.add(new Cons(fr.get_field_name(), cp));
}
- WS* R_PAREN
- {
+
$result =
- IfInstruction.build
+ new SetFields
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($IF_KW.getLine()),
- ($IF_KW.getCharPositionInLine())
+ ($IMP_SET_FIELDS_KW.getLine()),
+ ($IMP_SET_FIELDS_KW.getCharPositionInLine())
),
- ($non_text_value.result),
- ($general_fate_sequence.result)
+ ($computation.result),
+ assignments
);
}
- | IF_ELSE_KW
- non_text_value
- {
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- WS+ if_true=general_fate_instr
- {
- for (final String s: HIERARCHICAL_VARIABLES.pop())
- {
- LOCAL_VARIABLES.peekFirst().remove(s);
- }
+/******************************************************************************/
+/**** PLAYER INPUTS ***********************************************************/
+/******************************************************************************/
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- WS+ if_false=general_fate_instr
+ | PLAYER_CHOICE_KW
{
- for (final String s: HIERARCHICAL_VARIABLES.pop())
- {
- LOCAL_VARIABLES.peekFirst().remove(s);
- }
-
+ // FIXME: handle player_choice limited local variables.
+ PARSER.push_choice_limited_variables_level();
}
- WS* R_PAREN
+ player_choice_list WS*
+ R_PAREN
{
$result =
- IfElseInstruction.build
+ new PlayerChoice
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($IF_ELSE_KW.getLine()),
- ($IF_ELSE_KW.getCharPositionInLine())
+ ($PLAYER_CHOICE_KW.getLine()),
+ ($PLAYER_CHOICE_KW.getCharPositionInLine())
),
- ($non_text_value.result),
- ($if_true.result),
- ($if_false.result)
+ ($player_choice_list.result)
);
+
+ PARSER.pop_choice_limited_variables_level();
}
- | COND_KW instr_cond_list WS* R_PAREN
+ | PROMPT_STRING_KW
+ targetv=computation WS+
+ min_size=computation WS+
+ max_size=computation WS+
+ paragraph WS*
+ R_PAREN
{
$result =
- CondInstruction.build
+ PromptString.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($COND_KW.getLine()),
- ($COND_KW.getCharPositionInLine())
+ ($PROMPT_STRING_KW.getLine()),
+ ($PROMPT_STRING_KW.getCharPositionInLine())
),
- ($instr_cond_list.result)
+ ($targetv.result),
+ ($min_size.result),
+ ($max_size.result),
+ ($paragraph.result)
);
}
- | SWITCH_KW non_text_value WS*
- instr_cond_list WS*
- general_fate_instr WS*
+ | PROMPT_INTEGER_KW
+ targetv=computation WS+
+ min_size=computation WS+
+ max_size=computation WS+
+ paragraph WS*
R_PAREN
{
$result =
- SwitchInstruction.build
+ PromptInteger.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($SWITCH_KW.getLine()),
- ($SWITCH_KW.getCharPositionInLine())
+ ($PROMPT_INTEGER_KW.getLine()),
+ ($PROMPT_INTEGER_KW.getCharPositionInLine())
),
- ($non_text_value.result),
- ($instr_cond_list.result),
- ($general_fate_instr.result)
+ ($targetv.result),
+ ($min_size.result),
+ ($max_size.result),
+ ($paragraph.result)
);
}
- | PLAYER_CHOICE_KW
- {
- CHOICE_LIMITED_VARIABLES.push(new HashSet<String>());
- }
- player_choice_list WS* R_PAREN
+/******************************************************************************/
+/**** GENERIC INSTRUCTIONS ****************************************************/
+/******************************************************************************/
+ | L_PAREN identifier IMP_MARKER maybe_computation_list WS* R_PAREN
{
$result =
- new PlayerChoice
+ GenericInstruction.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($PLAYER_CHOICE_KW.getLine()),
- ($PLAYER_CHOICE_KW.getCharPositionInLine())
+ ($L_PAREN.getLine()),
+ ($L_PAREN.getCharPositionInLine())
),
- ($player_choice_list.result)
+ ($identifier.result),
+ ($maybe_computation_list.result)
);
-
- CHOICE_LIMITED_VARIABLES.pop();
- }
-
- | IMP_DICT_TO_LIST_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_FROM_LIST_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_KEYS_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_VALUES_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_MERGE_KW
- dict0r=value_reference WS+
- dict1=non_text_value WS+
- fun=non_text_value WS*
- R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_MERGE_KW
- dict0r=value_reference WS+
- dict1=non_text_value WS+
- fun=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_FILTER_KW
- dict0r=value_reference WS+
- fun=non_text_value WS*
- R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_FILTER_KW
- dict0r=value_reference WS+
- fun=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_SET_KW
- key=value WS+
- val=value WS+
- dict0r=value_reference WS*
- R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_REMOVE_KW key=value WS+ dict0r=value_reference WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_HAS_KW
- key=value WS+
- dict0=non_text_value WS+
- value_reference WS*
- R_PAREN
- {
-
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_GET_KW
- key=value WS+
- dict0=non_text_value WS+
- value_reference WS*
- R_PAREN
- {
-
- /* TODO */
- $result = null;
- }
-
- | IMP_DICT_GET_POINTER_KW
- key=value WS+
- dict0=non_text_value WS+
- value_reference WS*
- R_PAREN
- {
-
- /* TODO */
- $result = null;
}
+/******************************************************************************/
+/**** DISPLAYED COMPUTATIONS **************************************************/
+/******************************************************************************/
| paragraph
{
$result =
@@ -2344,17 +952,10 @@ returns [Instruction 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);
- }
+ PARSER.handle_error(e);
}
-instr_cond_list
+instruction_cond_list
returns [List<Cons<Computation, Instruction>> result]
@init
{
@@ -2368,9 +969,9 @@ returns [List<Cons<Computation, Instruction>> result]
(
(
(
- (L_PAREN WS* non_text_value WS+)
+ (L_PAREN WS* computation WS+)
{
- condition = ($non_text_value.result);
+ condition = ($computation.result);
}
)
|
@@ -2380,9 +981,8 @@ returns [List<Cons<Computation, Instruction>> result]
condition =
VariableFromWord.generate
(
- WORLD,
- LOCAL_VARIABLES,
- CONTEXT.get_origin_at
+ PARSER,
+ PARSER.get_origin_at
(
($something_else.getLine()),
($something_else.getCharPositionInLine())
@@ -2392,22 +992,14 @@ returns [List<Cons<Computation, Instruction>> result]
}
)
)
- {
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- general_fate_instr
- {
- for (final String s: HIERARCHICAL_VARIABLES.pop())
- {
- LOCAL_VARIABLES.peekFirst().remove(s);
- }
- }
- WS* R_PAREN
{
- $result.add
- (
- new Cons(condition, ($general_fate_instr.result))
- );
+ PARSER.increase_local_variables_hierarchy();
+ }
+ instruction WS* R_PAREN
+ {
+ PARSER.decrease_local_variables_hierarchy();
+
+ $result.add(new Cons(condition, ($instruction.result)));
}
WS*
)+
@@ -2416,17 +1008,10 @@ returns [List<Cons<Computation, Instruction>> 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);
- }
+ PARSER.handle_error(e);
}
-instr_switch_list
+instruction_switch_list
returns [List<Cons<Computation, Instruction>> result]
@init
{
@@ -2434,22 +1019,17 @@ returns [List<Cons<Computation, Instruction>> result]
}
:
(
- L_PAREN WS* value WS+
+ L_PAREN WS* computation WS+
{
- HIERARCHICAL_VARIABLES.push(new ArrayList());
+ PARSER.increase_local_variables_hierarchy();
}
- general_fate_instr
- {
- for (final String s: HIERARCHICAL_VARIABLES.pop())
- {
- LOCAL_VARIABLES.peekFirst().remove(s);
- }
- }
- WS* R_PAREN
+ instruction WS* R_PAREN
{
+ PARSER.decrease_local_variables_hierarchy();
+
$result.add
(
- new Cons(($value.result), ($general_fate_instr.result))
+ new Cons(($value.result), ($instruction.result))
);
}
WS*
@@ -2458,7 +1038,25 @@ returns [List<Cons<Computation, Instruction>> result]
}
;
-player_choice_list
+player_choice_list returns [List<Instruction> result]
+@init
+{
+ $result = new ArrayList<Instruction>();
+}
+:
+ (
+ WS* player_choice
+ {
+ $result.add($player_choice.result);
+ }
+ )+
+;
+catch [final Throwable e]
+{
+ PARSER.handle_error(e);
+}
+
+maybe_player_choice_list
returns [List<Instruction> result]
@init
{
@@ -2477,136 +1075,105 @@ returns [List<Instruction> result]
player_choice
returns [Instruction result]
+/*
+ * Do not use a separate Local Variable stack for the player choice
+ * instructions.
+ */
:
TEXT_OPTION_KW
- L_PAREN WS* paragraph WS* R_PAREN WS+
- {
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- general_fate_sequence
+ L_PAREN WS* paragraph WS* R_PAREN WS*
{
- for (final String s: HIERARCHICAL_VARIABLES.pop())
- {
- LOCAL_VARIABLES.peekFirst().remove(s);
- }
+ PARSER.increase_local_variables_hierarchy();
}
- WS*
+ maybe_instruction_list WS*
R_PAREN
{
+ PARSER.decrease_local_variables_hierarchy();
+
$result =
new TextOption
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($TEXT_OPTION_KW.getLine()),
($TEXT_OPTION_KW.getCharPositionInLine())
),
($paragraph.result),
- ($general_fate_sequence.result)
+ ($maybe_instruction_list.result)
);
}
| EVENT_OPTION_KW
- L_PAREN WS* WORD WS* R_PAREN WS+
- {
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- general_fate_sequence
+ L_PAREN WS* WORD maybe_value_list WS* R_PAREN WS*
{
- for (final String s: HIERARCHICAL_VARIABLES.pop())
- {
- LOCAL_VARIABLES.peekFirst().remove(s);
- }
+ PARSER.increase_local_variables_hierarchy();
}
- WS*
+ maybe_instruction_list WS*
R_PAREN
{
final Origin origin;
final Event event;
+ PARSER.decrease_local_variables_hierarchy();
+
origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($L_PAREN.getLine()),
($L_PAREN.getCharPositionInLine())
);
- event = WORLD.events().get(origin, ($WORD.text));
+ event = PARSER.get_world().events().get(origin, ($WORD.text));
$result =
- new EventOption
+ EventOption.build
(
origin,
event,
- ($general_fate_sequence.result)
+ ($maybe_value_list.result),
+ ($maybe_instruction_list.result)
);
}
- | EVENT_OPTION_KW
- L_PAREN WS* WORD WS+ value_list WS* R_PAREN WS+
- {
- HIERARCHICAL_VARIABLES.push(new ArrayList());
- }
- general_fate_sequence
- {
- for (final String s: HIERARCHICAL_VARIABLES.pop())
- {
- LOCAL_VARIABLES.peekFirst().remove(s);
- }
- }
- WS*
- R_PAREN
+ | L_PAREN maybe_player_choice_list WS* R_PAREN
{
- final Origin origin;
- final Event event;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($L_PAREN.getLine()),
- ($L_PAREN.getCharPositionInLine())
- );
-
- event = WORLD.events().get(origin, ($WORD.text));
-
$result =
- EventOption.build
+ new InstructionList
(
- origin,
- event,
- ($value_list.result),
- ($general_fate_sequence.result)
+ PARSER.get_origin_at
+ (
+ ($L_PAREN.getLine()),
+ ($L_PAREN.getCharPositionInLine())
+ ),
+ ($maybe_player_choice_list.result)
);
}
- | IF_KW
- non_text_value WS+
- player_choice_list WS*
- R_PAREN
+ | IF_KW computation WS* player_choice_list WS* R_PAREN
{
$result =
IfInstruction.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($IF_KW.getLine()),
($IF_KW.getCharPositionInLine())
),
- ($non_text_value.result),
+ ($computation.result),
($player_choice_list.result)
);
}
| IF_ELSE_KW
- non_text_value WS+
- if_true=player_choice WS+
- if_false=player_choice WS*
- R_PAREN
+ computation WS*
+ if_true=player_choice WS*
+ if_false=player_choice WS*
+ R_PAREN
{
$result =
IfElseInstruction.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($IF_ELSE_KW.getLine()),
($IF_ELSE_KW.getCharPositionInLine())
@@ -2622,7 +1189,7 @@ returns [Instruction result]
$result =
CondInstruction.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($COND_KW.getLine()),
($COND_KW.getCharPositionInLine())
@@ -2631,12 +1198,16 @@ returns [Instruction result]
);
}
- | SWITCH_KW value WS* player_choice_switch_list WS+ player_choice WS* R_PAREN
+ | SWITCH_KW
+ computation WS*
+ player_choice_switch_list WS+
+ player_choice WS*
+ R_PAREN
{
$result =
SwitchInstruction.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($SWITCH_KW.getLine()),
($SWITCH_KW.getCharPositionInLine())
@@ -2648,28 +1219,28 @@ returns [Instruction result]
}
| FOR_KW
- l0=L_PAREN
- choice_for_variable_list WS*
- R_PAREN WS*
- non_text_value WS*
- l1=L_PAREN
- choice_for_update_variable_list WS*
- R_PAREN WS*
- player_choice_list
- WS* R_PAREN
+ l0=L_PAREN
+ choice_for_variable_list WS*
+ R_PAREN WS*
+ computation WS*
+ l1=L_PAREN
+ choice_for_update_variable_list WS*
+ R_PAREN WS*
+ player_choice_list WS*
+ R_PAREN
{
$result =
For.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($FOR_KW.getLine()),
($FOR_KW.getCharPositionInLine())
),
- ($non_text_value.result),
+ ($computation.result),
new InstructionList
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($l0.getLine()),
($l0.getCharPositionInLine())
@@ -2679,7 +1250,7 @@ returns [Instruction result]
($player_choice_list.result),
new InstructionList
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($l1.getLine()),
($l1.getCharPositionInLine())
@@ -2690,7 +1261,7 @@ returns [Instruction result]
}
| FOR_EACH_KW
- non_text_value WS+ new_reference_name
+ computation WS+ identifier
{
final Map<String, Variable> variable_map;
final Variable new_variable;
@@ -2711,7 +1282,7 @@ returns [Instruction result]
(
new InvalidTypeException
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($FOR_EACH_KW.getLine()),
($FOR_EACH_KW.getCharPositionInLine())
@@ -2724,47 +1295,30 @@ returns [Instruction result]
elem_type = Type.ANY;
}
-
new_variable =
new Variable
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($FOR_EACH_KW.getLine()),
($FOR_EACH_KW.getCharPositionInLine())
),
elem_type,
- ($new_reference_name.result),
+ ($identifier.result),
false
);
- variable_map = LOCAL_VARIABLES.peekFirst();
-
- if (variable_map.containsKey(($new_reference_name.result)))
- {
- ErrorManager.handle
- (
- new DuplicateLocalVariableException
- (
- variable_map.get(($new_reference_name.result)),
- new_variable
- )
- );
- }
- else
- {
- variable_map.put(($new_reference_name.result), new_variable);
- }
+ PARSER.add_context_variable(new_variable);
}
WS+
{
- HIERARCHICAL_VARIABLES.push(new ArrayList());
+ PARSER.get_hierarchical_variables().push(new ArrayList());
}
player_choice_list
{
- for (final String s: HIERARCHICAL_VARIABLES.pop())
+ for (final String s: PARSER.get_hierarchical_variables().pop())
{
- LOCAL_VARIABLES.peekFirst().remove(s);
+ PARSER.get_local_variables().peekFirst().remove(s);
}
}
WS*
@@ -2773,29 +1327,22 @@ returns [Instruction result]
$result =
new ForEach
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($FOR_EACH_KW.getLine()),
($FOR_EACH_KW.getCharPositionInLine())
),
($non_text_value.result),
- ($new_reference_name.result),
+ ($identifier.result),
($player_choice_list.result)
);
- variable_map.remove(($new_reference_name.result));
+ variable_map.remove(($identifier.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);
- }
+ PARSER.handle_error(e);
}
player_choice_cond_list
@@ -2812,9 +1359,9 @@ returns [List<Cons<Computation, Instruction>> result]
(
(
(
- (L_PAREN WS* non_text_value WS+)
+ (L_PAREN WS* computation WS+)
{
- condition = ($non_text_value.result);
+ condition = ($computation.result);
}
)
|
@@ -2824,9 +1371,8 @@ returns [List<Cons<Computation, Instruction>> result]
condition =
VariableFromWord.generate
(
- WORLD,
- LOCAL_VARIABLES,
- CONTEXT.get_origin_at
+ PARSER,
+ PARSER.get_origin_at
(
($something_else.getLine()),
($something_else.getCharPositionInLine())
@@ -2847,14 +1393,7 @@ returns [List<Cons<Computation, Instruction>> 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);
- }
+ PARSER.handle_error(e);
}
player_choice_switch_list
@@ -2865,9 +1404,9 @@ returns [List<Cons<Computation, Instruction>> result]
}
:
(
- L_PAREN WS* value WS+ player_choice WS* R_PAREN
+ L_PAREN WS* computation WS* player_choice WS* R_PAREN
{
- $result.add(new Cons(($value.result), ($player_choice.result)));
+ $result.add(new Cons(($computation.result), ($player_choice.result)));
}
WS*
)+
@@ -2876,14 +1415,7 @@ returns [List<Cons<Computation, Instruction>> 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);
- }
+ PARSER.handle_error(e);
}
paragraph
@@ -2893,222 +1425,18 @@ returns [TextNode result]
final List<TextNode> content = new ArrayList();
}
:
- first=text_value
- {
- content.add(($first.result));
- }
- (
- (WS+ next_a=text_value)
- {
- if (!(content.get(content.size() - 1) instanceof Newline))
- {
- content.add
- (
- ValueToText.build
- (
- Constant.build_string
- (
- $next_a.result.get_origin(),
- " "
- )
- )
- );
- }
-
- content.add(($next_a.result));
- }
- |
- (next_b=text_value)
- {
- content.add(($next_b.result));
- }
- )*
+ computation_list
{
- if (content.size() == 1)
- {
- $result = content.get(0);
- }
- else
- {
- $result =
- new Paragraph
- (
- ($first.result.get_origin()),
- content
- );
- }
+ // convert all computations to text.
+ // return text node.
+ return new Paragraph(computation_list.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);
- }
+ PARSER.handle_error(e);
}
-actual_text_value
-returns [TextNode result]:
- TEXT_KW paragraph WS* R_PAREN
- {
- $result = ($paragraph.result);
- }
-
- | JOIN_KW value WS+ non_text_value WS* R_PAREN
- {
- $result =
- TextJoin.build
- (
- CONTEXT.get_origin_at
- (
- ($JOIN_KW.getLine()),
- ($JOIN_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- ($value.result)
- );
- }
-
- | ENABLE_TEXT_EFFECT_KW WORD WS+ paragraph WS* R_PAREN
- {
- final TextEffect effect;
-
- effect =
- WORLD.text_effects().get
- (
- CONTEXT.get_origin_at
- (
- ($WORD.getLine()),
- ($WORD.getCharPositionInLine())
- ),
- ($WORD.text)
- );
-
- $result =
- TextWithEffect.build
- (
- CONTEXT.get_origin_at
- (
- ($WORD.getLine()),
- ($WORD.getCharPositionInLine())
- ),
- effect,
- new ArrayList<Computation>(),
- ($paragraph.result)
- );
- }
-
- | ENABLE_TEXT_EFFECT_KW
- L_PAREN
- WORD WS+
- value_list WS*
- R_PAREN WS+
- paragraph WS*
- R_PAREN
- {
- final TextEffect effect;
-
- effect =
- WORLD.text_effects().get
- (
- CONTEXT.get_origin_at
- (
- ($WORD.getLine()),
- ($WORD.getCharPositionInLine())
- ),
- ($WORD.text)
- );
-
- $result =
- TextWithEffect.build
- (
- CONTEXT.get_origin_at
- (
- ($ENABLE_TEXT_EFFECT_KW.getLine()),
- ($ENABLE_TEXT_EFFECT_KW.getCharPositionInLine())
- ),
- effect,
- ($value_list.result),
- ($paragraph.result)
- );
- }
-
- | NEWLINE_KW
- {
- $result =
- new Newline
- (
- CONTEXT.get_origin_at
- (
- ($NEWLINE_KW.getLine()),
- ($NEWLINE_KW.getCharPositionInLine())
- )
- );
- }
-;
-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);
- }
-}
-
-value_as_text
-returns [TextNode result]:
- sentence
- {
- $result = ValueToText.build(($sentence.result));
- }
-
- | non_text_value
- {
- $result = ValueToText.build(($non_text_value.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_value
-returns [TextNode result]:
- actual_text_value
- {
- $result = $actual_text_value.result;
- }
-
- | value_as_text
- {
- $result = $value_as_text.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);
- }
-}
sentence
returns [Computation result]
@init
@@ -3116,12 +1444,6 @@ returns [Computation result]
final StringBuilder string_builder = new StringBuilder();
}
:
- STRING_KW sentence WS* R_PAREN
- {
- $result = ($sentence.result);
- }
-
- |
first_word=WORD
{
string_builder.append(($first_word.text));
@@ -3137,7 +1459,7 @@ returns [Computation result]
$result =
Constant.build_string
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($first_word.getLine()),
($first_word.getCharPositionInLine())
@@ -3148,14 +1470,7 @@ returns [Computation 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);
- }
+ PARSER.handle_error(e);
}
type
@@ -3164,9 +1479,9 @@ returns [Type result]
WORD
{
$result =
- WORLD.types().get
+ PARSER.get_world().types().get
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($WORD.getLine()),
($WORD.getCharPositionInLine())
@@ -3175,162 +1490,27 @@ returns [Type result]
);
}
- | REF_KW type WS* R_PAREN
- {
- final Origin start_origin;
-
- start_origin =
- CONTEXT.get_origin_at
- (
- ($REF_KW.getLine()),
- ($REF_KW.getCharPositionInLine())
- );
-
- $result =
- new PointerType
- (
- start_origin,
- ($type.result),
- ("anonymous (" + ($type.result).get_name() + ") ref type")
- );
- }
-
- | DICT_KW key_type=type WS+ val_type=type WS* R_PAREN
+ | L_PAREN identifier WS+ type_list WS* R_PAREN
{
- final Origin start_origin;
+ final Type t;
- start_origin =
- CONTEXT.get_origin_at
- (
- ($DICT_KW.getLine()),
- ($DICT_KW.getCharPositionInLine())
- );
-
- $result =
- DictionaryType.build
+ t =
+ PARSER.get_world().types().get
(
- start_origin,
- ($key_type.result),
- ($val_type.result),
+ PARSER.get_origin_at
(
- "anonymous ("
- + ($key_type.result)
- + " "
- + $val_type.result
- + ") dictionary type"
- )
- );
- }
-
- | SET_KW type WS* R_PAREN
- {
- final Origin start_origin;
-
- start_origin =
- CONTEXT.get_origin_at
- (
- ($SET_KW.getLine()),
- ($SET_KW.getCharPositionInLine())
- );
-
- $result =
- CollectionType.build
- (
- start_origin,
- ($type.result),
- true,
- ("anonymous (" + ($type.result).get_name() + ") set type")
- );
- }
-
- | LIST_KW type WS* R_PAREN
- {
- final Origin start_origin;
-
- start_origin =
- CONTEXT.get_origin_at
- (
- ($LIST_KW.getLine()),
- ($LIST_KW.getCharPositionInLine())
- );
-
- $result =
- CollectionType.build
- (
- start_origin,
- ($type.result),
- false,
- ("anonymous (" + ($type.result).get_name() + ") list type")
- );
- }
-
- | CONS_KW t0=type WS+ t1=type WS* R_PAREN
- {
- $result =
- new ConsType
- (
- CONTEXT.get_origin_at
- (
- ($CONS_KW.getLine()),
- ($CONS_KW.getCharPositionInLine())
+ ($WORD.getLine()),
+ ($WORD.getCharPositionInLine())
),
- ($t0.result),
- ($t1.result),
- ("anonymous (" + ($type.result).get_name() + ") list type")
- );
- }
-
- | LAMBDA_KW type WS* L_PAREN WS* type_list WS* R_PAREN WS* R_PAREN
- {
- final Origin start_origin;
-
- start_origin =
- CONTEXT.get_origin_at
- (
- ($LAMBDA_KW.getLine()),
- ($LAMBDA_KW.getCharPositionInLine())
- );
-
- $result =
- new LambdaType
- (
- start_origin,
- ($type.result),
- "auto_generated",
- ($type_list.result)
- );
- }
-
- | SEQUENCE_KW type_list WS* R_PAREN
- {
- final Origin start_origin;
-
- start_origin =
- CONTEXT.get_origin_at
- (
- ($SEQUENCE_KW.getLine()),
- ($SEQUENCE_KW.getCharPositionInLine())
+ ($WORD.text)
);
- $result =
- new SequenceType
- (
- start_origin,
- "auto_generated",
- ($type_list.result)
- );
+ $result = t.build(type_list);
}
;
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);
- }
+ PARSER.handle_error(e);
}
type_list
@@ -3340,12 +1520,27 @@ returns [List<Type> result]
$result = new ArrayList<Type>();
}
:
- (
+ type
+ {
+ $result.add(($type.result));
+ }
+ (WS+
type
{
$result.add(($type.result));
}
- )?
+ )*
+ {
+ }
+;
+
+maybe_type_list
+returns [List<Type> result]
+@init
+{
+ $result = new ArrayList<Type>();
+}
+:
(WS+
type
{
@@ -3364,10 +1559,6 @@ returns [List<Cons<Variable, Computation>> result]
var_name = null;
- Map<String, Variable> variables;
-
- variables = LOCAL_VARIABLES.peekFirst();
-
$result = new ArrayList<Cons<Variable, Computation>>();
}
:
@@ -3375,9 +1566,9 @@ returns [List<Cons<Variable, Computation>> result]
WS*
(
(
- L_PAREN WS* new_reference_name
+ L_PAREN WS* identifier
{
- var_name = ($new_reference_name.result);
+ var_name = ($identifier.result);
}
)
|
@@ -3395,7 +1586,7 @@ returns [List<Cons<Variable, Computation>> result]
v =
new Variable
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($L_PAREN.getLine()),
($L_PAREN.getCharPositionInLine())
@@ -3405,7 +1596,7 @@ returns [List<Cons<Variable, Computation>> result]
false
);
- if (variables.containsKey(var_name))
+ if (PARSER.current_context_variable_level_has(var_name))
{
ErrorManager.handle
(
@@ -3417,7 +1608,7 @@ returns [List<Cons<Variable, Computation>> result]
);
}
- variables.put(var_name, v);
+ PARSER.add_context_variable(v);
$result.add(new Cons(v, ($value.result)));
}
@@ -3427,14 +1618,7 @@ returns [List<Cons<Variable, Computation>> 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);
- }
+ PARSER.handle_error(e);
}
choice_for_update_variable_list
@@ -3445,7 +1629,7 @@ returns [List<Instruction> result]
String var_name;
Origin origin;
- allowed_variables = CHOICE_LIMITED_VARIABLES.peek();
+ allowed_variables = PARSER.get_choice_limited_variables().peek();
var_name = null;
origin = null;
@@ -3456,11 +1640,11 @@ returns [List<Instruction> result]
WS*
(
(
- L_PAREN WS* new_reference_name
+ L_PAREN WS* identifier
{
- var_name = ($new_reference_name.result);
+ var_name = ($identifier.result);
origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($L_PAREN.getLine()),
($L_PAREN.getCharPositionInLine())
@@ -3473,7 +1657,7 @@ returns [List<Instruction> result]
{
var_name = ($something_else.text).substring(1).trim();
origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($something_else.getLine()),
($something_else.getCharPositionInLine())
@@ -3481,18 +1665,17 @@ returns [List<Instruction> result]
}
)
)
- WS+ value WS* R_PAREN
+ WS+ computation WS* R_PAREN
{
$result.add
(
SetValue.build
(
origin,
- ($value.result),
+ ($computation.result),
VariableFromWord.generate
(
- WORLD,
- LOCAL_VARIABLES,
+ PARSER,
origin,
var_name
)
@@ -3513,14 +1696,7 @@ returns [List<Instruction> 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);
- }
+ PARSER.handle_error(e);
}
choice_for_variable_list
@@ -3531,7 +1707,7 @@ returns [List<Instruction> result]
String var_name;
Origin origin;
- allowed_variables = CHOICE_LIMITED_VARIABLES.peek();
+ allowed_variables = PARSER.get_choice_limited_variables().peek();
var_name = null;
origin = null;
@@ -3542,11 +1718,11 @@ returns [List<Instruction> result]
WS*
(
(
- L_PAREN WS* new_reference_name
+ L_PAREN WS* identifier
{
- var_name = ($new_reference_name.result);
+ var_name = ($identifier.result);
origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($L_PAREN.getLine()),
($L_PAREN.getCharPositionInLine())
@@ -3559,7 +1735,7 @@ returns [List<Instruction> result]
{
var_name = ($something_else.text).substring(1).trim();
origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($something_else.getLine()),
($something_else.getCharPositionInLine())
@@ -3567,21 +1743,15 @@ returns [List<Instruction> result]
}
)
)
- WS+ value WS* R_PAREN
+ WS+ computation WS* R_PAREN
{
$result.add
(
SetValue.build
(
origin,
- ($value.result),
- VariableFromWord.generate
- (
- WORLD,
- LOCAL_VARIABLES,
- origin,
- var_name
- )
+ ($computation.result),
+ VariableFromWord.generate(PARSER, origin, var_name)
)
);
@@ -3593,14 +1763,7 @@ returns [List<Instruction> 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);
- }
+ PARSER.handle_error(e);
}
variable_list
@@ -3625,7 +1788,7 @@ returns [VariableList result]
)
{
origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($L_PAREN.getLine()),
($L_PAREN.getCharPositionInLine())
@@ -3638,14 +1801,14 @@ returns [VariableList result]
something_else=.
{
origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($something_else.getLine()),
($something_else.getCharPositionInLine())
);
next_type =
- WORLD.types().get
+ PARSER.get_world().types().get
(
origin,
($something_else.text).substring(1).trim()
@@ -3653,7 +1816,7 @@ returns [VariableList result]
}
)
)
- WS* new_reference_name WS* R_PAREN
+ WS* identifier WS* R_PAREN
{
$result.add
(
@@ -3661,7 +1824,7 @@ returns [VariableList result]
(
origin,
next_type,
- ($new_reference_name.result),
+ ($identifier.result),
false
)
);
@@ -3669,18 +1832,10 @@ returns [VariableList 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);
- }
+ PARSER.handle_error(e);
}
field_value_list
@@ -3711,22 +1866,18 @@ returns [List<Cons<Origin, Cons<String, Computation>>> result]
}
)
)
- value WS* R_PAREN
+ computation WS* R_PAREN
{
$result.add
(
new Cons
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($L_PAREN.getLine()),
($L_PAREN.getCharPositionInLine())
),
- new Cons
- (
- field_name,
- ($value.result)
- )
+ new Cons(field_name, ($computation.result))
)
);
}
@@ -3735,7 +1886,7 @@ returns [List<Cons<Origin, Cons<String, Computation>>> result]
}
;
-new_reference_name
+identifier
returns [String result]
:
WORD
@@ -3746,7 +1897,7 @@ returns [String result]
(
new IllegalReferenceNameException
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($WORD.getLine()),
($WORD.getCharPositionInLine())
@@ -3761,472 +1912,26 @@ returns [String 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);
- }
+ PARSER.handle_error(e);
}
/******************************************************************************/
/**** VALUES ******************************************************************/
/******************************************************************************/
-boolean_expression
-returns [Computation result]:
- TRUE_KW
- {
- $result =
- Constant.build_boolean
- (
- CONTEXT.get_origin_at
- (
- ($TRUE_KW.getLine()),
- ($TRUE_KW.getCharPositionInLine())
- ),
- true
- );
- }
- | FALSE_KW
- {
- $result =
- Constant.build_boolean
- (
- CONTEXT.get_origin_at
- (
- ($FALSE_KW.getLine()),
- ($FALSE_KW.getCharPositionInLine())
- ),
- false
- );
- }
-
- | AND_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($AND_KW.getLine()),
- ($AND_KW.getCharPositionInLine())
- ),
- Operator.AND,
- ($non_text_value_list.result)
- );
- }
-
- | OR_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($OR_KW.getLine()),
- ($OR_KW.getCharPositionInLine())
- ),
- Operator.OR,
- ($non_text_value_list.result)
- );
- }
-
- | ONE_IN_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($ONE_IN_KW.getLine()),
- ($ONE_IN_KW.getCharPositionInLine())
- ),
- Operator.ONE_IN,
- ($non_text_value_list.result)
- );
- }
-
- | NOT_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($NOT_KW.getLine()),
- ($NOT_KW.getCharPositionInLine())
- ),
- Operator.NOT,
- ($non_text_value_list.result)
- );
- }
-
- | IMPLIES_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($IMPLIES_KW.getLine()),
- ($IMPLIES_KW.getCharPositionInLine())
- ),
- Operator.IMPLIES,
- ($non_text_value_list.result)
- );
- }
-
- | LOWER_THAN_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($LOWER_THAN_KW.getLine()),
- ($LOWER_THAN_KW.getCharPositionInLine())
- ),
- Operator.LOWER_THAN,
- ($non_text_value_list.result)
- );
- }
-
- | LOWER_EQUAL_THAN_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($LOWER_EQUAL_THAN_KW.getLine()),
- ($LOWER_EQUAL_THAN_KW.getCharPositionInLine())
- ),
- Operator.LOWER_EQUAL_THAN,
- ($non_text_value_list.result)
- );
- }
-
- | EQUALS_KW value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($EQUALS_KW.getLine()),
- ($EQUALS_KW.getCharPositionInLine())
- ),
- Operator.EQUALS,
- ($value_list.result)
- );
- }
-
- | GREATER_EQUAL_THAN_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($GREATER_EQUAL_THAN_KW.getLine()),
- ($GREATER_EQUAL_THAN_KW.getCharPositionInLine())
- ),
- Operator.GREATER_EQUAL_THAN,
- ($non_text_value_list.result)
- );
- }
-
- | GREATER_THAN_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($GREATER_THAN_KW.getLine()),
- ($GREATER_THAN_KW.getCharPositionInLine())
- ),
- Operator.GREATER_THAN,
- ($non_text_value_list.result)
- );
- }
-
- | IS_MEMBER_KW value WS+ value_reference WS* R_PAREN
- {
- $result =
- IsMemberOperator.build
- (
- CONTEXT.get_origin_at
- (
- ($IS_MEMBER_KW.getLine()),
- ($IS_MEMBER_KW.getCharPositionInLine())
- ),
- ($value.result),
- ($value_reference.result)
- );
- }
-
- | IS_EMPTY_KW value_reference WS* R_PAREN
- {
- $result =
- IsEmpty.build
- (
- CONTEXT.get_origin_at
- (
- ($IS_EMPTY_KW.getLine()),
- ($IS_EMPTY_KW.getCharPositionInLine())
- ),
- ($value_reference.result)
- );
- }
-
- | INDEX_OF_KW value WS+ value_reference WS* R_PAREN
- {
- $result =
- IndexOfOperator.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEX_OF_KW.getLine()),
- ($INDEX_OF_KW.getCharPositionInLine())
- ),
- ($value.result),
- ($value_reference.result)
- );
- }
-
- | SIZE_KW value_reference WS* R_PAREN
- {
- $result =
- SizeOperator.build
- (
- CONTEXT.get_origin_at
- (
- ($SIZE_KW.getLine()),
- ($SIZE_KW.getCharPositionInLine())
- ),
- ($value_reference.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);
- }
-}
-
-math_expression
-returns [Computation result]:
- PLUS_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($PLUS_KW.getLine()),
- ($PLUS_KW.getCharPositionInLine())
- ),
- Operator.PLUS,
- ($non_text_value_list.result)
- );
- }
-
- | MINUS_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($MINUS_KW.getLine()),
- ($MINUS_KW.getCharPositionInLine())
- ),
- Operator.MINUS,
- ($non_text_value_list.result)
- );
- }
-
- | MIN_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($MIN_KW.getLine()),
- ($MIN_KW.getCharPositionInLine())
- ),
- Operator.MIN,
- ($non_text_value_list.result)
- );
- }
-
- | MAX_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($MAX_KW.getLine()),
- ($MAX_KW.getCharPositionInLine())
- ),
- Operator.MAX,
- ($non_text_value_list.result)
- );
- }
-
- | CLAMP_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($CLAMP_KW.getLine()),
- ($CLAMP_KW.getCharPositionInLine())
- ),
- Operator.CLAMP,
- ($non_text_value_list.result)
- );
- }
-
- | ABS_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($ABS_KW.getLine()),
- ($ABS_KW.getCharPositionInLine())
- ),
- Operator.ABS,
- ($non_text_value_list.result)
- );
- }
-
- | MODULO_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($MODULO_KW.getLine()),
- ($MODULO_KW.getCharPositionInLine())
- ),
- Operator.MODULO,
- ($non_text_value_list.result)
- );
- }
-
- | TIMES_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($TIMES_KW.getLine()),
- ($TIMES_KW.getCharPositionInLine())
- ),
- Operator.TIMES,
- ($non_text_value_list.result)
- );
- }
-
- | DIVIDE_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($DIVIDE_KW.getLine()),
- ($DIVIDE_KW.getCharPositionInLine())
- ),
- Operator.DIVIDE,
- ($non_text_value_list.result)
- );
- }
-
- | POWER_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($POWER_KW.getLine()),
- ($POWER_KW.getCharPositionInLine())
- ),
- Operator.POWER,
- ($non_text_value_list.result)
- );
- }
-
- | RANDOM_KW non_text_value_list WS* R_PAREN
- {
- $result =
- Operation.build
- (
- CONTEXT.get_origin_at
- (
- ($RANDOM_KW.getLine()),
- ($RANDOM_KW.getCharPositionInLine())
- ),
- Operator.RANDOM,
- ($non_text_value_list.result)
- );
- }
-
- | COUNT_KW value WS+ non_text_value WS* R_PAREN
- {
- $result =
- CountOperator.build
- (
- CONTEXT.get_origin_at
- (
- ($COUNT_KW.getLine()),
- ($COUNT_KW.getCharPositionInLine())
- ),
- ($value.result),
- ($non_text_value.result)
- );
- }
-;
-catch [final Throwable e]
+computation
+returns [Computation result]
+@init
{
- if ((e.getMessage() == null) || !e.getMessage().startsWith("Require"))
- {
- throw new ParseCancellationException(CONTEXT.toString() + ((e.getMessage() == null) ? "" : e.getMessage()), e);
- }
- else
- {
- throw new ParseCancellationException(e);
- }
+ Parser.LocalVariables previous_local_variables_stack;
}
-
-value
-returns [Computation result]
:
WORD
{
$result =
- Constant.build
+ AmbiguousWord.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($WORD.getLine()),
($WORD.getCharPositionInLine())
@@ -4235,9 +1940,9 @@ returns [Computation result]
);
}
- | IGNORE_ERROR_KW WORD WS+ value WS* R_PAREN
+ | IGNORE_ERROR_KW WORD WS+ computation WS* R_PAREN
{
- $result = ($value.result);
+ $result = ($computation.result);
/* TODO: temporarily disable an compiler error category */
}
@@ -4251,344 +1956,27 @@ returns [Computation result]
$result = ($sentence.result);
}
- | actual_text_value
- {
- $result = ($actual_text_value.result);
- }
-
- | non_text_value
- {
- $result = ($non_text_value.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);
- }
-}
-
-non_text_value
-returns [Computation result]
-:
- STRING_KW sentence WS* R_PAREN
- {
- $result = $sentence.result;
- }
-
- | IF_ELSE_KW cond=non_text_value WS+
- if_true=value WS+
- if_false=value WS*
- R_PAREN
- {
- $result =
- IfElseValue.build
- (
- CONTEXT.get_origin_at
- (
- ($IF_ELSE_KW.getLine()),
- ($IF_ELSE_KW.getCharPositionInLine())
- ),
- ($cond.result),
- ($if_true.result),
- ($if_false.result)
- );
- }
-
- | CONS_KW v0=value WS+ v1=value WS* R_PAREN
- {
- $result =
- new ConsComputation
- (
- CONTEXT.get_origin_at
- (
- ($CONS_KW.getLine()),
- ($CONS_KW.getCharPositionInLine())
- ),
- ($v0.result),
- ($v1.result)
- );
- }
-
- | CAR_KW non_text_value WS* R_PAREN
- {
- $result =
- CarCdr.build
- (
- CONTEXT.get_origin_at
- (
- ($CAR_KW.getLine()),
- ($CAR_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- true
- );
- }
-
- | CDR_KW non_text_value WS* R_PAREN
- {
- $result =
- CarCdr.build
- (
- CONTEXT.get_origin_at
- (
- ($CDR_KW.getLine()),
- ($CDR_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- false
- );
- }
-
- | ACCESS_KW index=non_text_value WS+ collection=non_text_value WS* R_PAREN
- {
- $result =
- Access.build
- (
- CONTEXT.get_origin_at
- (
- ($ACCESS_KW.getLine()),
- ($ACCESS_KW.getCharPositionInLine())
- ),
- ($collection.result),
- ($index.result)
- );
- }
-
- | ACCESS_POINTER_KW non_text_value WS+ value_reference WS* R_PAREN
- {
- $result =
- AccessPointer.build
- (
- CONTEXT.get_origin_at
- (
- ($ACCESS_POINTER_KW.getLine()),
- ($ACCESS_POINTER_KW.getCharPositionInLine())
- ),
- ($value_reference.result),
- ($non_text_value.result)
- );
- }
-
- | FIELD_ACCESS_KW WORD WS+ non_text_value WS* R_PAREN
+ | FIELD_ACCESS_KW WORD WS+ computation WS* R_PAREN
{
$result =
FieldAccess.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($FIELD_ACCESS_KW.getLine()),
($FIELD_ACCESS_KW.getCharPositionInLine())
),
- ($non_text_value.result),
+ ($computation.result),
($WORD.text)
);
}
- | FOLDL_KW
- fun=non_text_value WS+
- init=value WS+
- inr=non_text_value WS*
- R_PAREN
- {
- $result =
- Fold.build
- (
- CONTEXT.get_origin_at
- (
- ($FOLDL_KW.getLine()),
- ($FOLDL_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($init.result),
- ($inr.result),
- true,
- new ArrayList()
- );
- }
-
- | FOLDL_KW
- fun=non_text_value WS+
- init=value WS+
- inr=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- Fold.build
- (
- CONTEXT.get_origin_at
- (
- ($FOLDL_KW.getLine()),
- ($FOLDL_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($init.result),
- ($inr.result),
- true,
- ($value_list.result)
- );
- }
-
- | FOLDR_KW
- fun=non_text_value WS+
- init=value WS+
- inr=non_text_value WS*
- R_PAREN
- {
- $result =
- Fold.build
- (
- CONTEXT.get_origin_at
- (
- ($FOLDR_KW.getLine()),
- ($FOLDR_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($init.result),
- ($inr.result),
- false,
- new ArrayList()
- );
- }
-
- | FOLDR_KW
- fun=non_text_value WS+
- init=value WS+
- inr=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- Fold.build
- (
- CONTEXT.get_origin_at
- (
- ($FOLDR_KW.getLine()),
- ($FOLDR_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($init.result),
- ($inr.result),
- false,
- ($value_list.result)
- );
- }
-
- | LIST_KW value_list WS* R_PAREN
- {
- final Origin origin;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($LIST_KW.getLine()),
- ($LIST_KW.getCharPositionInLine())
- );
-
- if ($value_list.result.size() == 0)
- {
- ErrorManager.handle(new InvalidArityException(origin, 0, 1, -1));
- }
-
-
- $result =
- new Default
- (
- origin,
- CollectionType.build
- (
- origin,
- ($value_list.result).get(0).get_type(),
- false,
- "Autogenerated List Type"
- )
- );
-
- for (final Computation val: $value_list.result)
- {
- $result =
- AddElementComputation.build
- (
- origin,
- val,
- $result
- );
- }
- }
-
- | SET_KW value_list WS* R_PAREN
- {
- final Origin origin;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($SET_KW.getLine()),
- ($SET_KW.getCharPositionInLine())
- );
-
- if ($value_list.result.size() == 0)
- {
- ErrorManager.handle(new InvalidArityException(origin, 0, 1, -1));
- }
-
- $result =
- new Default
- (
- origin,
- CollectionType.build
- (
- origin,
- ($value_list.result).get(0).get_type(),
- true,
- "Autogenerated Set Type"
- )
- );
-
- for (final Computation val: $value_list.result)
- {
- $result =
- AddElementComputation.build
- (
- origin,
- val,
- $result
- );
- }
- }
-
- | RANGE_KW
- vstart=non_text_value WS+
- vend=non_text_value WS+
- inc=non_text_value WS*
- R_PAREN
- {
- $result =
- Range.build
- (
- CONTEXT.get_origin_at
- (
- ($RANGE_KW.getLine()),
- ($RANGE_KW.getCharPositionInLine())
- ),
- ($vstart.result),
- ($vend.result),
- ($inc.result)
- );
- }
-
| DEFAULT_KW type WS* R_PAREN
{
$result =
new Default
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($DEFAULT_KW.getLine()),
($DEFAULT_KW.getCharPositionInLine())
@@ -4597,1225 +1985,129 @@ returns [Computation result]
);
}
- | COND_KW value_cond_list WS* R_PAREN
+ | COND_KW computation_cond_list WS* R_PAREN
{
$result =
CondValue.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($COND_KW.getLine()),
($COND_KW.getCharPositionInLine())
),
- ($value_cond_list.result)
+ ($computation_cond_list.result)
);
}
| SWITCH_KW
- target=value WS*
- value_switch_list WS*
- default_val=value WS*
+ target=computation WS*
+ computation_switch_list WS*
+ default_val=computation WS*
R_PAREN
{
$result =
SwitchValue.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($SWITCH_KW.getLine()),
($SWITCH_KW.getCharPositionInLine())
),
($target.result),
- ($value_switch_list.result),
+ ($computation_switch_list.result),
($default_val.result)
);
}
- | boolean_expression
- {
- $result = ($boolean_expression.result);
- }
-
| LAMBDA_KW
+ {
+ previous_local_variables_stack = PARSER.get_local_variables_stack();
+ PARSER.discard_local_variables_stack();
+ PARSER.increase_local_variables_hierarchy();
+ }
L_PAREN WS* variable_list WS* R_PAREN
{
- final Map<String, Variable> variable_map;
-
- variable_map = new HashMap<String, Variable>();
-
- variable_map.putAll(($variable_list.result).as_map());
-
- LOCAL_VARIABLES.push(variable_map);
+ PARSER.add_local_variables(($variable_lists.result).as_map());
}
WS*
- value
+ computation
WS*
R_PAREN
{
+ PARSER.restore_local_variables_stack(previous_local_variables_stack);
+
$result =
LambdaExpression.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($LAMBDA_KW.getLine()),
($LAMBDA_KW.getCharPositionInLine())
),
($variable_list.result).get_entries(),
- ($value.result)
+ ($computation.result)
);
-
- LOCAL_VARIABLES.pop();
}
| LET_KW
+ {
+ PARSER.increase_local_variables_hierarchy();
+ }
L_PAREN WS* let_variable_list WS* R_PAREN
WS*
- value
+ computation
WS*
R_PAREN
{
final List<Cons<Variable, Computation>> let_list;
+ PARSER.decrease_local_variables_hierarchy();
+
let_list = ($let_variable_list.result);
$result =
new Let
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($LET_KW.getLine()),
($LET_KW.getCharPositionInLine())
),
let_list,
- ($value.result)
+ ($computation.result)
);
-
- for (final Cons<Variable, Computation> entry: let_list)
- {
- LOCAL_VARIABLES.peekFirst().remove(entry.get_car().get_name());
- }
}
- | math_expression
- {
- $result = ($math_expression.result);
- }
-
- | REF_KW value_reference WS* R_PAREN
- {
- $result =
- new AddressOperator
- (
- CONTEXT.get_origin_at
- (
- ($REF_KW.getLine()),
- ($REF_KW.getCharPositionInLine())
- ),
- ($value_reference.result)
- );
- }
-
- | CAST_KW WORD WS+ value WS* R_PAREN
+ | CAST_KW type WS+ computation WS* R_PAREN
{
final Origin target_type_origin;
final Type target_type;
target_type_origin =
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($WORD.getLine()),
($WORD.getCharPositionInLine())
);
- target_type = WORLD.types().get(target_type_origin, ($WORD.text));
+ target_type =
+ PARSER.get_world().types().get(target_type_origin, ($WORD.text));
$result =
Cast.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($CAST_KW.getLine()),
($CAST_KW.getCharPositionInLine())
),
target_type,
- ($value.result),
- false
- );
- }
-
- | EXTRA_COMPUTATION_KW WORD WS+ value_list WS* R_PAREN
- {
- final Origin origin;
- final ExtraComputation extra_computation;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($WORD.getLine()),
- ($WORD.getCharPositionInLine())
- );
-
- extra_computation = WORLD.extra_computations().get(origin, ($WORD.text));
-
- $result =
- extra_computation.instantiate
- (
- WORLD,
- CONTEXT,
- origin,
- ($value_list.result)
- );
- }
-
- | EXTRA_COMPUTATION_KW WORD WS* R_PAREN
- {
- final Origin origin;
- final ExtraComputation extra_computation;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($WORD.getLine()),
- ($WORD.getCharPositionInLine())
- );
-
- extra_computation = WORLD.extra_computations().get(origin, ($WORD.text));
-
- $result =
- extra_computation.instantiate
- (
- WORLD,
- CONTEXT,
- origin,
- new ArrayList<Computation>()
- );
- }
-
- | SEQUENCE_KW WORD WS* R_PAREN
- {
- final SequenceReference sr;
- final Origin origin;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($SEQUENCE_KW.getLine()),
- ($SEQUENCE_KW.getCharPositionInLine())
- );
-
- sr = new SequenceReference(origin, ($WORD.text));
- $result = sr;
-
- WORLD.add_sequence_variable(sr);
- }
-
- | EVAL_KW value_reference WS* R_PAREN
- {
- final Origin origin;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($EVAL_KW.getLine()),
- ($EVAL_KW.getCharPositionInLine())
- );
-
- $result =
- LambdaEvaluation.build
- (
- origin,
- ($value_reference.result),
- new ArrayList()
- );
- }
-
- | EVAL_KW value_reference WS+ value_list WS* R_PAREN
- {
- final Origin origin;
-
- origin =
- CONTEXT.get_origin_at
- (
- ($EVAL_KW.getLine()),
- ($EVAL_KW.getCharPositionInLine())
- );
-
- $result =
- LambdaEvaluation.build
- (
- origin,
- ($value_reference.result),
- ($value_list.result)
- );
- }
-
- | ADD_KW vall=value_list WS+ coll=non_text_value WS* R_PAREN
- {
- $result = ($coll.result);
-
- for (final Computation value: ($vall.result))
- {
- $result =
- AddElementComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($ADD_KW.getLine()),
- ($ADD_KW.getCharPositionInLine())
- ),
- value,
- $result
- );
- }
- }
-
- | ADD_AT_KW
- index=non_text_value WS+
- element=value WS+
- coll=non_text_value WS*
- R_PAREN
- {
- $result =
- AddElementAtComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($ADD_AT_KW.getLine()),
- ($ADD_AT_KW.getCharPositionInLine())
- ),
- ($index.result),
- ($element.result),
- ($coll.result)
- );
- }
-
- | ADD_ALL_KW
- sourcev=non_text_value WS+
- targetv=non_text_value WS*
- R_PAREN
- {
- $result =
- AddElementsOfComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($ADD_ALL_KW.getLine()),
- ($ADD_ALL_KW.getCharPositionInLine())
- ),
- ($sourcev.result),
- ($targetv.result)
- );
- }
-
- | REMOVE_ONE_KW val=value WS+ coll=non_text_value WS* R_PAREN
- {
- $result =
- RemoveElementComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($REMOVE_ONE_KW.getLine()),
- ($REMOVE_ONE_KW.getCharPositionInLine())
- ),
- ($val.result),
- ($coll.result)
- );
- }
-
- | REMOVE_AT_KW val=value WS+ coll=non_text_value WS* R_PAREN
- {
- $result =
- RemoveElementAtComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($REMOVE_AT_KW.getLine()),
- ($REMOVE_AT_KW.getCharPositionInLine())
- ),
- ($val.result),
- ($coll.result)
- );
- }
-
- | REMOVE_ALL_KW val=value WS+ coll=non_text_value WS* R_PAREN
- {
- $result =
- RemoveAllOfElementComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($REMOVE_ALL_KW.getLine()),
- ($REMOVE_ALL_KW.getCharPositionInLine())
- ),
- ($val.result),
- ($coll.result)
- );
- }
-
- | REVERSE_KW non_text_value WS* R_PAREN
- {
- $result =
- ReverseListComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($REVERSE_KW.getLine()),
- ($REVERSE_KW.getCharPositionInLine())
- ),
- ($non_text_value.result)
- );
- }
-
- | PUSH_LEFT_KW val=value WS+ coll=non_text_value WS* R_PAREN
- {
- $result =
- PushElementComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($PUSH_LEFT_KW.getLine()),
- ($PUSH_LEFT_KW.getCharPositionInLine())
- ),
- ($val.result),
- ($coll.result),
- true
- );
- }
-
- | PUSH_RIGHT_KW val=value WS+ coll=non_text_value WS* R_PAREN
- {
- $result =
- PushElementComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($PUSH_RIGHT_KW.getLine()),
- ($PUSH_RIGHT_KW.getCharPositionInLine())
- ),
- ($val.result),
- ($coll.result),
- false
- );
- }
-
- | POP_LEFT_KW non_text_value WS* R_PAREN
- {
- $result =
- PopElementComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($POP_LEFT_KW.getLine()),
- ($POP_LEFT_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
- true
- );
- }
-
- | POP_RIGHT_KW non_text_value WS* R_PAREN
- {
- $result =
- PopElementComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($POP_RIGHT_KW.getLine()),
- ($POP_RIGHT_KW.getCharPositionInLine())
- ),
- ($non_text_value.result),
+ ($computation.result),
false
);
}
- | MAP_KW fun=non_text_value WS+ inv=non_text_value WS* R_PAREN
- {
- $result =
- tonkadur.fate.v1.lang.computation.MapComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($MAP_KW.getLine()),
- ($MAP_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv.result),
- new ArrayList()
- );
- }
-
- | MAP_KW fun=non_text_value WS+ inv=non_text_value WS+ value_list WS* R_PAREN
- {
- $result =
- tonkadur.fate.v1.lang.computation.MapComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($MAP_KW.getLine()),
- ($MAP_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv.result),
- ($value_list.result)
- );
- }
-
- | INDEXED_MAP_KW fun=non_text_value WS+ inv=non_text_value WS* R_PAREN
- {
- $result =
- IndexedMapComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEXED_MAP_KW.getLine()),
- ($INDEXED_MAP_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv.result),
- new ArrayList()
- );
- }
-
- | INDEXED_MAP_KW
- fun=non_text_value WS+
- inv=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedMapComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEXED_MAP_KW.getLine()),
- ($INDEXED_MAP_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv.result),
- ($value_list.result)
- );
- }
-
- | INDEXED_MERGE_TO_LIST_KW
- fun=non_text_value WS+
- inv0=non_text_value WS+
- inv1=non_text_value WS*
- R_PAREN
- {
- $result =
- IndexedMergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEXED_MERGE_TO_LIST_KW.getLine()),
- ($INDEXED_MERGE_TO_LIST_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- null,
- ($inv1.result),
- null,
- false,
- new ArrayList()
- );
- }
-
- | INDEXED_MERGE_TO_LIST_KW
- fun=non_text_value WS+
- inv0=non_text_value WS+
- inv1=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedMergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEXED_MERGE_TO_LIST_KW.getLine()),
- ($INDEXED_MERGE_TO_LIST_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- null,
- ($inv1.result),
- null,
- false,
- ($value_list.result)
- );
- }
-
- | SAFE_INDEXED_MERGE_TO_LIST_KW
- fun=non_text_value WS+
- def0=value WS+
- inv0=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS*
- R_PAREN
- {
- $result =
- IndexedMergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_INDEXED_MERGE_TO_LIST_KW.getLine()),
- ($SAFE_INDEXED_MERGE_TO_LIST_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- ($def0.result),
- ($inv1.result),
- ($def1.result),
- false,
- new ArrayList()
- );
- }
-
- | SAFE_INDEXED_MERGE_TO_LIST_KW
- fun=non_text_value WS+
- def0=value WS+
- inv0=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedMergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_INDEXED_MERGE_TO_LIST_KW.getLine()),
- ($SAFE_INDEXED_MERGE_TO_LIST_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- ($def0.result),
- ($inv1.result),
- ($def1.result),
- false,
- ($value_list.result)
- );
- }
-
- | MERGE_TO_LIST_KW
- fun=non_text_value WS+
- inv0=non_text_value WS+
- inv1=non_text_value WS*
- R_PAREN
- {
- $result =
- MergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($MERGE_TO_LIST_KW.getLine()),
- ($MERGE_TO_LIST_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- null,
- ($inv1.result),
- null,
- false,
- new ArrayList()
- );
- }
-
- | MERGE_TO_LIST_KW
- fun=non_text_value WS+
- inv0=non_text_value WS+
- inv1=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- MergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($MERGE_TO_LIST_KW.getLine()),
- ($MERGE_TO_LIST_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- null,
- ($inv1.result),
- null,
- false,
- ($value_list.result)
- );
- }
-
- | SAFE_MERGE_TO_LIST_KW
- fun=non_text_value WS+
- def0=value WS+
- inv0=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS*
- R_PAREN
- {
- $result =
- MergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_MERGE_TO_LIST_KW.getLine()),
- ($SAFE_MERGE_TO_LIST_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- ($def0.result),
- ($inv1.result),
- ($def1.result),
- false,
- new ArrayList()
- );
- }
-
- | SAFE_MERGE_TO_LIST_KW
- fun=non_text_value WS+
- def0=value WS+
- inv0=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- MergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_MERGE_TO_LIST_KW.getLine()),
- ($SAFE_MERGE_TO_LIST_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- ($def0.result),
- ($inv1.result),
- ($def1.result),
- false,
- ($value_list.result)
- );
- }
-
- | INDEXED_MERGE_TO_SET_KW
- fun=non_text_value WS+
- inv0=non_text_value WS+
- inv1=non_text_value WS*
- R_PAREN
- {
- $result =
- IndexedMergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEXED_MERGE_TO_SET_KW.getLine()),
- ($INDEXED_MERGE_TO_SET_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- null,
- ($inv1.result),
- null,
- true,
- new ArrayList()
- );
- }
-
- | INDEXED_MERGE_TO_SET_KW
- fun=non_text_value WS+
- inv0=non_text_value WS+
- inv1=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedMergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEXED_MERGE_TO_SET_KW.getLine()),
- ($INDEXED_MERGE_TO_SET_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- null,
- ($inv1.result),
- null,
- true,
- ($value_list.result)
- );
- }
-
- | SAFE_INDEXED_MERGE_TO_SET_KW
- fun=non_text_value WS+
- def0=value WS+
- inv0=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS*
- R_PAREN
- {
- $result =
- IndexedMergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_INDEXED_MERGE_TO_SET_KW.getLine()),
- ($SAFE_INDEXED_MERGE_TO_SET_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- ($def0.result),
- ($inv1.result),
- ($def1.result),
- true,
- new ArrayList()
- );
- }
-
- | SAFE_INDEXED_MERGE_TO_SET_KW
- fun=non_text_value WS+
- def0=value WS+
- inv0=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedMergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_INDEXED_MERGE_TO_SET_KW.getLine()),
- ($SAFE_INDEXED_MERGE_TO_SET_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- ($def0.result),
- ($inv1.result),
- ($def1.result),
- true,
- ($value_list.result)
- );
- }
-
- | MERGE_TO_SET_KW
- fun=non_text_value WS+
- inv0=non_text_value WS+
- inv1=non_text_value WS*
- R_PAREN
- {
- $result =
- MergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($MERGE_TO_SET_KW.getLine()),
- ($MERGE_TO_SET_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- null,
- ($inv1.result),
- null,
- true,
- new ArrayList()
- );
- }
-
- | MERGE_TO_SET_KW
- fun=non_text_value WS+
- inv0=non_text_value WS+
- inv1=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- MergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($MERGE_TO_SET_KW.getLine()),
- ($MERGE_TO_SET_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- null,
- ($inv1.result),
- null,
- true,
- ($value_list.result)
- );
- }
-
- | SAFE_MERGE_TO_SET_KW
- fun=non_text_value WS+
- def0=value WS+
- inv0=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS*
- R_PAREN
- {
- $result =
- MergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_MERGE_TO_SET_KW.getLine()),
- ($SAFE_MERGE_TO_SET_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- ($def0.result),
- ($inv1.result),
- ($def1.result),
- true,
- new ArrayList()
- );
- }
-
- | SAFE_MERGE_TO_SET_KW
- fun=non_text_value WS+
- def0=value WS+
- inv0=non_text_value WS+
- def1=value WS+
- inv1=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- MergeComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SAFE_MERGE_TO_SET_KW.getLine()),
- ($SAFE_MERGE_TO_SET_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($inv0.result),
- ($def0.result),
- ($inv1.result),
- ($def1.result),
- true,
- ($value_list.result)
- );
- }
-
- | SUB_LIST_KW
- vstart=non_text_value WS+
- vend=non_text_value WS+
- inv=non_text_value WS*
- R_PAREN
- {
- $result =
- SubListComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SUB_LIST_KW.getLine()),
- ($SUB_LIST_KW.getCharPositionInLine())
- ),
- ($vstart.result),
- ($vend.result),
- ($inv.result)
- );
- }
-
- | FILTER_KW fun=non_text_value WS+ coll=non_text_value WS* R_PAREN
- {
- $result =
- FilterComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($FILTER_KW.getLine()),
- ($FILTER_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($coll.result),
- new ArrayList()
- );
- }
-
- | FILTER_KW
- fun=non_text_value WS+
- coll=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- FilterComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($FILTER_KW.getLine()),
- ($FILTER_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($coll.result),
- ($value_list.result)
- );
- }
-
- | INDEXED_FILTER_KW fun=non_text_value WS+ coll=non_text_value WS* R_PAREN
- {
- $result =
- IndexedFilterComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEXED_FILTER_KW.getLine()),
- ($INDEXED_FILTER_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($coll.result),
- new ArrayList()
- );
- }
-
- | INDEXED_FILTER_KW
- fun=non_text_value WS+
- coll=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedFilterComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEXED_FILTER_KW.getLine()),
- ($INDEXED_FILTER_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($coll.result),
- ($value_list.result)
- );
- }
-
- | PARTITION_KW fun=non_text_value WS+ coll=non_text_value WS* R_PAREN
- {
- $result =
- PartitionComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($PARTITION_KW.getLine()),
- ($PARTITION_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($coll.result),
- new ArrayList()
- );
- }
-
- | PARTITION_KW
- fun=non_text_value WS+
- coll=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- PartitionComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($PARTITION_KW.getLine()),
- ($PARTITION_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($coll.result),
- ($value_list.result)
- );
- }
-
- | INDEXED_PARTITION_KW fun=non_text_value WS+ coll=non_text_value WS* R_PAREN
- {
- $result =
- IndexedPartitionComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEXED_PARTITION_KW.getLine()),
- ($INDEXED_PARTITION_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($coll.result),
- new ArrayList()
- );
- }
-
- | INDEXED_PARTITION_KW
- fun=non_text_value WS+
- coll=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- IndexedPartitionComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($INDEXED_PARTITION_KW.getLine()),
- ($INDEXED_PARTITION_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($coll.result),
- ($value_list.result)
- );
- }
-
- | SORT_KW fun=non_text_value WS+ coll=non_text_value WS* R_PAREN
- {
- $result =
- SortComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SORT_KW.getLine()),
- ($SORT_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($coll.result),
- new ArrayList()
- );
- }
-
- | SORT_KW
- fun=non_text_value WS+
- coll=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- $result =
- SortComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SORT_KW.getLine()),
- ($SORT_KW.getCharPositionInLine())
- ),
- ($fun.result),
- ($coll.result),
- ($value_list.result)
- );
- }
-
- | DICT_TO_LIST_KW non_text_value WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | DICT_FROM_LIST_KW non_text_value WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | DICT_KEYS_KW non_text_value WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | DICT_VALUES_KW non_text_value WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | DICT_MERGE_KW
- dict0=non_text_value WS+
- dict1=non_text_value WS+
- fun=non_text_value WS*
- R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | DICT_MERGE_KW
- dict0=non_text_value WS+
- dict1=non_text_value WS+
- fun=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | DICT_FILTER_KW
- dict0=non_text_value WS+
- fun=non_text_value WS*
- R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | DICT_FILTER_KW
- dict0=non_text_value WS+
- fun=non_text_value WS+
- value_list WS*
- R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | DICT_SET_KW key=value WS+ val=value WS+ dict0=non_text_value WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | DICT_REMOVE_KW key=value WS+ dict0=non_text_value WS* R_PAREN
- {
- /* TODO */
- $result = null;
- }
-
- | DICT_HAS_KW key=value WS+ dict0=non_text_value WS* R_PAREN
- {
-
- /* TODO */
- $result = null;
- }
-
- | DICT_GET_KW key=value WS+ dict0=non_text_value WS* R_PAREN
- {
-
- /* TODO */
- $result = null;
- }
-
- | DICT_GET_POINTER_KW key=value WS+ dict0=non_text_value WS* R_PAREN
- {
-
- /* TODO */
- $result = null;
- }
-
- | SHUFFLE_KW non_text_value WS* R_PAREN
- {
- $result =
- ShuffleComputation.build
- (
- CONTEXT.get_origin_at
- (
- ($SHUFFLE_KW.getLine()),
- ($SHUFFLE_KW.getCharPositionInLine())
- ),
- ($non_text_value.result)
- );
- }
-
- | SET_FIELDS_KW non_text_value WS* field_value_list WS* R_PAREN
+ | SET_FIELDS_KW computation WS* field_computation_list WS* R_PAREN
{
/*
* A bit of a lazy solution: build field references, then extract the data
@@ -5827,7 +2119,7 @@ returns [Computation result]
for
(
final Cons<Origin, Cons<String, Computation>> entry:
- ($field_value_list.result)
+ ($field_computation_list.result)
)
{
final FieldReference fr;
@@ -5837,7 +2129,7 @@ returns [Computation result]
FieldReference.build
(
entry.get_car(),
- ($non_text_value.result),
+ ($computation.result),
entry.get_cdr().get_car()
);
@@ -5851,24 +2143,24 @@ returns [Computation result]
$result =
new SetFieldsComputation
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($SET_FIELDS_KW.getLine()),
($SET_FIELDS_KW.getCharPositionInLine())
),
- ($non_text_value.result),
+ ($computation.result),
assignments
);
}
- | WORD
+ | ENABLE_TEXT_EFFECT_KW WORD WS+ paragraph WS* R_PAREN
{
- $result = null;
+ final TextEffect effect;
- $result =
- Constant.build_if_non_string
+ effect =
+ PARSER.get_world().text_effects().get
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
($WORD.getLine()),
($WORD.getCharPositionInLine())
@@ -5876,103 +2168,76 @@ returns [Computation result]
($WORD.text)
);
- if ($result == null)
- {
- $result =
- VariableFromWord.generate
+ $result =
+ TextWithEffect.build
+ (
+ PARSER.get_origin_at
(
- WORLD,
- LOCAL_VARIABLES,
- CONTEXT.get_origin_at
- (
- ($WORD.getLine()),
- ($WORD.getCharPositionInLine())
- ),
- ($WORD.text)
- );
- }
- }
-
- | value_reference
- {
- $result = ($value_reference.result);
+ ($WORD.getLine()),
+ ($WORD.getCharPositionInLine())
+ ),
+ effect,
+ new ArrayList<Computation>(),
+ ($paragraph.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
+ | ENABLE_TEXT_EFFECT_KW
+ L_PAREN
+ WORD WS+
+ value_list WS*
+ R_PAREN WS+
+ paragraph WS*
+ R_PAREN
{
- throw new ParseCancellationException(e);
- }
-}
+ final TextEffect effect;
-value_reference
-returns [Reference result]
-:
- AT_KW non_text_value WS* R_PAREN
- {
- $result =
- AtReference.build
+ effect =
+ PARSER.get_world().text_effects().get
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($AT_KW.getLine()),
- ($AT_KW.getCharPositionInLine())
+ ($WORD.getLine()),
+ ($WORD.getCharPositionInLine())
),
- ($non_text_value.result)
+ ($WORD.text)
);
- }
- | FIELD_KW WORD WS+ value_reference WS* R_PAREN
- {
$result =
- FieldReference.build
+ TextWithEffect.build
(
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($FIELD_KW.getLine()),
- ($FIELD_KW.getCharPositionInLine())
+ ($ENABLE_TEXT_EFFECT_KW.getLine()),
+ ($ENABLE_TEXT_EFFECT_KW.getCharPositionInLine())
),
- ($value_reference.result),
- ($WORD.text)
+ effect,
+ ($value_list.result),
+ ($paragraph.result)
);
}
-
- | (WORD | (VARIABLE_KW WORD WS* R_PAREN))
+ | L_PAREN identifier maybe_computation_list WS* R_PAREN
{
$result =
- VariableFromWord.generate
+ GenericComputation.build
(
- WORLD,
- LOCAL_VARIABLES,
- CONTEXT.get_origin_at
+ PARSER.get_origin_at
(
- ($WORD.getLine()),
- ($WORD.getCharPositionInLine())
+ ($L_PAREN.getLine()),
+ ($L_PAREN.getCharPositionInLine())
),
- ($WORD.text)
+ ($identifier.result),
+ ($maybe_computation_list.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);
- }
+ PARSER.handle_error(e);
}
-value_cond_list
+computation_cond_list
returns [List<Cons<Computation, Computation>> result]
@init
{
@@ -5987,7 +2252,7 @@ returns [List<Cons<Computation, Computation>> result]
(
(
(
- L_PAREN WS* c=non_text_value WS+
+ L_PAREN WS* c=computation WS+
)
{
condition = ($c.result);
@@ -6000,9 +2265,8 @@ returns [List<Cons<Computation, Computation>> result]
condition =
VariableFromWord.generate
(
- WORLD,
- LOCAL_VARIABLES,
- CONTEXT.get_origin_at
+ PARSER,
+ PARSER.get_origin_at
(
($something_else.getLine()),
($something_else.getCharPositionInLine())
@@ -6012,7 +2276,7 @@ returns [List<Cons<Computation, Computation>> result]
}
)
)
- v=value WS* R_PAREN WS*
+ v=computation WS* R_PAREN WS*
{
$result.add(new Cons(condition, ($v.result)));
}
@@ -6022,17 +2286,10 @@ returns [List<Cons<Computation, Computation>> 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);
- }
+ PARSER.handle_error(e);
}
-value_switch_list
+computation_switch_list
returns [List<Cons<Computation, Computation>> result]
@init
{
@@ -6040,7 +2297,7 @@ returns [List<Cons<Computation, Computation>> result]
}
:
(
- L_PAREN WS* c=value WS+ v=value WS* R_PAREN WS*
+ L_PAREN WS* c=computation WS+ v=computation WS* R_PAREN WS*
{
$result.add(new Cons(($c.result), ($v.result)));
}
@@ -6049,30 +2306,7 @@ returns [List<Cons<Computation, Computation>> result]
}
;
-value_list
-returns [List<Computation> result]
-@init
-{
- $result = new ArrayList<Computation>();
-}
-:
- (
- value
- {
- ($result).add(($value.result));
- }
- )*
- (WS+
- value
- {
- ($result).add(($value.result));
- }
- )*
- {
- }
-;
-
-non_text_value_list
+maybe_computation_list
returns [List<Computation> result]
@init
{
@@ -6080,15 +2314,15 @@ returns [List<Computation> result]
}
:
(
- non_text_value
+ computation
{
- ($result).add(($non_text_value.result));
+ ($result).add(($computation.result));
}
)*
(WS+
- non_text_value
+ computation
{
- ($result).add(($non_text_value.result));
+ ($result).add(($computation.result));
}
)*
{
diff --git a/src/core/src/tonkadur/fate/v1/parser/Parser.java b/src/core/src/tonkadur/fate/v1/parser/Parser.java
new file mode 100644
index 0000000..d746fb5
--- /dev/null
+++ b/src/core/src/tonkadur/fate/v1/parser/Parser.java
@@ -0,0 +1,229 @@
+package tonkadur.fate.v1.parser;
+
+import java.io.IOException;
+
+import java.util.Collection;
+import java.util.Deque;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.antlr.v4.runtime.CharStreams;
+import org.antlr.v4.runtime.CommonTokenStream;
+
+import tonkadur.parser.Context;
+import tonkadur.parser.Origin;
+
+import tonkadur.fate.v1.lang.Variable;
+import tonkadur.fate.v1.lang.World;
+
+public class Parser
+{
+ final World world;
+ final Context context;
+
+ LocalVariables local_variables;
+
+ int breakable_levels;
+ int continue_levels;
+
+ public Parser (final World world)
+ {
+ this.world = world;
+
+ local_variables = new LocalVariables();
+
+ breakable_levels = 0;
+ continue_levels = 0;
+
+ context = new Context();
+ }
+
+ public Origin get_origin_at (final int line, final int column)
+ {
+ return context.get_origin_at(line, column);
+ }
+
+ public World get_world ()
+ {
+ return world;
+ }
+
+ public Context get_context ()
+ {
+ return context;
+ }
+
+ /**** BREAKABLE LEVELS *****************************************************/
+ public boolean can_use_break ()
+ {
+ return (breakable_levels > 0);
+ }
+
+ public void increment_breakable_levels ()
+ {
+ breakable_levels++;
+ }
+
+ public void decrement_breakable_levels ()
+ {
+ breakable_levels--;
+ }
+
+ /**** CONTINUE LEVELS ******************************************************/
+ public boolean can_use_continue ()
+ {
+ return (continue_levels > 0);
+ }
+
+ public void increment_continue_levels ()
+ {
+ continue_levels++;
+ }
+
+ public void decrement_continue_levels ()
+ {
+ continue_levels--;
+ }
+
+ /**** LOCAL VARIABLES ******************************************************/
+ public Variable maybe_get_local_variable (final String name)
+ {
+ for (final Map<String, Variable> level: context_variables)
+ {
+ final Variable v;
+
+ v = level.get(name);
+
+ if (v != null)
+ {
+ return v;
+ }
+ }
+
+ return null;
+ }
+
+ public void add_local_variables (final Map<String, Variable> collection)
+ throws Trowable
+ {
+ for (final Variable variable: collection.values())
+ {
+ add_local_variable(variable);
+ }
+ }
+
+ public void add_local_variable (final Variable variable)
+ throws Trowable
+ {
+ final Map<String, Variable> current_hierarchy = local_variables.peek();
+ final Variable previous_entry;
+
+ previous_entry = current_hierarchy.get(variable.get_name());
+
+ if (previous_entry != null)
+ {
+ ErrorManager.handle
+ (
+ new DuplicateLocalVariableException
+ (
+ previous_entry,
+ variable
+ )
+ );
+ }
+
+ current_hierarchy.put(variable.get_name(), variable);
+ }
+
+ public void increase_local_variables_hierarchy ()
+ {
+ local_variables.push(new HashMap<String, Variable>());
+ }
+
+ public void decrease_local_variables_hierarchy ()
+ {
+ local_variables.pop();
+ }
+
+ /* I don't think it's needed ATM. */
+ public Collection<Variable> get_local_variables_at_current_hierarchy ()
+ {
+ return local_variables.peek().values();
+ }
+
+ public LocalVariables get_local_variables_stack ()
+ {
+ return local_variables;
+ }
+
+ public void restore_local_variables_stack
+ (
+ final LocalVariables local_variables
+ )
+ {
+ this.local_variables = local_variables;
+ }
+
+ public void discard_local_variables_stack ()
+ {
+ local_variables = new LocalVariables();
+ }
+
+ /**** ERROR HANDLING *******************************************************/
+ public void handle_error (final Throwable e)
+ {
+ if ((e.getMessage() == null) || !e.getMessage().startsWith("Require"))
+ {
+ kthrow
+ new ParseCancellationException
+ (
+ (
+ context.toString()
+ + ((e.getMessage() == null) ? "" : e.getMessage())
+ ),
+ e
+ );
+ }
+ else
+ {
+ throw new ParseCancellationException(e);
+ }
+ }
+
+ public void add_file_content (final Origin origin, final String filename)
+ throws IOException
+ {
+ final CommonTokenStream tokens;
+ final TinyFateLexer lexer;
+ final TinyFateParser parser;
+
+ lexer = new TinyFateLexer(CharStreams.fromFileName(filename));
+ tokens = new CommonTokenStream(lexer);
+ parser = new TinyFateParser(tokens);
+
+ if (origin != null)
+ {
+ context.push(origin);
+ }
+
+ parser.fate_file(this);
+
+ if (origin != null)
+ {
+ context.pop();
+ }
+
+ world.add_loaded_file(filename);
+
+ if (parser.getNumberOfSyntaxErrors() > 0)
+ {
+ throw new IOException("There were syntaxic errors in " + filename);
+ }
+ }
+
+ public static class LocalVariables extends Deque<Map<String, Variable>>
+ {
+ }
+}
diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java
index 405d32a..0936e19 100644
--- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java
+++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java
@@ -472,37 +472,6 @@ implements tonkadur.fate.v1.lang.meta.ComputationVisitor
}
@Override
- public void visit_field_reference
- (
- final tonkadur.fate.v1.lang.computation.FieldReference n
- )
- throws Throwable
- {
- final ComputationCompiler n_cc;
-
- n_cc = new ComputationCompiler(compiler);
-
- n.get_parent().get_visited_by(n_cc);
-
- assimilate(n_cc);
-
- result_as_address =
- new RelativeAddress
- (
- n_cc.get_address(),
- new Constant(Type.STRING, n.get_field_name()),
- TypeCompiler.compile
- (
- compiler,
- (
- (tonkadur.fate.v1.lang.type.StructType)
- n.get_parent().get_type()
- ).get_field_type(null, n.get_field_name())
- )
- );
- }
-
- @Override
public void visit_field_access
(
final tonkadur.fate.v1.lang.computation.FieldAccess n