feat: multidivert; more tests

This commit is contained in:
mattia
2025-03-01 18:03:42 +01:00
parent 6ee8051004
commit 43745e75e7
11 changed files with 276 additions and 212 deletions

View File

@@ -1,4 +1,5 @@
using System.Text;
using InkBlot.ParseHierarchy;
using Microsoft.Extensions.Logging;
namespace InkBlot.Tests;
@@ -22,4 +23,20 @@ internal static class Helpers
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
return loggerFactory;
}
}
public class TestBase
{
protected (Story, Diagnostic[]) ParseText(string inkInput)
{
// parse the story
var fileReader = new InMemoryFileReader([
("main.ink", inkInput)
]);
using var loggerFactory = Helpers.GetLoggerFactory();
var (story, diagnosticsEnumerable) = InkBlotParser.Parse(fileReader, loggerFactory, "main.ink");
var diagnostics = diagnosticsEnumerable.ToArray();
return (story, diagnostics);
}
}

View File

@@ -3,22 +3,60 @@ using Shouldly;
namespace InkBlot.Tests;
public class MultiDivertTest
public class MultiDivertTest : TestBase
{
[Fact]
public void TestThreadDivert()
private IStoryNode[] MyParseText(string text)
{
var fileReader = new InMemoryFileReader([
("main.ink", "<- threadName")
]);
var tokensStream = InkBlotParser.GetTokenStream(fileReader, "main.ink");
tokensStream.Fill();
var tokens = tokensStream.GetTokens();
using var loggerFactory = Helpers.GetLoggerFactory();
var (story, diagnostics) = InkBlotParser.Parse(fileReader, loggerFactory, "main.ink");
var (story, diagnostics) = ParseText(text);
diagnostics.ShouldBe([]);
var storyNodes = story.StoryNodes.ToArray();
return storyNodes;
}
[Fact]
public void TestThreadDivert()
{
var storyNodes = MyParseText("<- threadName");
storyNodes.ShouldBe([new MultiDivert(new ThreadDivert(new Identifier(["threadName"])))]);
}
[Fact]
public void TestSimpleDivert()
{
var storyNodes = MyParseText("-> divertName");
storyNodes.ShouldBe([
new MultiDivert(new TunnelsAndDivertsList([], new TunnelListEndingDivert(new Identifier(["divertName"]))))
]);
}
[Fact]
public void TestReturnFromTunnel()
{
var storyNodes = MyParseText("->->");
storyNodes.ShouldBe([
new MultiDivert(new TunnelsAndDivertsList([], new TunnelListEndingReturnFromTunnel(null)))
]);
}
[Fact]
public void TestDivertFromTunnel()
{
var storyNodes = MyParseText("->-> divertName");
storyNodes.ShouldBe([
new MultiDivert(new TunnelsAndDivertsList([],
new TunnelListEndingReturnFromTunnel(new Identifier(["divertName"]))))
]);
}
[Fact]
public void TestTunnel()
{
var storyNodes = MyParseText("-> tunnelName ->");
storyNodes.ShouldBe([
new MultiDivert(new TunnelsAndDivertsList([new Identifier(["tunnelName"])],
new TunnelListEndingDivert(null)))
]);
}
}

View File

