summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-07-22 09:57:10 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-07-22 09:57:10 +0200
commit699516de3c51829f32ee48efc956076a9c6bb585 (patch)
tree545a3ec7bade993d169924f7d341425c45a9bf40
parent7bd910917ac2e9ad6b6db9a1fff5a890ac149b52 (diff)
Let's use imacro/vmacro instead.
-rw-r--r--data/examples/monster_battle/in_your_room.fate4
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateLexer.g43
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateParser.g474
3 files changed, 20 insertions, 61 deletions
diff --git a/data/examples/monster_battle/in_your_room.fate b/data/examples/monster_battle/in_your_room.fate
index 8f30a00..892c680 100644
--- a/data/examples/monster_battle/in_your_room.fate
+++ b/data/examples/monster_battle/in_your_room.fate
@@ -52,7 +52,7 @@
Oh! You found something!
)
)
- (macro get_item (ref (var potion)))
+ (imacro get_item (ref (var potion)))
)
(text_effect narrator
No, you don't find anything.
@@ -70,7 +70,7 @@
(text_effect narrator
It's a monster-holder! There's a note, too.
)
- (macro generate_random_creature (var player.creature))
+ (imacro generate_random_creature (var player.creature))
(event pause)
(text_effect note_reading
Hey sleepyhead. I couldn't wake you up for your big day, but lucky you,
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
index 0dfa292..3288598 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
@@ -50,7 +50,8 @@ INCLUDE_KW: L_PAREN 'include' SEP+;
IS_MEMBER_KW: L_PAREN ('is_member'|'contains') SEP+;
LOWER_EQUAL_THAN_KW: L_PAREN ('lower_equal_than'|'=<'|'<='|'le') SEP+;
LOWER_THAN_KW: L_PAREN ('lower_than'|'<'|'lt') SEP+;
-MACRO_KW: L_PAREN 'macro' SEP+;
+IMACRO_KW: L_PAREN 'imacro' SEP+;
+VMACRO_KW: L_PAREN 'vmacro' SEP+;
MINUS_KW: L_PAREN ('minus'|'-') SEP+;
NEWLINE_KW: L_PAREN 'newline)';
NOT_KW: L_PAREN ('not'|'~'|'!') SEP+;
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
index 2875ad1..2a08b9e 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
@@ -558,33 +558,6 @@ catch [final Throwable e]
general_fate_instr
returns [InstructionNode result]
:
-
- just_a_paragraph
- {
- $result = ($just_a_paragraph.result);
- }
-
- | actual_general_fate_instr
- {
- $result = ($actual_general_fate_instr.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);
- }
-}
-
-
-actual_general_fate_instr
-returns [InstructionNode result]
-:
L_PAREN WS+ general_fate_sequence WS* R_PAREN
{
$result =
@@ -758,7 +731,7 @@ returns [InstructionNode result]
);
}
- | MACRO_KW WORD WS+ value_list WS* R_PAREN
+ | IMACRO_KW WORD WS+ value_list WS* R_PAREN
{
final Origin origin;
final Macro macro;
@@ -766,8 +739,8 @@ returns [InstructionNode result]
origin =
CONTEXT.get_origin_at
(
- ($MACRO_KW.getLine()),
- ($MACRO_KW.getCharPositionInLine())
+ ($IMACRO_KW.getLine()),
+ ($IMACRO_KW.getCharPositionInLine())
);
macro = WORLD.macros().get(origin, ($WORD.text));
@@ -910,6 +883,16 @@ returns [InstructionNode result]
);
}
}
+
+ | paragraph
+ {
+ $result =
+ new Display
+ (
+ ($paragraph.result.get_origin()),
+ ($paragraph.result)
+ );
+ }
;
catch [final Throwable e]
{
@@ -1970,7 +1953,7 @@ returns [ValueNode result]
}
}
- | MACRO_KW WORD WS+ value_list WS* R_PAREN
+ | VMACRO_KW WORD WS+ value_list WS* R_PAREN
{
final Origin origin;
final Macro macro;
@@ -1978,8 +1961,8 @@ returns [ValueNode result]
origin =
CONTEXT.get_origin_at
(
- ($MACRO_KW.getLine()),
- ($MACRO_KW.getCharPositionInLine())
+ ($VMACRO_KW.getLine()),
+ ($VMACRO_KW.getCharPositionInLine())
);
macro = WORLD.macros().get(origin, ($WORD.text));
@@ -2251,28 +2234,3 @@ returns [List<ValueNode> result]
{
}
;
-
-just_a_paragraph
-returns [InstructionNode result]
-:
- paragraph
- {
- $result =
- new Display
- (
- ($paragraph.result.get_origin()),
- ($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
- {
- throw new ParseCancellationException(e);
- }
-}