summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2020-09-07 10:34:31 +0200
committernsensfel <SpamShield0@noot-noot.org>2020-09-07 10:34:31 +0200
commite7e5ec29417559a155c6f79e1bbeed77a9fe1ff3 (patch)
tree088cb618845f00a5eee0642a6571b4f0ef8ea42c
parent07c0f271e1f30fdc87da9ef122781c83ff410f64 (diff)
Adds syntax for https://github.com/nsensfel/tonkadur/issues/11
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateLexer.g418
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateParser.g4147
2 files changed, 162 insertions, 3 deletions
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
index 03014ac..3ac7851 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
@@ -23,9 +23,12 @@ AND_KW: L_PAREN ('and'|'/\\') SEP+;
ASSERT_KW: L_PAREN 'assert' SEP+;
AT_KW: L_PAREN 'at' SEP+;
BREAK_KW: L_PAREN 'break)';
+CAR_KW: L_PAREN 'car' SEP+;
CAST_KW: L_PAREN 'cast' SEP+;
+CDR_KW: L_PAREN 'cdr' SEP+;
CLEAR_KW: L_PAREN 'clear' SEP+;
COND_KW: L_PAREN 'cond' SEP+;
+CONS_KW: L_PAREN 'cons' SEP+;
COUNT_KW: L_PAREN 'count' SEP+;
DECLARE_ALIAS_TYPE_KW:
L_PAREN ((('declare'|'define'|'def')US(('sub'|'alias')US)?'type')|'typedef') SEP+;
@@ -49,8 +52,11 @@ FALSE_KW: L_PAREN 'false)';
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+;
+FILTER_KW: L_PAREN '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+;
@@ -59,6 +65,7 @@ IF_KW: L_PAREN 'if' SEP+;
IMPLIES_KW: L_PAREN ('implies'|'=>'|'->') 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+;
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+;
@@ -66,20 +73,28 @@ LOWER_THAN_KW: L_PAREN ('lower'US'than'|'<'|'lt') SEP+;
LET_KW: L_PAREN 'let' SEP+;
MINUS_KW: L_PAREN ('minus'|'-') SEP+;
MIN_KW: L_PAREN ('min'('imum'?)) SEP+;
+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_KW : L_PAREN 'merge' SEP+;
NEWLINE_KW: L_PAREN 'newline)';
NEW_KW: L_PAREN ('new'|'reserve'|'create') SEP+;
NOT_KW: L_PAREN ('not'|'~'|'!') SEP+;
ONE_IN_KW: L_PAREN ('exactly'US)?'one'(US'in')? SEP+;
OR_KW: L_PAREN ('or'|'\\/') SEP+;
RICH_TEXT_KW: L_PAREN (('rich'US)?'text') SEP+;
+PARTITION_KW: L_PAREN 'partition' SEP+;
+POP_LEFT: L_PAREN 'pop'US'left' SEP+;
+POP_RIGHT: L_PAREN 'pop'US'right' SEP+;
+PUSH_LEFT: L_PAREN 'push'US'left' SEP+;
+PUSH_RIGHT: L_PAREN 'push'US'right' SEP+;
PLAYER_CHOICE_KW: L_PAREN ('choice'|'user'US'choice'|'player'US'choice') 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')?)|('address'(US'of'))) SEP+;
REMOVE_ALL_KW: L_PAREN 'remove'US'all' SEP+;
@@ -90,8 +105,11 @@ 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+;
+SORT_KW: L_PAREN 'sort' SEP+;
SET_FIELDS_KW: L_PAREN 'set'US'fields' SEP+;
SET_KW: L_PAREN 'set'(US(('val''ue'?)|('var''iable'?)))? SEP+;
+SUB_LIST_KW: L_PAREN 'sub'US'list' SEP+;
LIST_KW: L_PAREN 'list' SEP+;
SIZE_KW: L_PAREN 'size' SEP+;
SWITCH_KW: L_PAREN 'switch' SEP+;
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
index 4cf3f8f..b84313e 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
@@ -25,7 +25,8 @@ options
import tonkadur.parser.Location;
import tonkadur.parser.Origin;
- import tonkadur.fate.v1.Utils;
+/* Conflicts with an existing package */
+/* import tonkadur.fate.v1.tonkadur.fate.v1.Utils; */
import tonkadur.fate.v1.error.DuplicateLocalVariableException;
import tonkadur.fate.v1.error.IllegalReferenceNameException;
@@ -376,7 +377,7 @@ first_level_fate_instr:
filename
);
- Utils.add_file_content(filename, CONTEXT, WORLD);
+ tonkadur.fate.v1.Utils.add_file_content(filename, CONTEXT, WORLD);
CONTEXT.pop();
}
@@ -398,7 +399,7 @@ first_level_fate_instr:
filename
);
- Utils.add_file_content(filename, CONTEXT, WORLD);
+ tonkadur.fate.v1.Utils.add_file_content(filename, CONTEXT, WORLD);
CONTEXT.pop();
}
@@ -707,6 +708,118 @@ returns [Instruction result]
);
}
+ | MAP_KW value WS+ inr=value_reference WS+ outr=value_reference WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | INDEXED_MAP_KW value WS+ inr=value_reference WS+ outr=value_reference WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | FOLDL_KW fun=value WS+ init=value WS+ inr=value_reference WS+ outv=value WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | FOLDR_KW fun=value WS+ init=value WS+ inr=value_reference WS+ outv=value WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | MERGE_KW
+ fun=value WS+
+ init=value WS+
+ inr0=value_reference WS+
+ inr1=value_reference WS+
+ outr=value_reference WS*
+ R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | MERGE_KW
+ fun=value WS+
+ init=value WS+
+ def0=value WS+
+ inr0=value_reference WS+
+ def1=value WS+
+ inr1=value_reference WS+
+ outr=value_reference WS*
+ R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | SUB_LIST_KW
+ start=value WS+
+ end=value WS+
+ inr=value_reference WS+
+ outr=value_reference WS*
+ R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | FILTER_KW value WS+ value_reference WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | PARTITION_KW
+ value WS+
+ iftrue=value_reference WS+
+ iffalse=value_reference WS*
+ R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | SORT_KW value WS+ value_reference WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | RANGE_KW
+ start=value WS+
+ end=value WS+
+ inc=value WS+
+ value_reference WS*
+ R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | SHUFFLE_KW value_reference WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
| SET_KW value_reference WS+ value WS* R_PAREN
{
$result =
@@ -1853,6 +1966,13 @@ returns [Type result]
);
}
+ | CONS_KW t0=type WS+ t1=type WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
| LAMBDA_KW type WS* L_PAREN WS* type_list WS* R_PAREN WS* R_PAREN
{
final Origin start_origin;
@@ -2692,6 +2812,27 @@ returns [Computation result]
);
}
+ | CONS_KW v0=value WS+ t1=value WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | CAR_KW value WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
+ | CDR_KW value WS* R_PAREN
+ {
+ /* TODO */
+
+ $result = null;
+ }
+
| COND_KW value_cond_list WS* R_PAREN
{
$result =