@@ -39,4 +39,4 @@ expression
atn:
[4, 1, 10, 118, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 1, 0, 1, 0, 1, 1, 1, 1, 4, 1, 27, 8, 1, 11, 1, 12, 1, 28, 1, 1, 5, 1, 32, 8, 1, 10, 1, 12, 1, 35, 9, 1, 1, 1, 5, 1, 38, 8, 1, 10, 1, 12, 1, 41, 9, 1, 1, 2, 1, 2, 1, 3, 3, 3, 46, 8, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 5, 4, 54, 8, 4, 10, 4, 12, 4, 57, 9, 4, 1, 4, 3, 4, 60, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 68, 8, 5, 1, 6, 1, 6, 3, 6, 72, 8, 6, 1, 6, 3, 6, 75, 8, 6, 1, 6, 3, 6, 78, 8, 6, 1, 7, 3, 7, 81, 8, 7, 1, 7, 1, 7, 3, 7, 85, 8, 7, 1, 7, 1, 7, 3, 7, 89, 8, 7, 1, 7, 1, 7, 3, 7, 93, 8, 7, 5, 7, 95, 8, 7, 10, 7, 12, 7, 98, 9, 7, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 104, 8, 8, 1, 8, 5, 8, 107, 8, 8, 10, 8, 12, 8, 110, 9, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 0, 0, 11, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0, 0, 125, 0, 22, 1, 0, 0, 0, 2, 24, 1, 0, 0, 0, 4, 42, 1, 0, 0, 0, 6, 45, 1, 0, 0, 0, 8, 59, 1, 0, 0, 0, 10, 67, 1, 0, 0, 0, 12, 69, 1, 0, 0, 0, 14, 80, 1, 0, 0, 0, 16, 99, 1, 0, 0, 0, 18, 113, 1, 0, 0, 0, 20, 115, 1, 0, 0, 0, 22, 23, 3, 2, 1, 0, 23, 1, 1, 0, 0, 0, 24, 33, 3, 4, 2, 0, 25, 27, 5, 10, 0, 0, 26, 25, 1, 0, 0, 0, 27, 28, 1, 0, 0, 0, 28, 26, 1, 0, 0, 0, 28, 29, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 32, 3, 4, 2, 0, 31, 26, 1, 0, 0, 0, 32, 35, 1, 0, 0, 0, 33, 31, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 39, 1, 0, 0, 0, 35, 33, 1, 0, 0, 0, 36, 38, 5, 10, 0, 0, 37, 36, 1, 0, 0, 0, 38, 41, 1, 0, 0, 0, 39, 37, 1, 0, 0, 0, 39, 40, 1, 0, 0, 0, 40, 3, 1, 0, 0, 0, 41, 39, 1, 0, 0, 0, 42, 43, 3, 6, 3, 0, 43, 5, 1, 0, 0, 0, 44, 46, 5, 9, 0, 0, 45, 44, 1, 0, 0, 0, 45, 46, 1, 0, 0, 0, 46, 47, 1, 0, 0, 0, 47, 48, 3, 8, 4, 0, 48, 7, 1, 0, 0, 0, 49, 50, 5, 5, 0, 0, 50, 60, 3, 12, 6, 0, 51, 52, 5, 6, 0, 0, 52, 54, 3, 12, 6, 0, 53, 51, 1, 0, 0, 0, 54, 57, 1, 0, 0, 0, 55, 53, 1, 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 58, 1, 0, 0, 0, 57, 55, 1, 0, 0, 0, 58, 60, 3, 10, 5, 0, 59, 49, 1, 0, 0, 0, 59, 55, 1, 0, 0, 0, 60, 9, 1, 0, 0, 0, 61, 68, 5, 6, 0, 0, 62, 63, 5, 6, 0, 0, 63, 68, 3, 12, 6, 0, 64, 65, 5, 7, 0, 0, 65, 68, 3, 12, 6, 0, 66, 68, 5, 7, 0, 0, 67, 61, 1, 0, 0, 0, 67, 62, 1, 0, 0, 0, 67, 64, 1, 0, 0, 0, 67, 66, 1, 0, 0, 0, 68, 11, 1, 0, 0, 0, 69, 71, 3, 14, 7, 0, 70, 72, 5, 9, 0, 0, 71, 70, 1, 0, 0, 0, 71, 72, 1, 0, 0, 0, 72, 74, 1, 0, 0, 0, 73, 75, 3, 16, 8, 0, 74, 73, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 77, 1, 0, 0, 0, 76, 78, 5, 9, 0, 0, 77, 76, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 13, 1, 0, 0, 0, 79, 81, 5, 9, 0, 0, 80, 79, 1, 0, 0, 0, 80, 81, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 84, 3, 18, 9, 0, 83, 85, 5, 9, 0, 0, 84, 83, 1, 0, 0, 0, 84, 85, 1, 0, 0, 0, 85, 96, 1, 0, 0, 0, 86, 88, 5, 1, 0, 0, 87, 89, 5, 9, 0, 0, 88, 87, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 90, 1, 0, 0, 0, 90, 92, 3, 18, 9, 0, 91, 93, 5, 9, 0, 0, 92, 91, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 95, 1, 0, 0, 0, 94, 86, 1, 0, 0, 0, 95, 98, 1, 0, 0, 0, 96, 94, 1, 0, 0, 0, 96, 97, 1, 0, 0, 0, 97, 15, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 99, 100, 5, 2, 0, 0, 100, 108, 3, 20, 10, 0, 101, 103, 5, 3, 0, 0, 102, 104, 5, 9, 0, 0, 103, 102, 1, 0, 0, 0, 103, 104, 1, 0, 0, 0, 104, 105, 1, 0, 0, 0, 105, 107, 3, 20, 10, 0, 106, 101, 1, 0, 0, 0, 107, 110, 1, 0, 0, 0, 108, 106, 1, 0, 0, 0, 108, 109, 1, 0, 0, 0, 109, 111, 1, 0, 0, 0, 110, 108, 1, 0, 0, 0, 111, 112, 5, 4, 0, 0, 112, 17, 1, 0, 0, 0, 113, 114, 5, 8, 0, 0, 114, 19, 1, 0, 0, 0, 115, 116, 5, 8, 0, 0, 116, 21, 1, 0, 0, 0, 17, 28, 33, 39, 45, 55, 59, 67, 71, 74, 77, 80, 84, 88, 92, 96, 103, 108]
[4, 1, 10, 115, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 1, 0, 1, 0, 1, 1, 1, 1, 4, 1, 27, 8, 1, 11, 1, 12, 1, 28, 1, 1, 5, 1, 32, 8, 1, 10, 1, 12, 1, 35, 9, 1, 1, 1, 5, 1, 38, 8, 1, 10, 1, 12, 1, 41, 9, 1, 1, 2, 1, 2, 1, 3, 3, 3, 46, 8, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 5, 4, 54, 8, 4, 10, 4, 12, 4, 57, 9, 4, 1, 4, 3, 4, 60, 8, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 68, 8, 5, 1, 6, 3, 6, 71, 8, 6, 1, 6, 1, 6, 3, 6, 75, 8, 6, 1, 6, 3, 6, 78, 8, 6, 1, 7, 1, 7, 3, 7, 82, 8, 7, 1, 7, 1, 7, 3, 7, 86, 8, 7, 1, 7, 5, 7, 89, 8, 7, 10, 7, 12, 7, 92, 9, 7, 1, 8, 3, 8, 95, 8, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 101, 8, 8, 1, 8, 5, 8, 104, 8, 8, 10, 8, 12, 8, 107, 9, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 0, 0, 11, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 0, 0, 121, 0, 22, 1, 0, 0, 0, 2, 24, 1, 0, 0, 0, 4, 42, 1, 0, 0, 0, 6, 45, 1, 0, 0, 0, 8, 59, 1, 0, 0, 0, 10, 67, 1, 0, 0, 0, 12, 70, 1, 0, 0, 0, 14, 79, 1, 0, 0, 0, 16, 94, 1, 0, 0, 0, 18, 110, 1, 0, 0, 0, 20, 112, 1, 0, 0, 0, 22, 23, 3, 2, 1, 0, 23, 1, 1, 0, 0, 0, 24, 33, 3, 4, 2, 0, 25, 27, 5, 10, 0, 0, 26, 25, 1, 0, 0, 0, 27, 28, 1, 0, 0, 0, 28, 26, 1, 0, 0, 0, 28, 29, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 32, 3, 4, 2, 0, 31, 26, 1, 0, 0, 0, 32, 35, 1, 0, 0, 0, 33, 31, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 39, 1, 0, 0, 0, 35, 33, 1, 0, 0, 0, 36, 38, 5, 10, 0, 0, 37, 36, 1, 0, 0, 0, 38, 41, 1, 0, 0, 0, 39, 37, 1, 0, 0, 0, 39, 40, 1, 0, 0, 0, 40, 3, 1, 0, 0, 0, 41, 39, 1, 0, 0, 0, 42, 43, 3, 6, 3, 0, 43, 5, 1, 0, 0, 0, 44, 46, 5, 9, 0, 0, 45, 44, 1, 0, 0, 0, 45, 46, 1, 0, 0, 0, 46, 47, 1, 0, 0, 0, 47, 48, 3, 8, 4, 0, 48, 7, 1, 0, 0, 0, 49, 50, 5, 5, 0, 0, 50, 60, 3, 12, 6, 0, 51, 52, 5, 6, 0, 0, 52, 54, 3, 12, 6, 0, 53, 51, 1, 0, 0, 0, 54, 57, 1, 0, 0, 0, 55, 53, 1, 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 58, 1, 0, 0, 0, 57, 55, 1, 0, 0, 0, 58, 60, 3, 10, 5, 0, 59, 49, 1, 0, 0, 0, 59, 55, 1, 0, 0, 0, 60, 9, 1, 0, 0, 0, 61, 62, 5, 6, 0, 0, 62, 68, 3, 12, 6, 0, 63, 64, 5, 7, 0, 0, 64, 68, 3, 12, 6, 0, 65, 68, 5, 6, 0, 0, 66, 68, 5, 7, 0, 0, 67, 61, 1, 0, 0, 0, 67, 63, 1, 0, 0, 0, 67, 65, 1, 0, 0, 0, 67, 66, 1, 0, 0, 0, 68, 11, 1, 0, 0, 0, 69, 71, 5, 9, 0, 0, 70, 69, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 72, 1, 0, 0, 0, 72, 74, 3, 14, 7, 0, 73, 75, 3, 16, 8, 0, 74, 73, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 77, 1, 0, 0, 0, 76, 78, 5, 9, 0, 0, 77, 76, 1, 0, 0, 0, 77, 78, 1, 0, 0, 0, 78, 13, 1, 0, 0, 0, 79, 90, 3, 18, 9, 0, 80, 82, 5, 9, 0, 0, 81, 80, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 83, 1, 0, 0, 0, 83, 85, 5, 1, 0, 0, 84, 86, 5, 9, 0, 0, 85, 84, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 89, 3, 18, 9, 0, 88, 81, 1, 0, 0, 0, 89, 92, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 15, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 93, 95, 5, 9, 0, 0, 94, 93, 1, 0, 0, 0, 94, 95, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 97, 5, 2, 0, 0, 97, 105, 3, 20, 10, 0, 98, 100, 5, 3, 0, 0, 99, 101, 5, 9, 0, 0, 100, 99, 1, 0, 0, 0, 100, 101, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 104, 3, 20, 10, 0, 103, 98, 1, 0, 0, 0, 104, 107, 1, 0, 0, 0, 105, 103, 1, 0, 0, 0, 105, 106, 1, 0, 0, 0, 106, 108, 1, 0, 0, 0, 107, 105, 1, 0, 0, 0, 108, 109, 5, 4, 0, 0, 109, 17, 1, 0, 0, 0, 110, 111, 5, 8, 0, 0, 111, 19, 1, 0, 0, 0, 112, 113, 5, 8, 0, 0, 113, 21, 1, 0, 0, 0, 16, 28, 33, 39, 45, 55, 59, 67, 70, 74, 77, 81, 85, 90, 94, 100, 105]

