| summaryrefslogtreecommitdiff |
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2021-04-29 20:39:25 +0200 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2021-04-29 20:39:25 +0200 |
| commit | a5ddb05e399929e778f501c864c894b32da3c354 (patch) | |
| tree | 49a00cd53469419504f7e28c5bdbe69aa9bd0d2f /src | |
| parent | d0e544bba4a204875b8357bb2d7e29d9ce29a461 (diff) | |
Clears up the multiple text rules.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 | 2 | ||||
| -rw-r--r-- | src/core/src/tonkadur/fate/v1/parser/FateParser.g4 | 150 |
2 files changed, 51 insertions, 101 deletions
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 index d5f21cd..c9283c7 100644 --- a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 +++ b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 @@ -55,7 +55,7 @@ END_KW: L_PAREN 'end)'; EQUALS_KW: L_PAREN ('equals'|'='|'=='|'eq') SEP+; EXTENSION_FIRST_LEVEL_KW: L_PAREN '@'; EXTRA_INSTRUCTION_KW: L_PAREN '#'; -JOIN_KW: L_PAREN 'join' SEP+; +JOIN_KW: L_PAREN ('text'US)? 'join' SEP+; EXTRA_COMPUTATION_KW: L_PAREN '$'; FALSE_KW: L_PAREN 'false)'; IGNORE_ERROR_KW: L_PAREN 'ignore'US('error'|'warning') SEP+; diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 index cba5111..7736318 100644 --- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 +++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 @@ -2646,12 +2646,12 @@ returns [TextNode result] final List<TextNode> content = new ArrayList(); } : - first=text + first=text_value { content.add(($first.result)); } ( - (WS+ next_a=text) + (WS+ next_a=text_value) { if (!(content.get(content.size() - 1) instanceof Newline)) { @@ -2671,7 +2671,7 @@ returns [TextNode result] content.add(($next_a.result)); } | - (next_b=text) + (next_b=text_value) { content.add(($next_b.result)); } @@ -2704,11 +2704,11 @@ catch [final Throwable e] } } -text +actual_text_value returns [TextNode result]: - sentence + TEXT_KW paragraph WS* R_PAREN { - $result = ValueToText.build(($sentence.result)); + $result = ($paragraph.result); } | JOIN_KW value WS+ non_text_value WS* R_PAREN @@ -2802,6 +2802,25 @@ returns [TextNode result]: ) ); } +; +catch [final Throwable e] +{ + if ((e.getMessage() == null) || !e.getMessage().startsWith("Require")) + { + throw new ParseCancellationException(CONTEXT.toString() + ((e.getMessage() == null) ? "" : e.getMessage()), e); + } + else + { + throw new ParseCancellationException(e); + } +} + +value_as_text +returns [TextNode result]: + sentence + { + $result = ValueToText.build(($sentence.result)); + } | non_text_value { @@ -2820,6 +2839,29 @@ catch [final Throwable 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 @@ -3935,101 +3977,9 @@ returns [Computation result] $result = ($sentence.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 + | actual_text_value { - $result = - new Newline - ( - CONTEXT.get_origin_at - ( - ($NEWLINE_KW.getLine()), - ($NEWLINE_KW.getCharPositionInLine()) - ) - ); + $result = ($actual_text_value.result); } | non_text_value |


