| summaryrefslogtreecommitdiff | 
diff options
30 files changed, 572 insertions, 325 deletions
| diff --git a/data/examples/monster_battle/battle.fate b/data/examples/monster_battle/battle.fate new file mode 100644 index 0000000..cfdce39 --- /dev/null +++ b/data/examples/monster_battle/battle.fate @@ -0,0 +1,5 @@ +(fate_version 1) + +(define_sequence start_battle +   nothing yet +) diff --git a/data/examples/monster_battle/in_your_room.fate b/data/examples/monster_battle/in_your_room.fate new file mode 100644 index 0000000..8f30a00 --- /dev/null +++ b/data/examples/monster_battle/in_your_room.fate @@ -0,0 +1,92 @@ +(fate_version 1) + +(require include/creatures.fate) +(require include/events.fate) +(require include/items.fate) +(require include/player.fate) +(require include/progress.fate) +(require include/text_effects.fate) + +(require battle.fate) + +(define_sequence in_your_room +   (ifelse +      (is_member visited_your_room progress) +      (text_effect narrator +         You room is still a mess. You don't have time to clean things up, +         though. +      ) +      (text_effect narrator +         You room is a mess. You recall having been through every drawer while +         preparing your bag yesterday. While still unclear on how you are +         supposed to pack all the necessary things for what promises to be at +         least a year-long journey inside a small backpack, you cannot avoid +         but wasting more time contemplating the piles of items that didn't +         make the cut. +      ) +   ) +   (add visited_your_room progress) +   (player_choice +      ( +         ( Look for healing items ) +         (sequence look_for_healing_items) +      ) +      ( +         ( No time! Let's go adventuring! ) +         (sequence leave_your_room) +      ) +   ) +) + +(define_sequence look_for_healing_items +   (text_effect narrator +      You anxiously alternate between looking at the clock and looking at piles +      of mess for healing items. +      (newline) +   ) +   (ifelse +      (=< (rand 0 99) 25) +      ( +         (text_effect surprise +            (text_effect narrator +               Oh! You found something! +            ) +         ) +         (macro get_item (ref (var potion))) +      ) +      (text_effect narrator +         No, you don't find anything. +      ) +   ) +   (sequence in_your_room) +) + +(define_sequence leave_your_room +   (text_effect narrator +      As you rush through the door of your room, you fail to notice the obstacle +      in your path and trip on something that was clearly meant for you. +   ) +   (event pause) +   (text_effect narrator +      It's a monster-holder! There's a note, too. +   ) +   (macro 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, +      someone noticed that you weren't going to make it in time and got this for +      you. +      (newline) +      Looks like it's a (variable player.creature.name). Good for you! My first +      creature may not have been as powerful, but I wouldn't trade it for +      anything. +      (newline) +      Now go! Aand don't come back until you've achieved your dreams! +   ) +   (text_effect narrator +      Teary eyed, you pick up the monster-holder and leave your house. And +      immediately get challenged by some grinning kid who clearly knew you +      haven't had time to train and wants to score an easy victory. +   ) +   (sequence start_battle) +) diff --git a/data/examples/monster_battle/include/attacks.fate b/data/examples/monster_battle/include/attacks.fate new file mode 100644 index 0000000..8104727 --- /dev/null +++ b/data/examples/monster_battle/include/attacks.fate @@ -0,0 +1,3 @@ +(fate_version 1) + +(require types/attack.fate) diff --git a/data/examples/monster_battle/include/creatures.fate b/data/examples/monster_battle/include/creatures.fate new file mode 100644 index 0000000..2ce30c9 --- /dev/null +++ b/data/examples/monster_battle/include/creatures.fate @@ -0,0 +1,30 @@ +(fate_version 1) + +(require types/creature.fate) + +(declare_variable creature monster_0) +(declare_variable creature monster_1) +(declare_variable creature monster_2) +(declare_variable creature monster_3) +(declare_variable creature monster_4) +(declare_variable creature monster_5) + +(declare_variable int i) + +(define_macro generate_random_creature +   ( +      (creature creature) +   ) + +   (set i (rand 0 5)) +   (set (param creature) +      (cond +         ((= (var i) 0) (var monster_0)) +         ((= (var i) 1) (var monster_1)) +         ((= (var i) 2) (var monster_2)) +         ((= (var i) 3) (var monster_3)) +         ((= (var i) 4) (var monster_4)) +         ((= (var i) 5) (var monster_5)) +      ) +   ) +) diff --git a/data/examples/monster_battle/include/events.fate b/data/examples/monster_battle/include/events.fate new file mode 100644 index 0000000..3749427 --- /dev/null +++ b/data/examples/monster_battle/include/events.fate @@ -0,0 +1,3 @@ +(fate_version 1) + +(declare_event_type pause) diff --git a/data/examples/monster_battle/include/items.fate b/data/examples/monster_battle/include/items.fate new file mode 100644 index 0000000..3ddca93 --- /dev/null +++ b/data/examples/monster_battle/include/items.fate @@ -0,0 +1,13 @@ +(fate_version 1) + +(require types/item.fate) +(require player.fate) + +(declare_variable item potion) + +(define_macro get_item +   ( +      (item_ptr item) +   ) +   (add (param item) player.inventory) +) diff --git a/data/examples/monster_battle/include/player.fate b/data/examples/monster_battle/include/player.fate new file mode 100644 index 0000000..18e46dc --- /dev/null +++ b/data/examples/monster_battle/include/player.fate @@ -0,0 +1,5 @@ +(fate_version 1) + +(require types/player.fate) + +(define_variable player player) diff --git a/data/examples/monster_battle/include/progress.fate b/data/examples/monster_battle/include/progress.fate new file mode 100644 index 0000000..ee08320 --- /dev/null +++ b/data/examples/monster_battle/include/progress.fate @@ -0,0 +1,5 @@ +(fate_version 1) + +(require types/tag.fate) + +(define_variable tag_collection progress) diff --git a/data/examples/monster_battle/include/text_effects.fate b/data/examples/monster_battle/include/text_effects.fate new file mode 100644 index 0000000..22ed582 --- /dev/null +++ b/data/examples/monster_battle/include/text_effects.fate @@ -0,0 +1,5 @@ +(fate_version 1) + +(declare_text_effect narrator) +(declare_text_effect note_reading) +(declare_text_effect surprise) diff --git a/data/examples/monster_battle/include/types/attack.fate b/data/examples/monster_battle/include/types/attack.fate new file mode 100644 index 0000000..da273ad --- /dev/null +++ b/data/examples/monster_battle/include/types/attack.fate @@ -0,0 +1,11 @@ +(fate_version 1) + +(require element.fate) + +(declare_dict_type attack +   (string name) +   (element_ptr element) +   (int power) +) + +(declare_ref_type attack attack_ptr) diff --git a/data/examples/monster_battle/include/types/creature.fate b/data/examples/monster_battle/include/types/creature.fate new file mode 100644 index 0000000..ad7c957 --- /dev/null +++ b/data/examples/monster_battle/include/types/creature.fate @@ -0,0 +1,17 @@ +(fate_version 1) + +(require element.fate) +(require attack.fate) + +(declare_dict_type creature +   (string name) +   (int current_health) +   (int max_health) +   (element_ptr element) +   (attack_ptr attack_0) +   (attack_ptr attack_1) +   (attack_ptr attack_2) +   (attack_ptr attack_3) +) + +(declare_ref_type creature creature_ptr) diff --git a/data/examples/monster_battle/include/types/element.fate b/data/examples/monster_battle/include/types/element.fate new file mode 100644 index 0000000..7500b16 --- /dev/null +++ b/data/examples/monster_battle/include/types/element.fate @@ -0,0 +1,13 @@ +(fate_version 1) + +(declare_subtype string element_name) + +(declare_set_type element_name element_name_set) + +(declare_dict_type element +   (element_name name) +   (element_name_set strong_against) +   (element_name_set weak_against) +) + +(declare_ref_type element element_ptr) diff --git a/data/examples/monster_battle/include/types/item.fate b/data/examples/monster_battle/include/types/item.fate new file mode 100644 index 0000000..0b50475 --- /dev/null +++ b/data/examples/monster_battle/include/types/item.fate @@ -0,0 +1,9 @@ +(fate_version 1) + +(declare_dict_type item +   (string name) +   (int price) +) + +(declare_ref_type item item_ptr) +(declare_list_type item_ptr item_ptr_list) diff --git a/data/examples/monster_battle/include/types/player.fate b/data/examples/monster_battle/include/types/player.fate new file mode 100644 index 0000000..2573c38 --- /dev/null +++ b/data/examples/monster_battle/include/types/player.fate @@ -0,0 +1,10 @@ +(fate_version 1) + +(require item.fate) +(require creature.fate) + +(define_dict_type player +   (creature creature) +   (item_ptr_list inventory) +   (int money) +) diff --git a/data/examples/monster_battle/include/types/tag.fate b/data/examples/monster_battle/include/types/tag.fate new file mode 100644 index 0000000..8cca7fe --- /dev/null +++ b/data/examples/monster_battle/include/types/tag.fate @@ -0,0 +1,5 @@ +(fate_version 1) + +(define_subtype string tag) + +(define_set_type tag tag_collection) diff --git a/data/examples/monster_battle/main.fate b/data/examples/monster_battle/main.fate new file mode 100644 index 0000000..e77e734 --- /dev/null +++ b/data/examples/monster_battle/main.fate @@ -0,0 +1,25 @@ +(fate_version 1) + +(require include/events.fate) +(require include/text_effects.fate) + +(require in_your_room.fate) + +(text_effect narrator +   After failing to sleep because of the anticipation, you overslept. +   Today was supposed to be glorious! At long last, you were going on your +   life-defining adventure with a powerful companion. +) +(event pause) +(text_effect narrator +   ... +) +(event pause) +(text_effect narrator +   Maybe you should stop daydreaming and see what can be salvaged at this point. +) +(event pause) +(text_effect narrator +   You stand in your room, having just dressed. +) +(sequence in_your_room) diff --git a/data/examples/the_thief/include/chapters.fate b/data/examples/the_thief/include/chapters.fate deleted file mode 100644 index d7beb18..0000000 --- a/data/examples/the_thief/include/chapters.fate +++ /dev/null @@ -1,2 +0,0 @@ -(fate_version 1) - diff --git a/data/examples/the_thief/include/characters.fate b/data/examples/the_thief/include/characters.fate deleted file mode 100644 index 0bdd797..0000000 --- a/data/examples/the_thief/include/characters.fate +++ /dev/null @@ -1,57 +0,0 @@ -(fate_version 1) - -(require type/character.fate) - -(declare_variable local character oscar) -(declare_variable character carla) -(declare_variable local character simon) -(declare_variable character julie) -(declare_variable local character statue) - -(require include/locations.fate) - -(set_fields oscar - -   (name Oscar) -   (agility 50) -   (perception 50) -   (money 20) -) -(add (ref oscar) room0.occupants) - -(set_fields carla - -   (name Carla) -   (agility 75) -   (perception 35) -   (money 7) -) -(add (ref carla) room1.occupants) - -(set_fields simon - -   (name Simon) -   (agility 35) -   (perception 75) -   (money 80) -) -(add (ref simon) room2.occupants) - -(set_fields julie - -   (name Julie) -   (agility 60) -   (perception 60) -   (money 90) -) -(add (ref julie) corridor.occupants) - - -(set_fields statue - -   (name ( A oddly human shaped statue, with clothes adorned )) -   (agility 0) -   (perception 0) -   (money 30) -) -(add (ref statue) corridor.occupants) diff --git a/data/examples/the_thief/include/locations.fate b/data/examples/the_thief/include/locations.fate deleted file mode 100644 index e46c504..0000000 --- a/data/examples/the_thief/include/locations.fate +++ /dev/null @@ -1,41 +0,0 @@ -(fate_version 1) - -(require type/location.fate) - -(declare_variable local location room0) -(declare_variable local location room1) -(declare_variable local location room2) -(declare_variable local location corridor) - -(set_fields room0 -   (name ( Room 0 )) -   (description -      ( An luxurious bedroom, well lit. ) -   ) -   (luminosity 80) -) - -(set_fields room1 -   (name ( Room 1 )) -   (description -      ( An overly large kitchen, unevenly lit. ) -   ) -   (luminosity 35) -) - -(set_fields room2 -   (name ( Room 2 )) -   (description -      ( An tiny and messy study, unlit. ) -   ) -   (luminosity 0) -) - -(set_fields corridor -   (name Corridor) -   (description -      ( A long corridor, with many decorations, and many hiding places. ) -   ) -   (luminosity 50) -) - diff --git a/data/examples/the_thief/include/text_effects.fate b/data/examples/the_thief/include/text_effects.fate deleted file mode 100644 index c8cdd7e..0000000 --- a/data/examples/the_thief/include/text_effects.fate +++ /dev/null @@ -1,3 +0,0 @@ -(fate_version 1) - -(declare_text_effect narrator) diff --git a/data/examples/the_thief/include/type/character.fate b/data/examples/the_thief/include/type/character.fate deleted file mode 100644 index 6278ad9..0000000 --- a/data/examples/the_thief/include/type/character.fate +++ /dev/null @@ -1,12 +0,0 @@ -(fate_version 1) - -(require stat.fate) - -(declare_dict_type character -   (string name) -   (stat agility) -   (stat perception) -   (int money) -) - -(declare_ref_type character character_ptr) diff --git a/data/examples/the_thief/include/type/location.fate b/data/examples/the_thief/include/type/location.fate deleted file mode 100644 index 9db494f..0000000 --- a/data/examples/the_thief/include/type/location.fate +++ /dev/null @@ -1,15 +0,0 @@ -(fate_version 1) - -(require character.fate) - -(declare_set_type character_ptr occupants) -(declare_subtype int luminosity) - -(declare_dict_type location -   (string name) -   (string description) -   (luminosity luminosity) -   (occupants occupants) -) - -(declare_ref_type location location_ptr) diff --git a/data/examples/the_thief/include/type/stat.fate b/data/examples/the_thief/include/type/stat.fate deleted file mode 100644 index c2e0feb..0000000 --- a/data/examples/the_thief/include/type/stat.fate +++ /dev/null @@ -1,3 +0,0 @@ -(fate_version 1) - -(declare_subtype int stat) diff --git a/data/examples/the_thief/main.fate b/data/examples/the_thief/main.fate deleted file mode 100644 index 66773c2..0000000 --- a/data/examples/the_thief/main.fate +++ /dev/null @@ -1,47 +0,0 @@ -(fate_version 1) - -(require include/text_effects.fate) -(require include/characters.fate) -(require include/chapters.fate) - -(text_effect narrator -   As the last lights of the day vanish, you bid farewell to a sun you hope -   will not recognize you next morning, for tonight is the time of your -   transformation. Tonight, you put an end to the hunger. Tonight, you put an -   end to the cold. Tonight, surely, you get to claim the luck you were denied -   all this time. -   (newline) -   As you gaze upon the magnificent Tarmock manor, any trace of hesitation -   disappears. The plan is simple: your forged letter of introduction will get -   you through the door, and your lifelong skills through their purses. -) - -(sequence standing_before_the_manor) - -(cond -   ((= 3 (variable oscar.money)) ...don't...) -   ((> 3 (variable carla.agility)) ...might...) -   ((> 3 (variable carla.perception)) ...surely...) -) - -(= lol -   (cond -      ((= 3 (variable oscar.money)) ...don't...) -      ((> 3 (variable carla.agility)) ...might...) -      ((> 3 (variable carla.perception)) ...surely...) -   ) -) -Tonight's the night... (newline) -Tonight, we become rich... (newline) -Tonight, we... - -(player_choice -   ( -      ( ...get in through the window! ) -      (sequence through_the_window) -   ) -   ( -      ( ...knock at the door! ) -      (sequence knocking_on_door) -   ) -) diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Assert.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Assert.java index f876f0c..46c06d2 100644 --- a/src/core/src/tonkadur/fate/v1/lang/instruction/Assert.java +++ b/src/core/src/tonkadur/fate/v1/lang/instruction/Assert.java @@ -46,7 +46,7 @@ public class Assert extends InstructionNode     )     throws InvalidTypeException     { -      if (condition.get_type().get_base_type().equals(Type.BOOLEAN)) +      if (!condition.get_type().get_base_type().equals(Type.BOOLEAN))        {           ErrorManager.handle           ( diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/IfElseInstruction.java b/src/core/src/tonkadur/fate/v1/lang/instruction/IfElseInstruction.java index 1bedbe0..e41bf98 100644 --- a/src/core/src/tonkadur/fate/v1/lang/instruction/IfElseInstruction.java +++ b/src/core/src/tonkadur/fate/v1/lang/instruction/IfElseInstruction.java @@ -54,7 +54,7 @@ public class IfElseInstruction extends InstructionNode     )     throws InvalidTypeException     { -      if (condition.get_type().get_base_type().equals(Type.BOOLEAN)) +      if (!condition.get_type().get_base_type().equals(Type.BOOLEAN))        {           ErrorManager.handle           ( diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/IfInstruction.java b/src/core/src/tonkadur/fate/v1/lang/instruction/IfInstruction.java index a6c4a81..e63b71b 100644 --- a/src/core/src/tonkadur/fate/v1/lang/instruction/IfInstruction.java +++ b/src/core/src/tonkadur/fate/v1/lang/instruction/IfInstruction.java @@ -50,7 +50,7 @@ public class IfInstruction extends InstructionNode     )     throws InvalidTypeException     { -      if (condition.get_type().get_base_type().equals(Type.BOOLEAN)) +      if (!condition.get_type().get_base_type().equals(Type.BOOLEAN))        {           ErrorManager.handle           ( diff --git a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 index 8d6dd29..0dfa292 100644 --- a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 +++ b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 @@ -12,68 +12,67 @@ WS: SEP;  L_PAREN: '(';  R_PAREN: ')'; -ADD_KW: L_PAREN 'add'; -ADD_VARIABLE_ATTRIBUTE_KW: L_PAREN 'add_variable_attribute'; -AND_KW: L_PAREN ('and'|'/\\'); -ASSERT_KW: L_PAREN 'assert'; -AT_KW: L_PAREN 'at'; -CAST_KW: L_PAREN 'cast'; -CLEAR_KW: L_PAREN 'clear'; -COND_KW: L_PAREN 'cond'; -COUNT_KW: L_PAREN 'count'; -DECLARE_ALIAS_TYPE_KW: L_PAREN 'declare_subtype'; -DECLARE_DICT_TYPE_KW: L_PAREN 'declare_dict_type'; -DECLARE_EVENT_TYPE_KW: L_PAREN 'declare_event_type'; -DECLARE_LIST_TYPE_KW: L_PAREN 'declare_list_type'; -DECLARE_REF_TYPE_KW: L_PAREN 'declare_ref_type'; -DECLARE_SET_TYPE_KW: L_PAREN 'declare_set_type'; -DECLARE_TEXT_EFFECT_KW: L_PAREN 'declare_text_effect'; -DECLARE_VARIABLE_KW: L_PAREN 'declare_variable'; -DEFINE_MACRO_KW: L_PAREN 'define_macro'; -DEFINE_SEQUENCE_KW: L_PAREN 'define_sequence'; -DIVIDE_KW: L_PAREN ('divide'|'/'); -ENABLE_TEXT_EFFECT_KW: L_PAREN 'text_effect'; -EQUALS_KW: L_PAREN ('equals'|'='|'=='); -EVENT_KW: L_PAREN 'event'; + +ADD_KW: L_PAREN 'add' SEP+; +AND_KW: L_PAREN ('and'|'/\\') SEP+; +ASSERT_KW: L_PAREN 'assert' SEP+; +AT_KW: L_PAREN 'at' SEP+; +CAST_KW: L_PAREN 'cast' SEP+; +CLEAR_KW: L_PAREN 'clear' SEP+; +COND_KW: L_PAREN 'cond' SEP+; +COUNT_KW: L_PAREN 'count' SEP+; +DECLARE_ALIAS_TYPE_KW: L_PAREN ((('declare'|'define'|'def')'_'('sub'('_'?))?'type')|'typedef') SEP+; +DECLARE_DICT_TYPE_KW: L_PAREN ('declare'|'define'|'def')'_dict_type' SEP+; +DECLARE_EVENT_TYPE_KW: L_PAREN ('declare'|'define'|'def')'_event_type' SEP+; +DECLARE_LIST_TYPE_KW: L_PAREN ('declare'|'define'|'def')'_list_type' SEP+; +DECLARE_REF_TYPE_KW: L_PAREN ('declare'|'define'|'def')'_ref_type' SEP+; +DECLARE_SET_TYPE_KW: L_PAREN ('declare'|'define'|'def')'_set_type' SEP+; +DECLARE_TEXT_EFFECT_KW: L_PAREN ('declare'|'define'|'def')'_text_effect' SEP+; +DECLARE_VARIABLE_KW: L_PAREN ('declare'|'define'|'def')'_var'('iable')? SEP+; +DEFINE_MACRO_KW: L_PAREN ('declare'|'define'|'def')'_macro' SEP+; +DEFINE_SEQUENCE_KW: L_PAREN ('declare'|'define'|'def')'_sequence' SEP+; +DIVIDE_KW: L_PAREN ('divide'|'/'|'div') SEP+; +ENABLE_TEXT_EFFECT_KW: L_PAREN 'text_effect' SEP+; +EQUALS_KW: L_PAREN ('equals'|'='|'=='|'eq') SEP+; +EVENT_KW: L_PAREN 'event' SEP+;  EXTENSION_FIRST_LEVEL_KW: L_PAREN '@';  EXTENSION_INSTRUCTION_KW: L_PAREN '#';  EXTENSION_VALUE_KW: L_PAREN '$';  FALSE_KW: L_PAREN 'false)'; -FATE_VERSION_KW: L_PAREN 'fate_version'; -FIELD_KW: L_PAREN 'field'; -GREATER_EQUAL_THAN_KW: L_PAREN ('greater_equal_than'|'>='); -GREATER_THAN_KW: L_PAREN ('greater_than'|'>'); -IF_ELSE_KW: L_PAREN 'if_else'; -IF_KW: L_PAREN 'if'; -IMPLIES_KW: L_PAREN ('implies'|'=>'); -INCLUDE_KW: L_PAREN 'include'; -IS_MEMBER_KW: L_PAREN 'is_member'; -LOWER_EQUAL_THAN_KW: L_PAREN ('lower_equal_than'|'=<'|'<='); -LOWER_THAN_KW: L_PAREN ('lower_than'|'<'); -MACRO_KW: L_PAREN 'macro'; -MINUS_KW: L_PAREN ('minus'|'-'); +FATE_VERSION_KW: L_PAREN 'fate_version' SEP+; +FIELD_KW: L_PAREN 'field' SEP+; +GREATER_EQUAL_THAN_KW: L_PAREN ('greater_equal_than'|'>='|'ge') SEP+; +GREATER_THAN_KW: L_PAREN ('greater_than'|'>'|'gt') SEP+; +IF_ELSE_KW: L_PAREN ('if_else'|'ifelse') SEP+; +IF_KW: L_PAREN 'if' SEP+; +IMPLIES_KW: L_PAREN ('implies'|'=>') SEP+; +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+; +MINUS_KW: L_PAREN ('minus'|'-') SEP+;  NEWLINE_KW: L_PAREN 'newline)'; -NOT_KW: L_PAREN ('not'|'~'|'!'); -ONE_IN_KW: L_PAREN 'one_in'; -OR_KW: L_PAREN ('or'|'\\/'); -PARAMETER_KW: L_PAREN ('param'|'parameter'); -PLAYER_CHOICE_KW: L_PAREN ('choice'|'user_choice'|'player_choice'); -PLUS_KW: L_PAREN ('plus'|'+'); -POWER_KW: L_PAREN ('power'|'^'|'**'); -RANDOM_KW: L_PAREN ('random'|'rand'); -REF_KW: L_PAREN 'ref'; -REMOVE_ALL_KW: L_PAREN 'remove_all'; -REMOVE_ONE_KW: L_PAREN 'remove_one'; -REQUIRE_EXTENSION_KW: L_PAREN 'require_extension'; -REQUIRE_KW: L_PAREN 'require'; -SEQUENCE_KW: L_PAREN 'sequence'; -SET_EXPRESSION_KW: L_PAREN 'set_expression'; -SET_FIELDS_KW: L_PAREN 'set_fields'; -SET_KW: L_PAREN 'set'; -TIMES_KW: L_PAREN ('times'|'*'); +NOT_KW: L_PAREN ('not'|'~'|'!') SEP+; +ONE_IN_KW: L_PAREN 'one_in' SEP+; +OR_KW: L_PAREN ('or'|'\\/') SEP+; +PARAMETER_KW: L_PAREN ('param'|'parameter'|'par') SEP+; +PLAYER_CHOICE_KW: L_PAREN ('choice'|'user_choice'|'player_choice') SEP+; +PLUS_KW: L_PAREN ('plus'|'+') SEP+; +POWER_KW: L_PAREN ('power'|'^'|'**') SEP+; +RANDOM_KW: L_PAREN ('random'|'rand') SEP+; +REF_KW: L_PAREN 'ref' SEP+; +REMOVE_ALL_KW: L_PAREN 'remove_all' SEP+; +REMOVE_ONE_KW: L_PAREN 'remove_one' SEP+; +REQUIRE_EXTENSION_KW: L_PAREN 'require_extension' SEP+; +REQUIRE_KW: L_PAREN 'require' SEP+; +SEQUENCE_KW: L_PAREN 'sequence' SEP+; +SET_FIELDS_KW: L_PAREN 'set_fields' SEP+; +SET_KW: L_PAREN 'set' SEP+; +TIMES_KW: L_PAREN ('times'|'*') SEP+;  TRUE_KW: L_PAREN 'true)'; -VAL_KW: L_PAREN 'val'; -VARIABLE_KW: L_PAREN 'variable'; +VAL_KW: L_PAREN ('val'|'value') SEP+; +VARIABLE_KW: L_PAREN ('variable'|'var') SEP+;  WORD: (~([ \t\r\n()])|'\\)'|'\\(')+; diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 index 94920f3..2875ad1 100644 --- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 +++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 @@ -56,7 +56,7 @@ fate_file [Context context, World world]        PARAMETERS = null;     }     : -   WS* FATE_VERSION_KW WS+ WORD WS* R_PAREN WS* +   WS* FATE_VERSION_KW WORD WS* R_PAREN WS*     (        (           first_level_fate_instr @@ -94,7 +94,6 @@ returns [List<InstructionNode> result]  first_level_fate_instr:     DEFINE_SEQUENCE_KW -      WS+        new_reference_name        pre_sequence_point=WS+        general_fate_sequence @@ -134,7 +133,6 @@ first_level_fate_instr:     }     | DECLARE_VARIABLE_KW -      WS+        type        WS+        name=new_reference_name @@ -164,7 +162,6 @@ first_level_fate_instr:     }     | DECLARE_VARIABLE_KW -      WS+        scope=WORD        WS+        type @@ -216,7 +213,6 @@ first_level_fate_instr:     }     | DECLARE_TEXT_EFFECT_KW -      WS+        params=type_list        WS*        new_reference_name @@ -244,14 +240,14 @@ first_level_fate_instr:        WORLD.text_effects().add(new_text_effect);     } -   | REQUIRE_EXTENSION_KW WS+ WORD WS* R_PAREN +   | 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 WS+ parent=type WS+ new_reference_name WS* R_PAREN +   | DECLARE_ALIAS_TYPE_KW parent=type WS+ new_reference_name WS* R_PAREN     {        final Origin start_origin;        final Type new_type; @@ -274,7 +270,7 @@ first_level_fate_instr:        WORLD.types().add(new_type);     } -   | DECLARE_SET_TYPE_KW WS+ parent=type WS+ new_reference_name WS* R_PAREN +   | DECLARE_SET_TYPE_KW parent=type WS+ new_reference_name WS* R_PAREN     {        final Origin start_origin;        final Type new_type; @@ -298,7 +294,7 @@ first_level_fate_instr:        WORLD.types().add(new_type);     } -   | DECLARE_LIST_TYPE_KW WS+ parent=type WS+ new_reference_name WS* R_PAREN +   | DECLARE_LIST_TYPE_KW parent=type WS+ new_reference_name WS* R_PAREN     {        final Origin start_origin;        final Type new_type; @@ -322,7 +318,7 @@ first_level_fate_instr:        WORLD.types().add(new_type);     } -   | DECLARE_REF_TYPE_KW WS+ parent=type WS+ new_reference_name WS* R_PAREN +   | DECLARE_REF_TYPE_KW parent=type WS+ new_reference_name WS* R_PAREN     {        final Origin start_origin;        final Type new_type; @@ -346,7 +342,6 @@ first_level_fate_instr:     }     | DECLARE_DICT_TYPE_KW -      WS+        new_reference_name        WS*        typed_entry_list @@ -386,8 +381,30 @@ first_level_fate_instr:        WORLD.types().add(new_type);     } +   | DECLARE_EVENT_TYPE_KW new_reference_name WS* R_PAREN +   { +      final Origin start_origin; +      final Event new_event; -   | DECLARE_EVENT_TYPE_KW WS+ new_reference_name WS+ type_list WS* R_PAREN +      start_origin = +         CONTEXT.get_origin_at +         ( +            ($DECLARE_EVENT_TYPE_KW.getLine()), +            ($DECLARE_EVENT_TYPE_KW.getCharPositionInLine()) +         ); + +      new_event = +         new Event +         ( +            start_origin, +            new ArrayList<Type>(), +            ($new_reference_name.result) +         ); + +      WORLD.events().add(new_event); +   } + +   | DECLARE_EVENT_TYPE_KW new_reference_name WS+ type_list WS* R_PAREN     {        final Origin start_origin;        final Event new_event; @@ -410,7 +427,8 @@ first_level_fate_instr:        WORLD.events().add(new_event);     } -   | REQUIRE_KW WS+ WORD WS* R_PAREN + +   | REQUIRE_KW WORD WS* R_PAREN     {        final String filename; @@ -434,7 +452,7 @@ first_level_fate_instr:        }     } -   | INCLUDE_KW WS+ WORD WS* R_PAREN +   | INCLUDE_KW WORD WS* R_PAREN     {        final String filename; @@ -456,7 +474,6 @@ first_level_fate_instr:     }     | DEFINE_MACRO_KW -         WS+           new_reference_name           WS*           ( @@ -527,12 +544,47 @@ first_level_fate_instr:  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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); +   }  } +/* Trying to get rule priorities right */  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 = @@ -547,7 +599,7 @@ returns [InstructionNode result]           );     } -   | ADD_KW WS+ value WS+ value_reference WS* R_PAREN +   | ADD_KW value WS+ value_reference WS* R_PAREN     {        $result =           AddElement.build @@ -562,7 +614,7 @@ returns [InstructionNode result]           );     } -   | REMOVE_ONE_KW WS+ value WS+ value_reference WS* R_PAREN +   | REMOVE_ONE_KW value WS+ value_reference WS* R_PAREN     {        $result =           RemoveElement.build @@ -577,7 +629,7 @@ returns [InstructionNode result]           );     } -   | REMOVE_ALL_KW WS+ value WS+ value_reference WS* R_PAREN +   | REMOVE_ALL_KW value WS+ value_reference WS* R_PAREN     {        $result =           RemoveAllOfElement.build @@ -592,7 +644,7 @@ returns [InstructionNode result]           );     } -   | CLEAR_KW WS+ value_reference WS* R_PAREN +   | CLEAR_KW value_reference WS* R_PAREN     {        $result =           Clear.build @@ -606,7 +658,7 @@ returns [InstructionNode result]           );     } -   | SET_KW WS+ value WS+ value_reference WS* R_PAREN +   | SET_KW value_reference WS+ value WS* R_PAREN     {        $result =           SetValue.build @@ -621,7 +673,7 @@ returns [InstructionNode result]           );     } -   | SET_FIELDS_KW WS+ value_reference WS* field_value_list WS* R_PAREN +   | SET_FIELDS_KW value_reference WS* field_value_list WS* R_PAREN     {        final Origin origin;        final List<InstructionNode> operations; @@ -660,7 +712,7 @@ returns [InstructionNode result]        $result = new InstructionList(origin, operations);     } -   | EVENT_KW WS+ WORD WS+ value_list WS* R_PAREN +   | EVENT_KW WORD WS+ value_list WS* R_PAREN     {        final Origin origin;        final Event event; @@ -683,7 +735,30 @@ returns [InstructionNode result]           );     } -   | MACRO_KW WS+ WORD WS+ value_list WS* R_PAREN +   | EVENT_KW WORD WS* R_PAREN +   { +      final Origin origin; +      final Event event; + +      origin = +         CONTEXT.get_origin_at +         ( +            ($EVENT_KW.getLine()), +            ($EVENT_KW.getCharPositionInLine()) +         ); + +      event = WORLD.events().get(origin, ($WORD.text)); + +      $result = +         EventCall.build +         ( +            origin, +            event, +            new ArrayList<ValueNode>() +         ); +   } + +   | MACRO_KW WORD WS+ value_list WS* R_PAREN     {        final Origin origin;        final Macro macro; @@ -706,7 +781,7 @@ returns [InstructionNode result]           );     } -   | SEQUENCE_KW WS+ WORD WS* R_PAREN +   | SEQUENCE_KW WORD WS* R_PAREN     {        final Origin origin;        final String sequence_name; @@ -725,7 +800,7 @@ returns [InstructionNode result]        $result = new SequenceCall(origin, sequence_name);     } -   | ASSERT_KW WS+ value WS* R_PAREN +   | ASSERT_KW value WS* R_PAREN     {        $result =           Assert.build @@ -739,7 +814,7 @@ returns [InstructionNode result]           );     } -   | IF_KW WS+ value WS* general_fate_instr WS* R_PAREN +   | IF_KW value WS* general_fate_instr WS* R_PAREN     {        $result =           IfInstruction.build @@ -755,7 +830,7 @@ returns [InstructionNode result]     }     | IF_ELSE_KW -         WS+ value +         value           WS+ if_true=general_fate_instr           WS+ if_false=general_fate_instr        WS* R_PAREN @@ -774,7 +849,7 @@ returns [InstructionNode result]           );     } -   | COND_KW WS+ instr_cond_list WS* R_PAREN +   | COND_KW instr_cond_list WS* R_PAREN     {        $result =           CondInstruction.build @@ -788,7 +863,7 @@ returns [InstructionNode result]           );     } -   | PLAYER_CHOICE_KW WS+ player_choice_list WS* R_PAREN +   | PLAYER_CHOICE_KW player_choice_list WS* R_PAREN     {        $result =           new PlayerChoiceList @@ -835,20 +910,17 @@ returns [InstructionNode result]              );        }     } - -   | paragraph -   { -      $result = -         new Display -         ( -            ($paragraph.result.get_origin()), -            ($paragraph.result) -         ); -   }  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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); +   }  }  instr_cond_list @@ -907,7 +979,7 @@ returns [InstructionNode result]           );     } -   | IF_KW WS+ value WS+ player_choice WS* R_PAREN +   | IF_KW value WS+ player_choice WS* R_PAREN     {        $result =           IfInstruction.build @@ -922,7 +994,7 @@ returns [InstructionNode result]           );     } -   | IF_ELSE_KW WS+ +   | IF_ELSE_KW        value WS+        if_true=player_choice WS+        if_false=player_choice WS* @@ -942,7 +1014,7 @@ returns [InstructionNode result]           );     } -   | COND_KW WS+ player_choice_cond_list WS* R_PAREN +   | COND_KW player_choice_cond_list WS* R_PAREN     {        $result =           CondInstruction.build @@ -958,7 +1030,14 @@ returns [InstructionNode result]  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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); +   }  }  player_choice_cond_list @@ -980,7 +1059,14 @@ returns [List<Cons<ValueNode, InstructionNode>> result]  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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); +   }  }  paragraph @@ -1034,7 +1120,7 @@ returns [TextNode result]:        $result = ($sentence.result);     } -   | ENABLE_TEXT_EFFECT_KW WS+ WORD WS+ paragraph WS* R_PAREN +   | ENABLE_TEXT_EFFECT_KW WORD WS+ paragraph WS* R_PAREN     {        final TextEffect effect; @@ -1063,7 +1149,7 @@ returns [TextNode result]:           );     } -   | ENABLE_TEXT_EFFECT_KW WS+ +   | ENABLE_TEXT_EFFECT_KW        L_PAREN           WORD WS+           value_list @@ -1118,7 +1204,14 @@ returns [TextNode result]:  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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 @@ -1173,7 +1266,14 @@ returns [Type result]  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(e); +   if ((e.getMessage() == null) || !e.getMessage().startsWith("Require")) +   { +      throw new ParseCancellationException(CONTEXT.toString() + ((e.getMessage() == null) ? "" : e.getMessage()), e); +   } +   else +   { +      throw new ParseCancellationException(e); +   }  }  type_list @@ -1227,7 +1327,14 @@ returns [TypedEntryList result]  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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); +   }  }  field_value_list @@ -1289,7 +1396,14 @@ returns [String result]  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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); +   }  }  /******************************************************************************/ @@ -1325,7 +1439,7 @@ returns [ValueNode result]:           );     } -   | AND_KW WS+ value_list WS* R_PAREN +   | AND_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1340,7 +1454,7 @@ returns [ValueNode result]:           );     } -   | OR_KW WS+ value_list WS* R_PAREN +   | OR_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1355,7 +1469,7 @@ returns [ValueNode result]:           );     } -   | ONE_IN_KW WS+ value_list WS* R_PAREN +   | ONE_IN_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1370,7 +1484,7 @@ returns [ValueNode result]:           );     } -   | NOT_KW WS+ value_list WS* R_PAREN +   | NOT_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1385,7 +1499,7 @@ returns [ValueNode result]:           );     } -   | IMPLIES_KW WS+ value_list WS* R_PAREN +   | IMPLIES_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1400,7 +1514,7 @@ returns [ValueNode result]:           );     } -   | LOWER_THAN_KW WS+ value_list WS* R_PAREN +   | LOWER_THAN_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1415,7 +1529,7 @@ returns [ValueNode result]:           );     } -   | LOWER_EQUAL_THAN_KW WS+ value_list WS* R_PAREN +   | LOWER_EQUAL_THAN_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1430,7 +1544,7 @@ returns [ValueNode result]:           );     } -   | EQUALS_KW WS+ value_list WS* R_PAREN +   | EQUALS_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1445,7 +1559,7 @@ returns [ValueNode result]:           );     } -   | GREATER_EQUAL_THAN_KW WS+ value_list WS* R_PAREN +   | GREATER_EQUAL_THAN_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1460,7 +1574,7 @@ returns [ValueNode result]:           );     } -   | GREATER_THAN_KW WS+ value_list WS* R_PAREN +   | GREATER_THAN_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1475,7 +1589,7 @@ returns [ValueNode result]:           );     } -   | IS_MEMBER_KW WS+ value WS+ value_reference WS* R_PAREN +   | IS_MEMBER_KW value WS+ value_reference WS* R_PAREN     {        $result =           IsMemberOperator.build @@ -1492,12 +1606,19 @@ returns [ValueNode result]:  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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 [ValueNode result]: -   PLUS_KW WS+ value_list WS* R_PAREN +   PLUS_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1512,7 +1633,7 @@ returns [ValueNode result]:           );     } -   | MINUS_KW WS+ value_list WS* R_PAREN +   | MINUS_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1527,7 +1648,7 @@ returns [ValueNode result]:           );     } -   | TIMES_KW WS+ value_list WS* R_PAREN +   | TIMES_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1542,7 +1663,7 @@ returns [ValueNode result]:           );     } -   | DIVIDE_KW WS+ value_list WS* R_PAREN +   | DIVIDE_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1557,7 +1678,7 @@ returns [ValueNode result]:           );     } -   | POWER_KW WS+ value_list WS* R_PAREN +   | POWER_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1572,7 +1693,7 @@ returns [ValueNode result]:           );     } -   | RANDOM_KW WS+ value_list WS* R_PAREN +   | RANDOM_KW value_list WS* R_PAREN     {        $result =           Operation.build @@ -1587,7 +1708,7 @@ returns [ValueNode result]:           );     } -   | COUNT_KW WS+ value WS+ value_reference WS* R_PAREN +   | COUNT_KW value WS+ value_reference WS* R_PAREN     {        $result =           CountOperator.build @@ -1604,7 +1725,14 @@ returns [ValueNode result]:  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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 @@ -1629,7 +1757,7 @@ returns [ValueNode result]        $result = ($paragraph.result);     } -   | ENABLE_TEXT_EFFECT_KW WS+ WORD WS+ paragraph WS* R_PAREN +   | ENABLE_TEXT_EFFECT_KW WORD WS+ paragraph WS* R_PAREN     {        final TextEffect effect; @@ -1658,7 +1786,7 @@ returns [ValueNode result]           );     } -   | ENABLE_TEXT_EFFECT_KW WS+ +   | ENABLE_TEXT_EFFECT_KW        L_PAREN           WORD WS+           value_list @@ -1713,13 +1841,20 @@ returns [ValueNode result]  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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 [ValueNode result]  : -   IF_ELSE_KW WS+ cond=value WS+ if_true=value WS+ if_false=value WS* R_PAREN +   IF_ELSE_KW cond=value WS+ if_true=value WS+ if_false=value WS* R_PAREN     {        $result =           IfElseValue.build @@ -1735,7 +1870,7 @@ returns [ValueNode result]           );     } -   | COND_KW WS+ value_cond_list WS* R_PAREN +   | COND_KW value_cond_list WS* R_PAREN     {        $result =           CondValue.build @@ -1759,7 +1894,7 @@ returns [ValueNode result]        $result = ($math_expression.result);     } -   | REF_KW WS+ value_reference WS* R_PAREN +   | REF_KW value_reference WS* R_PAREN     {        $result =           new RefOperator @@ -1773,7 +1908,7 @@ returns [ValueNode result]           );     } -   | CAST_KW WS+ WORD WS+ value WS* R_PAREN +   | CAST_KW WORD WS+ value WS* R_PAREN     {        final Origin target_type_origin;        final Type target_type; @@ -1835,7 +1970,7 @@ returns [ValueNode result]        }     } -   | MACRO_KW WS+ WORD WS+ value_list WS* R_PAREN +   | MACRO_KW WORD WS+ value_list WS* R_PAREN     {        final Origin origin;        final Macro macro; @@ -1865,13 +2000,20 @@ returns [ValueNode result]  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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_reference  returns [Reference result]  : -   AT_KW WS+ value_reference WS* R_PAREN +   AT_KW value_reference WS* R_PAREN     {        $result =           AtReference.build @@ -1885,7 +2027,7 @@ returns [Reference result]           );     } -   | FIELD_KW WS+ value_reference WORD R_PAREN +   | FIELD_KW value_reference WORD R_PAREN     {        $result =           FieldReference.build @@ -1900,7 +2042,7 @@ returns [Reference result]           );     } -   | VARIABLE_KW WS+ WORD WS* R_PAREN +   | VARIABLE_KW WORD WS* R_PAREN     {        final Origin target_var_origin;        final Variable target_var; @@ -1946,7 +2088,7 @@ returns [Reference result]        }     } -   | PARAMETER_KW WS+ WORD WS* R_PAREN +   | PARAMETER_KW WORD WS* R_PAREN     {        final Origin origin; @@ -2060,7 +2202,14 @@ returns [Reference result]  ;  catch [final Throwable e]  { -   throw new ParseCancellationException(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_cond_list @@ -2102,3 +2251,28 @@ 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); +   } +} diff --git a/src/core/src/tonkadur/parser/Context.java b/src/core/src/tonkadur/parser/Context.java index edb1e68..f99ad2b 100644 --- a/src/core/src/tonkadur/parser/Context.java +++ b/src/core/src/tonkadur/parser/Context.java @@ -116,6 +116,9 @@ public class Context           sb.append(System.lineSeparator());        } +      sb.append(current_file); +      sb.append(System.lineSeparator()); +        return sb.toString();     } | 