View File

@@ -112,20 +112,6 @@ public partial class InkBlotAntlrGrammarBaseListener : IInkBlotAntlrGrammarListe
/// <param name="context">The parse tree.</param>
public virtual void ExitMultiDivertArrows([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrowsContext context) { }
/// <summary>
/// Enter a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context) { }
/// <summary>
/// Exit a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context) { }
/// <summary>
/// Enter a parse tree produced by the <c>MultiDivertArrows_tailDivert</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// <para>The default implementation does nothing.</para>
@@ -154,6 +140,20 @@ public partial class InkBlotAntlrGrammarBaseListener : IInkBlotAntlrGrammarListe
/// <param name="context">The parse tree.</param>
public virtual void ExitMultiDivertArrows_tailTunnelWithReplacement([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailTunnelWithReplacementContext context) { }
/// <summary>
/// Enter a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context) { }
/// <summary>
/// Exit a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context) { }
/// <summary>
/// Enter a parse tree produced by the <c>MultiDivertArrows_tailTunnel</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// <para>The default implementation does nothing.</para>

View File

@@ -97,17 +97,6 @@ public partial class InkBlotAntlrGrammarBaseVisitor<Result> : AbstractParseTreeV
/// <return>The visitor result.</return>
public virtual Result VisitMultiDivertArrows([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrowsContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
/// on <paramref name="context"/>.
/// </para>
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
public virtual Result VisitMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by the <c>MultiDivertArrows_tailDivert</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// <para>
@@ -130,6 +119,17 @@ public partial class InkBlotAntlrGrammarBaseVisitor<Result> : AbstractParseTreeV
/// <return>The visitor result.</return>
public virtual Result VisitMultiDivertArrows_tailTunnelWithReplacement([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailTunnelWithReplacementContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
/// on <paramref name="context"/>.
/// </para>
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
public virtual Result VisitMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by the <c>MultiDivertArrows_tailTunnel</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// <para>

View File

@@ -95,18 +95,6 @@ public interface IInkBlotAntlrGrammarListener : IParseTreeListener {
/// <param name="context">The parse tree.</param>
void ExitMultiDivertArrows([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrowsContext context);
/// <summary>
/// Enter a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context);
/// <summary>
/// Exit a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context);
/// <summary>
/// Enter a parse tree produced by the <c>MultiDivertArrows_tailDivert</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// </summary>
@@ -131,6 +119,18 @@ public interface IInkBlotAntlrGrammarListener : IParseTreeListener {
/// <param name="context">The parse tree.</param>
void ExitMultiDivertArrows_tailTunnelWithReplacement([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailTunnelWithReplacementContext context);
/// <summary>
/// Enter a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context);
/// <summary>
/// Exit a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context);
/// <summary>
/// Enter a parse tree produced by the <c>MultiDivertArrows_tailTunnel</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// </summary>

View File

@@ -587,31 +587,31 @@ public partial class InkBlotAntlrGrammarParser : Parser {
ErrorHandler.Sync(this);
switch ( Interpreter.AdaptivePredict(TokenStream,6,Context) ) {
case 1:
_localctx = new MultiDivertArrows_tailDefaultChoiceContext(_localctx);
_localctx = new MultiDivertArrows_tailDivertContext(_localctx);
EnterOuterAlt(_localctx, 1);
{
State = 61;
Match(DIVERT_ARROW);
State = 62;
divertIdentifierWithArguments();
}
break;
case 2:
_localctx = new MultiDivertArrows_tailDivertContext(_localctx);
_localctx = new MultiDivertArrows_tailTunnelWithReplacementContext(_localctx);
EnterOuterAlt(_localctx, 2);
{
State = 62;
Match(DIVERT_ARROW);
State = 63;
Match(TUNNEL_ARROW);
State = 64;
divertIdentifierWithArguments();
}
break;
case 3:
_localctx = new MultiDivertArrows_tailTunnelWithReplacementContext(_localctx);
_localctx = new MultiDivertArrows_tailDefaultChoiceContext(_localctx);
EnterOuterAlt(_localctx, 3);
{
State = 64;
Match(TUNNEL_ARROW);
State = 65;
divertIdentifierWithArguments();
Match(DIVERT_ARROW);
}
break;
case 4:
@@ -677,28 +677,28 @@ public partial class InkBlotAntlrGrammarParser : Parser {
try {
EnterOuterAlt(_localctx, 1);
{
State = 69;
divertIdentifierWithArguments_name();
State = 71;
ErrorHandler.Sync(this);
switch ( Interpreter.AdaptivePredict(TokenStream,7,Context) ) {
case 1:
{
State = 70;
Match(WS);
}
break;
}
State = 74;
State = 70;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
if (_la==T__1) {
if (_la==WS) {
{
State = 69;
Match(WS);
}
}
State = 72;
divertIdentifierWithArguments_name();
State = 74;
ErrorHandler.Sync(this);
switch ( Interpreter.AdaptivePredict(TokenStream,8,Context) ) {
case 1:
{
State = 73;
divertIdentifierWithArguments_arguments();
}
break;
}
State = 77;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
@@ -762,65 +762,48 @@ public partial class InkBlotAntlrGrammarParser : Parser {
EnterRule(_localctx, 14, RULE_divertIdentifierWithArguments_name);
int _la;
try {
int _alt;
EnterOuterAlt(_localctx, 1);
{
State = 80;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
if (_la==WS) {
{
State = 79;
Match(WS);
}
}
State = 82;
State = 79;
identifier();
State = 84;
State = 90;
ErrorHandler.Sync(this);
switch ( Interpreter.AdaptivePredict(TokenStream,11,Context) ) {
case 1:
{
State = 83;
Match(WS);
}
break;
}
State = 96;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
while (_la==T__0) {
{
{
State = 86;
Match(T__0);
State = 88;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
if (_la==WS) {
_alt = Interpreter.AdaptivePredict(TokenStream,12,Context);
while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
State = 87;
Match(WS);
{
State = 81;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
if (_la==WS) {
{
State = 80;
Match(WS);
}
}
}
State = 90;
identifier();
State = 83;
Match(T__0);
State = 85;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
if (_la==WS) {
{
State = 84;
Match(WS);
}
}
State = 87;
identifier();
}
}
}
State = 92;
ErrorHandler.Sync(this);
switch ( Interpreter.AdaptivePredict(TokenStream,13,Context) ) {
case 1:
{
State = 91;
Match(WS);
}
break;
}
}
}
State = 98;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
_alt = Interpreter.AdaptivePredict(TokenStream,12,Context);
}
}
}
@@ -877,37 +860,47 @@ public partial class InkBlotAntlrGrammarParser : Parser {
try {
EnterOuterAlt(_localctx, 1);
{
State = 99;
State = 94;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
if (_la==WS) {
{
State = 93;
Match(WS);
}
}
State = 96;
Match(T__1);
State = 100;
State = 97;
expression();
State = 108;
State = 105;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
while (_la==T__2) {
{
{
State = 101;
State = 98;
Match(T__2);
State = 103;
State = 100;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
if (_la==WS) {
{
State = 102;
State = 99;
Match(WS);
}
}
State = 105;
State = 102;
expression();
}
}
State = 110;
State = 107;
ErrorHandler.Sync(this);
_la = TokenStream.LA(1);
}
State = 111;
State = 108;
Match(T__3);
}
}
@@ -954,7 +947,7 @@ public partial class InkBlotAntlrGrammarParser : Parser {
try {
EnterOuterAlt(_localctx, 1);
{
State = 113;
State = 110;
Match(IDENTIFIER);
}
}
@@ -1001,7 +994,7 @@ public partial class InkBlotAntlrGrammarParser : Parser {
try {
EnterOuterAlt(_localctx, 1);
{
State = 115;
State = 112;
Match(IDENTIFIER);
}
}
@@ -1017,41 +1010,40 @@ public partial class InkBlotAntlrGrammarParser : Parser {
}
private static int[] _serializedATN = {
4,1,10,118,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,
4,1,10,115,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,
7,7,2,8,7,8,2,9,7,9,2,10,7,10,1,0,1,0,1,1,1,1,4,1,27,8,1,11,1,12,1,28,
1,1,5,1,32,8,1,10,1,12,1,35,9,1,1,1,5,1,38,8,1,10,1,12,1,41,9,1,1,2,1,
2,1,3,3,3,46,8,3,1,3,1,3,1,4,1,4,1,4,1,4,5,4,54,8,4,10,4,12,4,57,9,4,1,
4,3,4,60,8,4,1,5,1,5,1,5,1,5,1,5,1,5,3,5,68,8,5,1,6,1,6,3,6,72,8,6,1,6,
3,6,75,8,6,1,6,3,6,78,8,6,1,7,3,7,81,8,7,1,7,1,7,3,7,85,8,7,1,7,1,7,3,
7,89,8,7,1,7,1,7,3,7,93,8,7,5,7,95,8,7,10,7,12,7,98,9,7,1,8,1,8,1,8,1,
8,3,8,104,8,8,1,8,5,8,107,8,8,10,8,12,8,110,9,8,1,8,1,8,1,9,1,9,1,10,1,
10,1,10,0,0,11,0,2,4,6,8,10,12,14,16,18,20,0,0,125,0,22,1,0,0,0,2,24,1,
0,0,0,4,42,1,0,0,0,6,45,1,0,0,0,8,59,1,0,0,0,10,67,1,0,0,0,12,69,1,0,0,
0,14,80,1,0,0,0,16,99,1,0,0,0,18,113,1,0,0,0,20,115,1,0,0,0,22,23,3,2,
1,0,23,1,1,0,0,0,24,33,3,4,2,0,25,27,5,10,0,0,26,25,1,0,0,0,27,28,1,0,
0,0,28,26,1,0,0,0,28,29,1,0,0,0,29,30,1,0,0,0,30,32,3,4,2,0,31,26,1,0,
0,0,32,35,1,0,0,0,33,31,1,0,0,0,33,34,1,0,0,0,34,39,1,0,0,0,35,33,1,0,
0,0,36,38,5,10,0,0,37,36,1,0,0,0,38,41,1,0,0,0,39,37,1,0,0,0,39,40,1,0,
0,0,40,3,1,0,0,0,41,39,1,0,0,0,42,43,3,6,3,0,43,5,1,0,0,0,44,46,5,9,0,
0,45,44,1,0,0,0,45,46,1,0,0,0,46,47,1,0,0,0,47,48,3,8,4,0,48,7,1,0,0,0,
49,50,5,5,0,0,50,60,3,12,6,0,51,52,5,6,0,0,52,54,3,12,6,0,53,51,1,0,0,
0,54,57,1,0,0,0,55,53,1,0,0,0,55,56,1,0,0,0,56,58,1,0,0,0,57,55,1,0,0,
0,58,60,3,10,5,0,59,49,1,0,0,0,59,55,1,0,0,0,60,9,1,0,0,0,61,68,5,6,0,
0,62,63,5,6,0,0,63,68,3,12,6,0,64,65,5,7,0,0,65,68,3,12,6,0,66,68,5,7,
0,0,67,61,1,0,0,0,67,62,1,0,0,0,67,64,1,0,0,0,67,66,1,0,0,0,68,11,1,0,
0,0,69,71,3,14,7,0,70,72,5,9,0,0,71,70,1,0,0,0,71,72,1,0,0,0,72,74,1,0,
0,0,73,75,3,16,8,0,74,73,1,0,0,0,74,75,1,0,0,0,75,77,1,0,0,0,76,78,5,9,
0,0,77,76,1,0,0,0,77,78,1,0,0,0,78,13,1,0,0,0,79,81,5,9,0,0,80,79,1,0,
0,0,80,81,1,0,0,0,81,82,1,0,0,0,82,84,3,18,9,0,83,85,5,9,0,0,84,83,1,0,
0,0,84,85,1,0,0,0,85,96,1,0,0,0,86,88,5,1,0,0,87,89,5,9,0,0,88,87,1,0,
0,0,88,89,1,0,0,0,89,90,1,0,0,0,90,92,3,18,9,0,91,93,5,9,0,0,92,91,1,0,
0,0,92,93,1,0,0,0,93,95,1,0,0,0,94,86,1,0,0,0,95,98,1,0,0,0,96,94,1,0,
0,0,96,97,1,0,0,0,97,15,1,0,0,0,98,96,1,0,0,0,99,100,5,2,0,0,100,108,3,
20,10,0,101,103,5,3,0,0,102,104,5,9,0,0,103,102,1,0,0,0,103,104,1,0,0,
0,104,105,1,0,0,0,105,107,3,20,10,0,106,101,1,0,0,0,107,110,1,0,0,0,108,
106,1,0,0,0,108,109,1,0,0,0,109,111,1,0,0,0,110,108,1,0,0,0,111,112,5,
4,0,0,112,17,1,0,0,0,113,114,5,8,0,0,114,19,1,0,0,0,115,116,5,8,0,0,116,
21,1,0,0,0,17,28,33,39,45,55,59,67,71,74,77,80,84,88,92,96,103,108
4,3,4,60,8,4,1,5,1,5,1,5,1,5,1,5,1,5,3,5,68,8,5,1,6,3,6,71,8,6,1,6,1,6,
3,6,75,8,6,1,6,3,6,78,8,6,1,7,1,7,3,7,82,8,7,1,7,1,7,3,7,86,8,7,1,7,5,
7,89,8,7,10,7,12,7,92,9,7,1,8,3,8,95,8,8,1,8,1,8,1,8,1,8,3,8,101,8,8,1,
8,5,8,104,8,8,10,8,12,8,107,9,8,1,8,1,8,1,9,1,9,1,10,1,10,1,10,0,0,11,
0,2,4,6,8,10,12,14,16,18,20,0,0,121,0,22,1,0,0,0,2,24,1,0,0,0,4,42,1,0,
0,0,6,45,1,0,0,0,8,59,1,0,0,0,10,67,1,0,0,0,12,70,1,0,0,0,14,79,1,0,0,
0,16,94,1,0,0,0,18,110,1,0,0,0,20,112,1,0,0,0,22,23,3,2,1,0,23,1,1,0,0,
0,24,33,3,4,2,0,25,27,5,10,0,0,26,25,1,0,0,0,27,28,1,0,0,0,28,26,1,0,0,
0,28,29,1,0,0,0,29,30,1,0,0,0,30,32,3,4,2,0,31,26,1,0,0,0,32,35,1,0,0,
0,33,31,1,0,0,0,33,34,1,0,0,0,34,39,1,0,0,0,35,33,1,0,0,0,36,38,5,10,0,
0,37,36,1,0,0,0,38,41,1,0,0,0,39,37,1,0,0,0,39,40,1,0,0,0,40,3,1,0,0,0,
41,39,1,0,0,0,42,43,3,6,3,0,43,5,1,0,0,0,44,46,5,9,0,0,45,44,1,0,0,0,45,
46,1,0,0,0,46,47,1,0,0,0,47,48,3,8,4,0,48,7,1,0,0,0,49,50,5,5,0,0,50,60,
3,12,6,0,51,52,5,6,0,0,52,54,3,12,6,0,53,51,1,0,0,0,54,57,1,0,0,0,55,53,
1,0,0,0,55,56,1,0,0,0,56,58,1,0,0,0,57,55,1,0,0,0,58,60,3,10,5,0,59,49,
1,0,0,0,59,55,1,0,0,0,60,9,1,0,0,0,61,62,5,6,0,0,62,68,3,12,6,0,63,64,
5,7,0,0,64,68,3,12,6,0,65,68,5,6,0,0,66,68,5,7,0,0,67,61,1,0,0,0,67,63,
1,0,0,0,67,65,1,0,0,0,67,66,1,0,0,0,68,11,1,0,0,0,69,71,5,9,0,0,70,69,
1,0,0,0,70,71,1,0,0,0,71,72,1,0,0,0,72,74,3,14,7,0,73,75,3,16,8,0,74,73,
1,0,0,0,74,75,1,0,0,0,75,77,1,0,0,0,76,78,5,9,0,0,77,76,1,0,0,0,77,78,
1,0,0,0,78,13,1,0,0,0,79,90,3,18,9,0,80,82,5,9,0,0,81,80,1,0,0,0,81,82,
1,0,0,0,82,83,1,0,0,0,83,85,5,1,0,0,84,86,5,9,0,0,85,84,1,0,0,0,85,86,
1,0,0,0,86,87,1,0,0,0,87,89,3,18,9,0,88,81,1,0,0,0,89,92,1,0,0,0,90,88,
1,0,0,0,90,91,1,0,0,0,91,15,1,0,0,0,92,90,1,0,0,0,93,95,5,9,0,0,94,93,
1,0,0,0,94,95,1,0,0,0,95,96,1,0,0,0,96,97,5,2,0,0,97,105,3,20,10,0,98,
100,5,3,0,0,99,101,5,9,0,0,100,99,1,0,0,0,100,101,1,0,0,0,101,102,1,0,
0,0,102,104,3,20,10,0,103,98,1,0,0,0,104,107,1,0,0,0,105,103,1,0,0,0,105,
106,1,0,0,0,106,108,1,0,0,0,107,105,1,0,0,0,108,109,5,4,0,0,109,17,1,0,
0,0,110,111,5,8,0,0,111,19,1,0,0,0,112,113,5,8,0,0,113,21,1,0,0,0,16,28,
33,39,45,55,59,67,70,74,77,81,85,90,94,100,105
};
public static readonly ATN _ATN =

View File

@@ -70,13 +70,6 @@ public interface IInkBlotAntlrGrammarVisitor<Result> : IParseTreeVisitor<Result>
/// <return>The visitor result.</return>
Result VisitMultiDivertArrows([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrowsContext context);
/// <summary>
/// Visit a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context);
/// <summary>
/// Visit a parse tree produced by the <c>MultiDivertArrows_tailDivert</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// </summary>
@@ -91,6 +84,13 @@ public interface IInkBlotAntlrGrammarVisitor<Result> : IParseTreeVisitor<Result>
/// <return>The visitor result.</return>
Result VisitMultiDivertArrows_tailTunnelWithReplacement([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailTunnelWithReplacementContext context);
/// <summary>
/// Visit a parse tree produced by the <c>MultiDivertArrows_tailDefaultChoice</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitMultiDivertArrows_tailDefaultChoice([NotNull] InkBlotAntlrGrammarParser.MultiDivertArrows_tailDefaultChoiceContext context);
/// <summary>
/// Visit a parse tree produced by the <c>MultiDivertArrows_tailTunnel</c>
/// labeled alternative in <see cref="InkBlotAntlrGrammarParser.multiDivertArrows_tail"/>.
/// </summary>

View File

@@ -94,24 +94,25 @@ multiDivert_withoutWS:
;
multiDivertArrows_tail:
DIVERT_ARROW # MultiDivertArrows_tailDefaultChoice
| DIVERT_ARROW divertIdentifierWithArguments # MultiDivertArrows_tailDivert
DIVERT_ARROW divertIdentifierWithArguments # MultiDivertArrows_tailDivert
| TUNNEL_ARROW divertIdentifierWithArguments # MultiDivertArrows_tailTunnelWithReplacement
| DIVERT_ARROW # MultiDivertArrows_tailDefaultChoice
| TUNNEL_ARROW # MultiDivertArrows_tailTunnel
;
divertIdentifierWithArguments:
divertIdentifierWithArguments_name
WS?
divertIdentifierWithArguments_name
divertIdentifierWithArguments_arguments?
WS?
;
divertIdentifierWithArguments_name:
WS? identifier WS? ('.' WS? identifier WS? )*
identifier (WS? '.' WS? identifier )*
;
divertIdentifierWithArguments_arguments:
WS?
'('
expression (',' WS? expression)*
')'

View File

@@ -4,18 +4,8 @@ namespace InkBlot.ParseHierarchy;
[GenerateOneOf]
public partial class
MultiDivert : OneOfBase<ThreadDivert, DivertsListWithReturnFromTunnel, DivertsListWithoutReturnFromTunnel>,
IStoryNode
{
public override bool Equals(object? obj)
{
if (obj is OneOfBase<ThreadDivert, DivertsListWithReturnFromTunnel, DivertsListWithoutReturnFromTunnel> divert)
Console.WriteLine("it actually is fuck");
var rv = base.Equals(obj);
return rv;
}
}
MultiDivert : OneOfBase<ThreadDivert, TunnelsAndDivertsList>,
IStoryNode;
public record Identifier(string[] Elements /* TODO: expressions */)
{
@@ -44,14 +34,38 @@ public record ThreadDivert(Identifier Identifier) : IStoryNode
}
}
// -> ... ->-> // return from tunnel
// or
// -> ... ->-> tunnelReplacement // return from tunnel, but replace destination
public record DivertsListWithReturnFromTunnel(Identifier[] Identifiers, Identifier? TunnelReplacement)
: IStoryNode;
[GenerateOneOf]
public partial class TunnelListEnding : OneOfBase<TunnelListEndingDivert, TunnelListEndingReturnFromTunnel>;
// -> ... -> div // not a tunnel
// or
// -> ... -> div -> // is tunnel
public record DivertsListWithoutReturnFromTunnel(Identifier[] Identifiers, bool IsTunnel)
: IStoryNode;
public record TunnelListEndingDivert(Identifier? Divert);
public record TunnelListEndingReturnFromTunnel(Identifier? Divert);
/// <summary>
/// A sequence of zero or more tunnels, potentially ending in a divert, and potentially providing a tunnel replacement.
/// <code>
/// -> // [], divert(null)
/// ->-> // [], returnFromTunnel(null)
/// -> divertName // [], divert(divertName)
/// ->-> divertName // [], returnFromTunnel(divertName)
/// -> tunnelName -> // [tunnelName], divert(null)
/// -> tunnelName -> divertName // [tunnelName], divert(divertName)
/// -> tunnelName1 -> tunnelName2 -> // [tunnelName1, tunnelName2], divert(null)
/// -> tunnelName1 -> tunnelName2 ->-> // [tunnelName1, tunnelName2], returnFromTunnel(null)
/// -> tunnelName1 -> tunnelName2 ->-> divertName // [tunnelName1, tunnelName2], returnFromTunnel(divertName)
/// </code>
/// </summary>
public record TunnelsAndDivertsList(Identifier[] TunnelIdentifiers, TunnelListEnding Ending)
: IStoryNode
{
public virtual bool Equals(TunnelsAndDivertsList? other)
{
return other is not null && Ending.Equals(other.Ending) &&
TunnelIdentifiers.SequenceEqual(other.TunnelIdentifiers);
}
public override int GetHashCode()
{
return HashCode.Combine(TunnelIdentifiers, Ending);
}
}

View File

@@ -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