feat: multidivert; more tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Antlr4.Runtime.Tree;
|
||||
using System.Diagnostics;
|
||||
using Antlr4.Runtime.Tree;
|
||||
using InkBlot.ParseHierarchy;
|
||||
|
||||
namespace InkBlot.Visitor;
|
||||
@@ -13,7 +14,9 @@ public partial class Listener
|
||||
|
||||
public override void ExitMultiDivert(InkBlotAntlrGrammarParser.MultiDivertContext context)
|
||||
{
|
||||
PutStoryNode(context, _multiDiverts.Get(context));
|
||||
var storyNode = _multiDiverts.Get(context);
|
||||
Debug.Assert(storyNode != null);
|
||||
PutStoryNode(context, storyNode);
|
||||
}
|
||||
|
||||
public override void ExitMultiDivertThread(InkBlotAntlrGrammarParser.MultiDivertThreadContext context)
|
||||
@@ -29,41 +32,40 @@ public partial class Listener
|
||||
.divertIdentifierWithArguments()
|
||||
.Select(a => _divertIdentifiers.Get(a));
|
||||
var tail = _multiDivertsArrowsTail.Get(context.multiDivertArrows_tail());
|
||||
_multiDiverts.Put(context,
|
||||
Debug.Assert(tail != null);
|
||||
var tunnelsAndDivertsList = new TunnelsAndDivertsList(
|
||||
divertIdentifiers.ToArray(),
|
||||
tail.LastArrowIsDivert
|
||||
? new DivertsListWithoutReturnFromTunnel(
|
||||
(tail.Identifier != null ? divertIdentifiers.Append(tail.Identifier) : divertIdentifiers).ToArray(),
|
||||
tail.LastArrowIsDivert)
|
||||
: new DivertsListWithReturnFromTunnel(
|
||||
divertIdentifiers.ToArray(),
|
||||
tail.Identifier
|
||||
));
|
||||
? new TunnelListEndingDivert(tail.Identifier)
|
||||
: new TunnelListEndingReturnFromTunnel(tail.Identifier)
|
||||
);
|
||||
_multiDiverts.Put(context.Parent, tunnelsAndDivertsList);
|
||||
}
|
||||
|
||||
public override void ExitMultiDivertArrows_tailDefaultChoice(
|
||||
InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context)
|
||||
{
|
||||
_multiDivertsArrowsTail.Put(context.Parent, new MultiDivertArrowsTail(true, null));
|
||||
_multiDivertsArrowsTail.Put(context, new MultiDivertArrowsTail(true, null));
|
||||
}
|
||||
|
||||
public override void ExitMultiDivertArrows_tailDivert(
|
||||
InkBlotAntlrGrammarParser.MultiDivertArrows_tailDivertContext context)
|
||||
{
|
||||
_multiDivertsArrowsTail.Put(context.Parent, new MultiDivertArrowsTail(true,
|
||||
_multiDivertsArrowsTail.Put(context, new MultiDivertArrowsTail(true,
|
||||
_divertIdentifiers.Get(context.divertIdentifierWithArguments())));
|
||||
}
|
||||
|
||||
public override void ExitMultiDivertArrows_tailTunnelWithReplacement(
|
||||
InkBlotAntlrGrammarParser.MultiDivertArrows_tailTunnelWithReplacementContext context)
|
||||
{
|
||||
_multiDivertsArrowsTail.Put(context.Parent, new MultiDivertArrowsTail(false,
|
||||
_multiDivertsArrowsTail.Put(context, new MultiDivertArrowsTail(false,
|
||||
_divertIdentifiers.Get(context.divertIdentifierWithArguments())));
|
||||
}
|
||||
|
||||
public override void ExitMultiDivertArrows_tailTunnel(
|
||||
InkBlotAntlrGrammarParser.MultiDivertArrows_tailTunnelContext context)
|
||||
{
|
||||
_multiDivertsArrowsTail.Put(context.Parent, new MultiDivertArrowsTail(false, null));
|
||||
_multiDivertsArrowsTail.Put(context, new MultiDivertArrowsTail(false, null));
|
||||
}
|
||||
|
||||
#region divertIdentifierWithArguments_name
|
||||
|
||||
Reference in New Issue
Block a user