feat: finally able to overcome the base of the base of this f*cked up mess

This commit is contained in:
mattia
2025-03-01 17:06:56 +01:00
parent eed28168ad
commit 6ee8051004
20 changed files with 518 additions and 2306 deletions

View File

@@ -20,12 +20,15 @@ public class ContentTextTest
var fileReader = new InMemoryFileReader([
("main.ink", inkInput)
]);
var parser = new InkBlotParser();
using var loggerFactory = Helpers.GetLoggerFactory();
var (story, diagnostics) = InkBlotParser.Parse(fileReader, loggerFactory, "main.ink");
var (story, diagnosticsEnumerable) = InkBlotParser.Parse(fileReader, loggerFactory, "main.ink");
var diagnostics = diagnosticsEnumerable.ToArray();
// check the diagnostic counts match
diagnostics.Count().ShouldBe(numErrors);
if (numErrors == 0)
diagnostics.ShouldBe([]);
else
diagnostics.Count().ShouldBe(numErrors);
// check the contents match (only if there was no diagnostic)
if (numErrors != 0) return;

View File

@@ -5,23 +5,36 @@ namespace InkBlot.Tests;
public class LexerTest
{
private readonly TokenEqualityComparer _tokenEqualityComparer = new();
private IToken T(string text, int type)
{
return new SimpleToken(text, type);
}
[Fact]
public void TestSimpleTokens()
{
var tokens = GetTokens("testTest15");
tokens.ShouldBe([
T("testTest15", InkBlotAntlrGrammarLexer.IDENTIFIER),
T("<EOF>", InkBlotAntlrGrammarLexer.Eof)
], _tokenEqualityComparer);
}
[Fact]
public void TestDivertForLexer()
{
var divertTokens = GetTokens("<- threadName");
divertTokens.ShouldSatisfyAllConditions(
() => divertTokens[0].Text.ShouldBe("<-"),
() => divertTokens[0].Type.ShouldBe(InkBlotAntlrGrammarLexer.THREAD_ARROW),
() => divertTokens[1].Text.ShouldBe(" "),
() => divertTokens[1].Type.ShouldBe(InkBlotAntlrGrammarLexer.WS),
() => divertTokens[2].Text.ShouldBe("threadName"),
() => divertTokens[2].Type.ShouldBe(InkBlotAntlrGrammarLexer.IDENTIFIER),
() => divertTokens[3].Text.ShouldBe("<EOF>"),
() => divertTokens[3].Type.ShouldBe(InkBlotAntlrGrammarLexer.Eof)
);
divertTokens.ShouldBe([
T("<-", InkBlotAntlrGrammarLexer.THREAD_ARROW),
T(" ", InkBlotAntlrGrammarLexer.WS),
T("threadName", InkBlotAntlrGrammarLexer.IDENTIFIER),
T("<EOF>", InkBlotAntlrGrammarLexer.Eof)
], _tokenEqualityComparer);
}
private IList<IToken> GetTokens(string text)
private static IList<IToken> GetTokens(string text)
{
var fileReader = new InMemoryFileReader([
("main.ink", text)
@@ -31,4 +44,39 @@ public class LexerTest
var tokens = tokensStream.GetTokens();
return tokens;
}
private class TokenEqualityComparer : IEqualityComparer<IToken>
{
public bool Equals(IToken? x, IToken? y)
{
if (ReferenceEquals(x, y)) return true;
if (x is null) return false;
if (y is null) return false;
return x.Text == y.Text && x.Type == y.Type;
}
public int GetHashCode(IToken obj)
{
return HashCode.Combine(obj.Text, obj.Type);
}
}
private class SimpleToken(string text, int type) : IToken
{
public string Text { get; } = text;
public int Type { get; } = type;
public int Line => 0;
public int Column => 0;
public int Channel => 0;
public int TokenIndex => 0;
public int StartIndex => 0;
public int StopIndex => 0;
public ITokenSource TokenSource => null!;
public ICharStream InputStream => null!;
public override string ToString()
{
return $"['{Text}',<{Type}>]";
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -2,33 +2,16 @@ T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
WS=7
NL=8
MULTILINE_WS=9
CONTENT_TEXT_NO_ESCAPE_SIMPLE=10
INLINE_LOGIC_START=11
INLINE_LOGIC_END=12
SEQUENCE_TYPE_SYMBOL_ANNOTATION=13
ONCE=14
CYCLE=15
SHUFFLE=16
STOPPING=17
SHUFFLE_ONCE=18
SHUFFLE_STOPPING=19
THREAD_ARROW=20
DIVERT_ARROW=21
TUNNEL_ARROW=22
IDENTIFIER=23
'('=1
','=2
')'=3
'.'=4
'-'=5
'|'=6
'{'=11
'}'=12
'<-'=20
'->'=21
'->->'=22
THREAD_ARROW=5
DIVERT_ARROW=6
TUNNEL_ARROW=7
IDENTIFIER=8
WS=9
NL=10
'.'=1
'('=2
','=3
')'=4
'<-'=5
'->'=6
'->->'=7

View File

@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
// Generated from C:/Users/mbelletti/RiderProjects/inkblot/InkBlot/InkBlotAntlrGrammar.g4 by ANTLR 4.13.2
// Generated from E:/ProgettiUnity/InkAntlr/InkBlot/InkBlot/InkBlotAntlrGrammar.g4 by ANTLR 4.13.2
// Unreachable code detected
#pragma warning disable 0162
@@ -72,102 +72,6 @@ public partial class InkBlotAntlrGrammarBaseListener : IInkBlotAntlrGrammarListe
/// <param name="context">The parse tree.</param>
public virtual void ExitTopLevelStatement([NotNull] InkBlotAntlrGrammarParser.TopLevelStatementContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.knotLevelStatements"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterKnotLevelStatements([NotNull] InkBlotAntlrGrammarParser.KnotLevelStatementsContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.knotLevelStatements"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitKnotLevelStatements([NotNull] InkBlotAntlrGrammarParser.KnotLevelStatementsContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.stitchLevelStatements"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterStitchLevelStatements([NotNull] InkBlotAntlrGrammarParser.StitchLevelStatementsContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.stitchLevelStatements"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitStitchLevelStatements([NotNull] InkBlotAntlrGrammarParser.StitchLevelStatementsContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerBlockLevelStatements"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterInnerBlockLevelStatements([NotNull] InkBlotAntlrGrammarParser.InnerBlockLevelStatementsContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerBlockLevelStatements"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitInnerBlockLevelStatements([NotNull] InkBlotAntlrGrammarParser.InnerBlockLevelStatementsContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.contentText"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterContentText([NotNull] InkBlotAntlrGrammarParser.ContentTextContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.contentText"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitContentText([NotNull] InkBlotAntlrGrammarParser.ContentTextContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.mixedTextAndLogic"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterMixedTextAndLogic([NotNull] InkBlotAntlrGrammarParser.MixedTextAndLogicContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.mixedTextAndLogic"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitMixedTextAndLogic([NotNull] InkBlotAntlrGrammarParser.MixedTextAndLogicContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogicOrGlueOrTagStart"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterInlineLogicOrGlueOrTagStart([NotNull] InkBlotAntlrGrammarParser.InlineLogicOrGlueOrTagStartContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogicOrGlueOrTagStart"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitInlineLogicOrGlueOrTagStart([NotNull] InkBlotAntlrGrammarParser.InlineLogicOrGlueOrTagStartContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogic"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterInlineLogic([NotNull] InkBlotAntlrGrammarParser.InlineLogicContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogic"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitInlineLogic([NotNull] InkBlotAntlrGrammarParser.InlineLogicContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerLogic"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterInnerLogic([NotNull] InkBlotAntlrGrammarParser.InnerLogicContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerLogic"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitInnerLogic([NotNull] InkBlotAntlrGrammarParser.InnerLogicContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.multiDivert"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
@@ -323,66 +227,6 @@ public partial class InkBlotAntlrGrammarBaseListener : IInkBlotAntlrGrammarListe
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitExpression([NotNull] InkBlotAntlrGrammarParser.ExpressionContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.sequenceTypeAnnotation"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterSequenceTypeAnnotation([NotNull] InkBlotAntlrGrammarParser.SequenceTypeAnnotationContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.sequenceTypeAnnotation"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitSequenceTypeAnnotation([NotNull] InkBlotAntlrGrammarParser.SequenceTypeAnnotationContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerSequenceObjects"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterInnerSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerSequenceObjectsContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerSequenceObjects"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitInnerSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerSequenceObjectsContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerMultilineSequenceObjects"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterInnerMultilineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerMultilineSequenceObjectsContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerMultilineSequenceObjects"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitInnerMultilineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerMultilineSequenceObjectsContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.singleMultilineSequenceElement"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterSingleMultilineSequenceElement([NotNull] InkBlotAntlrGrammarParser.SingleMultilineSequenceElementContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.singleMultilineSequenceElement"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitSingleMultilineSequenceElement([NotNull] InkBlotAntlrGrammarParser.SingleMultilineSequenceElementContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerInlineSequenceObjects"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterInnerInlineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerInlineSequenceObjectsContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerInlineSequenceObjects"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitInnerInlineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerInlineSequenceObjectsContext context) { }
/// <inheritdoc/>
/// <remarks>The default implementation does nothing.</remarks>

View File

@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
// Generated from C:/Users/mbelletti/RiderProjects/inkblot/InkBlot/InkBlotAntlrGrammar.g4 by ANTLR 4.13.2
// Generated from E:/ProgettiUnity/InkAntlr/InkBlot/InkBlot/InkBlotAntlrGrammar.g4 by ANTLR 4.13.2
// Unreachable code detected
#pragma warning disable 0162
@@ -65,86 +65,6 @@ public partial class InkBlotAntlrGrammarBaseVisitor<Result> : AbstractParseTreeV
/// <return>The visitor result.</return>
public virtual Result VisitTopLevelStatement([NotNull] InkBlotAntlrGrammarParser.TopLevelStatementContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.knotLevelStatements"/>.
/// <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 VisitKnotLevelStatements([NotNull] InkBlotAntlrGrammarParser.KnotLevelStatementsContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.stitchLevelStatements"/>.
/// <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 VisitStitchLevelStatements([NotNull] InkBlotAntlrGrammarParser.StitchLevelStatementsContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerBlockLevelStatements"/>.
/// <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 VisitInnerBlockLevelStatements([NotNull] InkBlotAntlrGrammarParser.InnerBlockLevelStatementsContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.contentText"/>.
/// <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 VisitContentText([NotNull] InkBlotAntlrGrammarParser.ContentTextContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.mixedTextAndLogic"/>.
/// <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 VisitMixedTextAndLogic([NotNull] InkBlotAntlrGrammarParser.MixedTextAndLogicContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogicOrGlueOrTagStart"/>.
/// <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 VisitInlineLogicOrGlueOrTagStart([NotNull] InkBlotAntlrGrammarParser.InlineLogicOrGlueOrTagStartContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogic"/>.
/// <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 VisitInlineLogic([NotNull] InkBlotAntlrGrammarParser.InlineLogicContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerLogic"/>.
/// <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 VisitInnerLogic([NotNull] InkBlotAntlrGrammarParser.InnerLogicContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.multiDivert"/>.
/// <para>
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
@@ -270,54 +190,4 @@ public partial class InkBlotAntlrGrammarBaseVisitor<Result> : AbstractParseTreeV
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
public virtual Result VisitExpression([NotNull] InkBlotAntlrGrammarParser.ExpressionContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.sequenceTypeAnnotation"/>.
/// <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 VisitSequenceTypeAnnotation([NotNull] InkBlotAntlrGrammarParser.SequenceTypeAnnotationContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerSequenceObjects"/>.
/// <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 VisitInnerSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerSequenceObjectsContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerMultilineSequenceObjects"/>.
/// <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 VisitInnerMultilineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerMultilineSequenceObjectsContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.singleMultilineSequenceElement"/>.
/// <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 VisitSingleMultilineSequenceElement([NotNull] InkBlotAntlrGrammarParser.SingleMultilineSequenceElementContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerInlineSequenceObjects"/>.
/// <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 VisitInnerInlineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerInlineSequenceObjectsContext context) { return VisitChildren(context); }
}

View File

@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
// Generated from C:/Users/mbelletti/RiderProjects/inkblot/InkBlot/InkBlotAntlrGrammar.g4 by ANTLR 4.13.2
// Generated from E:/ProgettiUnity/InkAntlr/InkBlot/InkBlot/InkBlotAntlrGrammar.g4 by ANTLR 4.13.2
// Unreachable code detected
#pragma warning disable 0162
@@ -33,11 +33,8 @@ public partial class InkBlotAntlrGrammarLexer : Lexer {
protected static DFA[] decisionToDFA;
protected static PredictionContextCache sharedContextCache = new PredictionContextCache();
public const int
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, WS=7, NL=8, MULTILINE_WS=9,
CONTENT_TEXT_NO_ESCAPE_SIMPLE=10, INLINE_LOGIC_START=11, INLINE_LOGIC_END=12,
SEQUENCE_TYPE_SYMBOL_ANNOTATION=13, ONCE=14, CYCLE=15, SHUFFLE=16, STOPPING=17,
SHUFFLE_ONCE=18, SHUFFLE_STOPPING=19, THREAD_ARROW=20, DIVERT_ARROW=21,
TUNNEL_ARROW=22, IDENTIFIER=23;
T__0=1, T__1=2, T__2=3, T__3=4, THREAD_ARROW=5, DIVERT_ARROW=6, TUNNEL_ARROW=7,
IDENTIFIER=8, WS=9, NL=10;
public static string[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
@@ -47,11 +44,8 @@ public partial class InkBlotAntlrGrammarLexer : Lexer {
};
public static readonly string[] ruleNames = {
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "WS", "NL", "MULTILINE_WS",
"CONTENT_TEXT_NO_ESCAPE_SIMPLE", "INLINE_LOGIC_START", "INLINE_LOGIC_END",
"SEQUENCE_TYPE_SYMBOL_ANNOTATION", "ONCE", "CYCLE", "SHUFFLE", "STOPPING",
"SHUFFLE_ONCE", "SHUFFLE_STOPPING", "THREAD_ARROW", "DIVERT_ARROW", "TUNNEL_ARROW",
"IDENTIFIER"
"T__0", "T__1", "T__2", "T__3", "THREAD_ARROW", "DIVERT_ARROW", "TUNNEL_ARROW",
"IDENTIFIER", "WS", "NL"
};
@@ -65,16 +59,11 @@ public partial class InkBlotAntlrGrammarLexer : Lexer {
}
private static readonly string[] _LiteralNames = {
null, "'('", "','", "')'", "'.'", "'-'", "'|'", null, null, null, null,
"'{'", "'}'", null, null, null, null, null, null, null, "'<-'", "'->'",
"'->->'"
null, "'.'", "'('", "','", "')'", "'<-'", "'->'", "'->->'"
};
private static readonly string[] _SymbolicNames = {
null, null, null, null, null, null, null, "WS", "NL", "MULTILINE_WS",
"CONTENT_TEXT_NO_ESCAPE_SIMPLE", "INLINE_LOGIC_START", "INLINE_LOGIC_END",
"SEQUENCE_TYPE_SYMBOL_ANNOTATION", "ONCE", "CYCLE", "SHUFFLE", "STOPPING",
"SHUFFLE_ONCE", "SHUFFLE_STOPPING", "THREAD_ARROW", "DIVERT_ARROW", "TUNNEL_ARROW",
"IDENTIFIER"
null, null, null, null, null, "THREAD_ARROW", "DIVERT_ARROW", "TUNNEL_ARROW",
"IDENTIFIER", "WS", "NL"
};
public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames);
@@ -103,85 +92,25 @@ public partial class InkBlotAntlrGrammarLexer : Lexer {
decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i);
}
}
public override bool Sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
switch (ruleIndex) {
case 9 : return CONTENT_TEXT_NO_ESCAPE_SIMPLE_sempred(_localctx, predIndex);
}
return true;
}
private bool CONTENT_TEXT_NO_ESCAPE_SIMPLE_sempred(RuleContext _localctx, int predIndex) {
switch (predIndex) {
case 0: return InputStream.LA(1) != '>' ;
}
return true;
}
private static int[] _serializedATN = {
4,0,23,198,6,-1,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,2,11,7,11,2,12,7,12,2,13,7,13,2,14,
7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,
7,21,2,22,7,22,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,4,6,
61,8,6,11,6,12,6,62,1,7,3,7,66,8,7,1,7,3,7,69,8,7,1,7,1,7,1,8,4,8,74,8,
8,11,8,12,8,75,1,9,1,9,1,9,1,9,1,9,4,9,83,8,9,11,9,12,9,84,1,10,1,10,1,
11,1,11,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,3,13,99,8,13,1,13,1,13,
1,14,1,14,1,14,1,14,1,14,1,14,1,14,3,14,110,8,14,1,14,1,14,1,15,1,15,1,
15,1,15,1,15,1,15,1,15,1,15,1,15,3,15,123,8,15,1,15,1,15,1,16,1,16,1,16,
1,16,1,16,1,16,1,16,1,16,1,16,1,16,3,16,137,8,16,1,16,1,16,1,17,1,17,1,
17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,3,17,156,
8,17,1,17,1,17,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,
1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,3,18,179,8,18,1,18,1,18,1,19,1,
19,1,19,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,22,4,22,195,8,22,11,
22,12,22,196,0,0,23,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,
23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,
1,0,5,2,0,9,9,32,32,6,0,10,10,13,13,32,32,35,60,92,92,123,125,1,0,0,65535,
4,0,32,33,36,36,38,38,126,126,4,0,48,57,65,90,95,95,97,122,211,0,1,1,0,
0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,
1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,
0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,
1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,
0,1,47,1,0,0,0,3,49,1,0,0,0,5,51,1,0,0,0,7,53,1,0,0,0,9,55,1,0,0,0,11,
57,1,0,0,0,13,60,1,0,0,0,15,65,1,0,0,0,17,73,1,0,0,0,19,82,1,0,0,0,21,
86,1,0,0,0,23,88,1,0,0,0,25,90,1,0,0,0,27,92,1,0,0,0,29,102,1,0,0,0,31,
113,1,0,0,0,33,126,1,0,0,0,35,140,1,0,0,0,37,159,1,0,0,0,39,182,1,0,0,
0,41,185,1,0,0,0,43,188,1,0,0,0,45,194,1,0,0,0,47,48,5,40,0,0,48,2,1,0,
0,0,49,50,5,44,0,0,50,4,1,0,0,0,51,52,5,41,0,0,52,6,1,0,0,0,53,54,5,46,
0,0,54,8,1,0,0,0,55,56,5,45,0,0,56,10,1,0,0,0,57,58,5,124,0,0,58,12,1,
0,0,0,59,61,7,0,0,0,60,59,1,0,0,0,61,62,1,0,0,0,62,60,1,0,0,0,62,63,1,
0,0,0,63,14,1,0,0,0,64,66,3,13,6,0,65,64,1,0,0,0,65,66,1,0,0,0,66,68,1,
0,0,0,67,69,5,13,0,0,68,67,1,0,0,0,68,69,1,0,0,0,69,70,1,0,0,0,70,71,5,
10,0,0,71,16,1,0,0,0,72,74,3,15,7,0,73,72,1,0,0,0,74,75,1,0,0,0,75,73,
1,0,0,0,75,76,1,0,0,0,76,18,1,0,0,0,77,83,8,1,0,0,78,79,5,92,0,0,79,83,
7,2,0,0,80,81,5,45,0,0,81,83,4,9,0,0,82,77,1,0,0,0,82,78,1,0,0,0,82,80,
1,0,0,0,83,84,1,0,0,0,84,82,1,0,0,0,84,85,1,0,0,0,85,20,1,0,0,0,86,87,
5,123,0,0,87,22,1,0,0,0,88,89,5,125,0,0,89,24,1,0,0,0,90,91,7,3,0,0,91,
26,1,0,0,0,92,93,5,111,0,0,93,94,5,110,0,0,94,95,5,99,0,0,95,96,5,101,
0,0,96,98,1,0,0,0,97,99,3,13,6,0,98,97,1,0,0,0,98,99,1,0,0,0,99,100,1,
0,0,0,100,101,5,58,0,0,101,28,1,0,0,0,102,103,5,99,0,0,103,104,5,121,0,
0,104,105,5,99,0,0,105,106,5,108,0,0,106,107,5,101,0,0,107,109,1,0,0,0,
108,110,3,13,6,0,109,108,1,0,0,0,109,110,1,0,0,0,110,111,1,0,0,0,111,112,
5,58,0,0,112,30,1,0,0,0,113,114,5,115,0,0,114,115,5,104,0,0,115,116,5,
117,0,0,116,117,5,102,0,0,117,118,5,102,0,0,118,119,5,108,0,0,119,120,
5,101,0,0,120,122,1,0,0,0,121,123,3,13,6,0,122,121,1,0,0,0,122,123,1,0,
0,0,123,124,1,0,0,0,124,125,5,58,0,0,125,32,1,0,0,0,126,127,5,115,0,0,
127,128,5,116,0,0,128,129,5,111,0,0,129,130,5,112,0,0,130,131,5,112,0,
0,131,132,5,105,0,0,132,133,5,110,0,0,133,134,5,103,0,0,134,136,1,0,0,
0,135,137,3,13,6,0,136,135,1,0,0,0,136,137,1,0,0,0,137,138,1,0,0,0,138,
139,5,58,0,0,139,34,1,0,0,0,140,141,5,115,0,0,141,142,5,104,0,0,142,143,
5,117,0,0,143,144,5,102,0,0,144,145,5,102,0,0,145,146,5,108,0,0,146,147,
5,101,0,0,147,148,1,0,0,0,148,149,3,13,6,0,149,150,5,111,0,0,150,151,5,
110,0,0,151,152,5,99,0,0,152,153,5,101,0,0,153,155,1,0,0,0,154,156,3,13,
6,0,155,154,1,0,0,0,155,156,1,0,0,0,156,157,1,0,0,0,157,158,5,58,0,0,158,
36,1,0,0,0,159,160,5,115,0,0,160,161,5,104,0,0,161,162,5,117,0,0,162,163,
5,102,0,0,163,164,5,102,0,0,164,165,5,108,0,0,165,166,5,101,0,0,166,167,
1,0,0,0,167,168,3,13,6,0,168,169,5,115,0,0,169,170,5,116,0,0,170,171,5,
111,0,0,171,172,5,112,0,0,172,173,5,112,0,0,173,174,5,105,0,0,174,175,
5,110,0,0,175,176,5,103,0,0,176,178,1,0,0,0,177,179,3,13,6,0,178,177,1,
0,0,0,178,179,1,0,0,0,179,180,1,0,0,0,180,181,5,58,0,0,181,38,1,0,0,0,
182,183,5,60,0,0,183,184,5,45,0,0,184,40,1,0,0,0,185,186,5,45,0,0,186,
187,5,62,0,0,187,42,1,0,0,0,188,189,5,45,0,0,189,190,5,62,0,0,190,191,
5,45,0,0,191,192,5,62,0,0,192,44,1,0,0,0,193,195,7,4,0,0,194,193,1,0,0,
0,195,196,1,0,0,0,196,194,1,0,0,0,196,197,1,0,0,0,197,46,1,0,0,0,14,0,
62,65,68,75,82,84,98,109,122,136,155,178,196,0
4,0,10,58,6,-1,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,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,4,1,4,1,4,1,
5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,7,4,7,42,8,7,11,7,12,7,43,1,8,4,8,47,8,
8,11,8,12,8,48,1,9,3,9,52,8,9,1,9,3,9,55,8,9,1,9,1,9,0,0,10,1,1,3,2,5,
3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,1,0,2,4,0,48,57,65,90,95,95,97,122,
2,0,9,9,32,32,61,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,
0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,
1,21,1,0,0,0,3,23,1,0,0,0,5,25,1,0,0,0,7,27,1,0,0,0,9,29,1,0,0,0,11,32,
1,0,0,0,13,35,1,0,0,0,15,41,1,0,0,0,17,46,1,0,0,0,19,51,1,0,0,0,21,22,
5,46,0,0,22,2,1,0,0,0,23,24,5,40,0,0,24,4,1,0,0,0,25,26,5,44,0,0,26,6,
1,0,0,0,27,28,5,41,0,0,28,8,1,0,0,0,29,30,5,60,0,0,30,31,5,45,0,0,31,10,
1,0,0,0,32,33,5,45,0,0,33,34,5,62,0,0,34,12,1,0,0,0,35,36,5,45,0,0,36,
37,5,62,0,0,37,38,5,45,0,0,38,39,5,62,0,0,39,14,1,0,0,0,40,42,7,0,0,0,
41,40,1,0,0,0,42,43,1,0,0,0,43,41,1,0,0,0,43,44,1,0,0,0,44,16,1,0,0,0,
45,47,7,1,0,0,46,45,1,0,0,0,47,48,1,0,0,0,48,46,1,0,0,0,48,49,1,0,0,0,
49,18,1,0,0,0,50,52,3,17,8,0,51,50,1,0,0,0,51,52,1,0,0,0,52,54,1,0,0,0,
53,55,5,13,0,0,54,53,1,0,0,0,54,55,1,0,0,0,55,56,1,0,0,0,56,57,5,10,0,
0,57,20,1,0,0,0,5,0,43,48,51,54,0
};
public static readonly ATN _ATN =

File diff suppressed because one or more lines are too long

View File

@@ -2,33 +2,16 @@ T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
WS=7
NL=8
MULTILINE_WS=9
CONTENT_TEXT_NO_ESCAPE_SIMPLE=10
INLINE_LOGIC_START=11
INLINE_LOGIC_END=12
SEQUENCE_TYPE_SYMBOL_ANNOTATION=13
ONCE=14
CYCLE=15
SHUFFLE=16
STOPPING=17
SHUFFLE_ONCE=18
SHUFFLE_STOPPING=19
THREAD_ARROW=20
DIVERT_ARROW=21
TUNNEL_ARROW=22
IDENTIFIER=23
'('=1
','=2
')'=3
'.'=4
'-'=5
'|'=6
'{'=11
'}'=12
'<-'=20
'->'=21
'->->'=22
THREAD_ARROW=5
DIVERT_ARROW=6
TUNNEL_ARROW=7
IDENTIFIER=8
WS=9
NL=10
'.'=1
'('=2
','=3
')'=4
'<-'=5
'->'=6
'->->'=7

View File

@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
// Generated from C:/Users/mbelletti/RiderProjects/inkblot/InkBlot/InkBlotAntlrGrammar.g4 by ANTLR 4.13.2
// Generated from E:/ProgettiUnity/InkAntlr/InkBlot/InkBlot/InkBlotAntlrGrammar.g4 by ANTLR 4.13.2
// Unreachable code detected
#pragma warning disable 0162
@@ -61,86 +61,6 @@ public interface IInkBlotAntlrGrammarListener : IParseTreeListener {
/// <param name="context">The parse tree.</param>
void ExitTopLevelStatement([NotNull] InkBlotAntlrGrammarParser.TopLevelStatementContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.knotLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterKnotLevelStatements([NotNull] InkBlotAntlrGrammarParser.KnotLevelStatementsContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.knotLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitKnotLevelStatements([NotNull] InkBlotAntlrGrammarParser.KnotLevelStatementsContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.stitchLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterStitchLevelStatements([NotNull] InkBlotAntlrGrammarParser.StitchLevelStatementsContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.stitchLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitStitchLevelStatements([NotNull] InkBlotAntlrGrammarParser.StitchLevelStatementsContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerBlockLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterInnerBlockLevelStatements([NotNull] InkBlotAntlrGrammarParser.InnerBlockLevelStatementsContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerBlockLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitInnerBlockLevelStatements([NotNull] InkBlotAntlrGrammarParser.InnerBlockLevelStatementsContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.contentText"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterContentText([NotNull] InkBlotAntlrGrammarParser.ContentTextContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.contentText"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitContentText([NotNull] InkBlotAntlrGrammarParser.ContentTextContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.mixedTextAndLogic"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterMixedTextAndLogic([NotNull] InkBlotAntlrGrammarParser.MixedTextAndLogicContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.mixedTextAndLogic"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitMixedTextAndLogic([NotNull] InkBlotAntlrGrammarParser.MixedTextAndLogicContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogicOrGlueOrTagStart"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterInlineLogicOrGlueOrTagStart([NotNull] InkBlotAntlrGrammarParser.InlineLogicOrGlueOrTagStartContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogicOrGlueOrTagStart"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitInlineLogicOrGlueOrTagStart([NotNull] InkBlotAntlrGrammarParser.InlineLogicOrGlueOrTagStartContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogic"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterInlineLogic([NotNull] InkBlotAntlrGrammarParser.InlineLogicContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogic"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitInlineLogic([NotNull] InkBlotAntlrGrammarParser.InlineLogicContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerLogic"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterInnerLogic([NotNull] InkBlotAntlrGrammarParser.InnerLogicContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerLogic"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitInnerLogic([NotNull] InkBlotAntlrGrammarParser.InnerLogicContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.multiDivert"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
@@ -272,54 +192,4 @@ public interface IInkBlotAntlrGrammarListener : IParseTreeListener {
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitExpression([NotNull] InkBlotAntlrGrammarParser.ExpressionContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.sequenceTypeAnnotation"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterSequenceTypeAnnotation([NotNull] InkBlotAntlrGrammarParser.SequenceTypeAnnotationContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.sequenceTypeAnnotation"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitSequenceTypeAnnotation([NotNull] InkBlotAntlrGrammarParser.SequenceTypeAnnotationContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerSequenceObjects"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterInnerSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerSequenceObjectsContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerSequenceObjects"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitInnerSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerSequenceObjectsContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerMultilineSequenceObjects"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterInnerMultilineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerMultilineSequenceObjectsContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerMultilineSequenceObjects"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitInnerMultilineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerMultilineSequenceObjectsContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.singleMultilineSequenceElement"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterSingleMultilineSequenceElement([NotNull] InkBlotAntlrGrammarParser.SingleMultilineSequenceElementContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.singleMultilineSequenceElement"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitSingleMultilineSequenceElement([NotNull] InkBlotAntlrGrammarParser.SingleMultilineSequenceElementContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerInlineSequenceObjects"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterInnerInlineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerInlineSequenceObjectsContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerInlineSequenceObjects"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitInnerInlineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerInlineSequenceObjectsContext context);
}

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
// Generated from C:/Users/mbelletti/RiderProjects/inkblot/InkBlot/InkBlotAntlrGrammar.g4 by ANTLR 4.13.2
// Generated from E:/ProgettiUnity/InkAntlr/InkBlot/InkBlot/InkBlotAntlrGrammar.g4 by ANTLR 4.13.2
// Unreachable code detected
#pragma warning disable 0162
@@ -50,54 +50,6 @@ public interface IInkBlotAntlrGrammarVisitor<Result> : IParseTreeVisitor<Result>
/// <return>The visitor result.</return>
Result VisitTopLevelStatement([NotNull] InkBlotAntlrGrammarParser.TopLevelStatementContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.knotLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitKnotLevelStatements([NotNull] InkBlotAntlrGrammarParser.KnotLevelStatementsContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.stitchLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitStitchLevelStatements([NotNull] InkBlotAntlrGrammarParser.StitchLevelStatementsContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerBlockLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitInnerBlockLevelStatements([NotNull] InkBlotAntlrGrammarParser.InnerBlockLevelStatementsContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.contentText"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitContentText([NotNull] InkBlotAntlrGrammarParser.ContentTextContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.mixedTextAndLogic"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitMixedTextAndLogic([NotNull] InkBlotAntlrGrammarParser.MixedTextAndLogicContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogicOrGlueOrTagStart"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitInlineLogicOrGlueOrTagStart([NotNull] InkBlotAntlrGrammarParser.InlineLogicOrGlueOrTagStartContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.inlineLogic"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitInlineLogic([NotNull] InkBlotAntlrGrammarParser.InlineLogicContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerLogic"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitInnerLogic([NotNull] InkBlotAntlrGrammarParser.InnerLogicContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.multiDivert"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
@@ -175,34 +127,4 @@ public interface IInkBlotAntlrGrammarVisitor<Result> : IParseTreeVisitor<Result>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitExpression([NotNull] InkBlotAntlrGrammarParser.ExpressionContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.sequenceTypeAnnotation"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitSequenceTypeAnnotation([NotNull] InkBlotAntlrGrammarParser.SequenceTypeAnnotationContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerSequenceObjects"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitInnerSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerSequenceObjectsContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerMultilineSequenceObjects"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitInnerMultilineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerMultilineSequenceObjectsContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.singleMultilineSequenceElement"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitSingleMultilineSequenceElement([NotNull] InkBlotAntlrGrammarParser.SingleMultilineSequenceElementContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.innerInlineSequenceObjects"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitInnerInlineSequenceObjects([NotNull] InkBlotAntlrGrammarParser.InnerInlineSequenceObjectsContext context);
}

View File

@@ -13,68 +13,72 @@ story: topLevelStatements ;
*/
topLevelStatements:
topLevelStatement+
topLevelStatement (NL+ topLevelStatement)* NL*
;
topLevelStatement:
multiDivert
| contentText
;
knotLevelStatements:
(contentText
| multiDivert
)+
;
stitchLevelStatements:
(contentText
| multiDivert
)+
;
innerBlockLevelStatements:
(contentText
| multiDivert
)+
;
/*
* STATEMENTS
*/
contentText: CONTENT_TEXT_NO_ESCAPE_SIMPLE ;
mixedTextAndLogic:
// TODO: ~ is not allowed as first symbol of this (see InkParser_Content => MixedTextAndLog), let's implement it in the C# side?
// like in innerInlineSequenceObjects, a bit of a chaos to avoid having completely empty entries
contentText? (inlineLogicOrGlueOrTagStart? contentText | inlineLogicOrGlueOrTagStart contentText?)+
// TODO: this is valid only when not parsing a choice, see above for the code where this logic is implemented
multiDivert
// TODO: management of tag ftw O_O
;
inlineLogicOrGlueOrTagStart:
inlineLogic
// TODO: glue, tag start
;
inlineLogic:
INLINE_LOGIC_START
WS?
innerLogic
// TODO: += and -= are disabled here (don't know why, maybe because they're statements?)
WS?
INLINE_LOGIC_END
// TODO: tags ftw
;
innerLogic:
WS?
sequenceTypeAnnotation innerSequenceObjects
// TODO: the rest of InkParser_Logic => InnerLogic
;
//topLevelStatement:
// multiDivert
// | contentText
// ;
//
// knotLevelStatements:
// (contentText
// | multiDivert
// )+
// ;
//
// stitchLevelStatements:
// (contentText
// | multiDivert
// )+
// ;
//
// innerBlockLevelStatements:
// (contentText
// | multiDivert
// )+
// ;
//
///*
// * STATEMENTS
// */
//
//contentText: (CONTENT_TEXT_NO_ESCAPE_NO_IDENT_SIMPLE | IDENTIFIER | WS | SEQUENCE_TYPE_SYMBOL_ANNOTATION | '&' | '$' | '!')+ ;
//
//mixedTextAndLogic:
// // TODO: ~ is not allowed as first symbol of this (see InkParser_Content => MixedTextAndLog), let's implement it in the C# side?
// // like in innerInlineSequenceObjects, a bit of a chaos to avoid having completely empty entries
// contentText? (inlineLogicOrGlueOrTagStart? contentText | inlineLogicOrGlueOrTagStart contentText?)+
// // TODO: this is valid only when not parsing a choice, see above for the code where this logic is implemented
// multiDivert
// // TODO: management of tag ftw O_O
// ;
//
//inlineLogicOrGlueOrTagStart:
// inlineLogic
// // TODO: glue, tag start
// ;
//
//inlineLogic:
// INLINE_LOGIC_START
// WS?
// innerLogic
// // TODO: += and -= are disabled here (don't know why, maybe because they're statements?)
// WS?
// INLINE_LOGIC_END
// // TODO: tags ftw
// ;
//
//innerLogic:
// WS?
// sequenceTypeAnnotation innerSequenceObjects
// // TODO: the rest of InkParser_Logic => InnerLogic
// ;
//
multiDivert:
WS?
multiDivert_withoutWS
@@ -97,21 +101,16 @@ multiDivertArrows_tail:
;
divertIdentifierWithArguments:
WS?
divertIdentifierWithArguments_name
WS?
(
'('
expression (',' WS? expression)*
')'
)?
divertIdentifierWithArguments_arguments?
WS?
;
divertIdentifierWithArguments_name:
WS? identifier WS? ('.' WS? identifier WS? )*
;
divertIdentifierWithArguments_arguments:
'('
expression (',' WS? expression)*
@@ -128,45 +127,45 @@ expression:
IDENTIFIER
;
// all possible symbols or word(s) for sequencing
sequenceTypeAnnotation:
op=SEQUENCE_TYPE_SYMBOL_ANNOTATION
| ONCE
| CYCLE
| SHUFFLE
| STOPPING
| SHUFFLE_ONCE
| SHUFFLE_STOPPING
;
/* a list of sequence objects, either compressed in a single line (e.g.: {a|b|c}) or expanded in multiple lines (e.g.:
{\n- a\n- b\n- c}
*/
innerSequenceObjects:
NL innerMultilineSequenceObjects
| innerInlineSequenceObjects
;
innerMultilineSequenceObjects:
singleMultilineSequenceElement+
;
singleMultilineSequenceElement:
WS?
/* TODO: how to express this? and why is it here? InkParser_Sequences => SingleMultilineSequenceElement
if (ParseString ("->") != null)
return null;
*/
'-'
WS?
(
innerBlockLevelStatements
| MULTILINE_WS
)
;
innerInlineSequenceObjects:
// it's a bit chaotic, in order to allow for empty mixedTextAndLogic, but always require at least one entry
(mixedTextAndLogic ('|' mixedTextAndLogic?)*)
| ('|' mixedTextAndLogic?)+
;
//// all possible symbols or word(s) for sequencing
//sequenceTypeAnnotation:
// op=SEQUENCE_TYPE_SYMBOL_ANNOTATION
// | 'once' WS? ':'
// | 'cycle' WS? ':'
// | 'shuffle' WS? ':'
// | 'stopping' WS? ':'
// | 'shuffle' WS 'once' WS? ':'
// | 'shuffle' WS 'stopping' WS? ':'
// ;
//
///* a list of sequence objects, either compressed in a single line (e.g.: {a|b|c}) or expanded in multiple lines (e.g.:
//{\n- a\n- b\n- c}
//*/
//innerSequenceObjects:
// NL innerMultilineSequenceObjects
// | innerInlineSequenceObjects
// ;
//
//innerMultilineSequenceObjects:
// singleMultilineSequenceElement+
// ;
//
//singleMultilineSequenceElement:
// WS?
// /* TODO: how to express this? and why is it here? InkParser_Sequences => SingleMultilineSequenceElement
// if (ParseString ("->") != null)
// return null;
// */
// '-'
// WS?
// (
// innerBlockLevelStatements
// | MULTILINE_WS
// )
// ;
//
//innerInlineSequenceObjects:
// // it's a bit chaotic, in order to allow for empty mixedTextAndLogic, but always require at least one entry
// (mixedTextAndLogic ('|' mixedTextAndLogic?)*)
// | ('|' mixedTextAndLogic?)+
// ;

View File

@@ -1,47 +1,52 @@
lexer grammar InkBlotAntlrLexer;
// classic "white space" and "new line" - ink's new line also allows for some whitespace at start
WS: [ \t]+ ;
NL: WS? '\r'? '\n' ;
// one or more (potential whitespace followed by) newline(s); used e.g. for block sequencing
MULTILINE_WS: NL+ ;
// see InkParser_Content.cs, ContentTextNoEscape and ContentTextAllowingEcapeChar for the escape case
// this works for the base case where we're not parsing a string, nor a choice
CONTENT_TEXT_NO_ESCAPE_SIMPLE:
(
// any character is valid, except for:
// - {} ==> identifies embedded logic
// - | ==> text alternatives, is forbidden even in non-logic text for some reason
// - \n\r ==> a new line of content
// - # ==> a tag
// - \, < and - with exceptions (see below)
~[{}|\n\r\\#-< ]
// any character can be escaped
| '\\' [\u0000-\uFFFF] // TODO: is there a better way to say "any character"?
// accept a - only if not followed by a > (->, a divert)
| '-' { InputStream.LA(1) != '>' }?
// same for threads (<-) and glue (<>)
// | '<' { InputStream.LA(1) != '-' && InputStream.LA(1) != '>' }?
)+ ;
INLINE_LOGIC_START: '{' ;
INLINE_LOGIC_END: '}' ;
// All symbols for sequencing: either using the short-hand symbols (https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#types-of-alternatives)
// or using the multiline blocks (https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#multiline-blocks)
SEQUENCE_TYPE_SYMBOL_ANNOTATION: [!&~$ ] ;
ONCE: 'once' WS? ':' ;
CYCLE: 'cycle' WS? ':' ;
SHUFFLE: 'shuffle' WS? ':' ;
STOPPING: 'stopping' WS? ':' ;
SHUFFLE_ONCE: 'shuffle' WS 'once' WS? ':' ;
SHUFFLE_STOPPING: 'shuffle' WS 'stopping' WS? ':' ;
THREAD_ARROW: '<-' ;
DIVERT_ARROW: '->' ;
TUNNEL_ARROW: '->->' ;
// TODO: add all extra character ranges from InkParser_CharacterRanges (LatinBasic, LatinExtendedA, ...)
IDENTIFIER: [A-Za-z0-9_]+;
IDENTIFIER: [a-zA-Z0-9_]+;
//// classic "white space" and "new line" - ink's new line also allows for some whitespace at start
WS: [ \t]+ ;
NL: WS? '\r'? '\n' ;
//
//// one or more (potential whitespace followed by) newline(s); used e.g. for block sequencing
//MULTILINE_WS: NL+ ;
//
//// see InkParser_Content.cs, ContentTextNoEscape and ContentTextAllowingEcapeChar for the escape case
//// this works for the base case where we're not parsing a string, nor a choice
//// We ALSO have to remove all other tokens from here, otherwise this will gobble them all up, since it will become
//// the longest-matching token
//CONTENT_TEXT_NO_ESCAPE_NO_IDENT_SIMPLE:
// (
// // any character is valid, except for:
// // - {} ==> identifies embedded logic
// // - | ==> text alternatives, is forbidden even in non-logic text for some reason
// // - \n\r ==> a new line of content
// // - # ==> a tag
// // - \, < and - with exceptions (see below)
// // - space and \t ==> these are used to parse spaces
// // a-z, A-Z, 0-9 and _ ==> these are used to parse identifiers TODO: add missing characters
// // !&$ ==> these are used by as sequence type symbol annotation; "~" too but that is special
// ~[{}|\n\r\\#\-< \ta-zA-Z0-9_!&$]
// // any character can be escaped
// | '\\' [\u0000-\uFFFF] // TODO: is there a better way to say "any character"?
// // accept a - only if not followed by a > (->, a divert)
// | '-' { InputStream.LA(1) != '>' }?
// // same for threads (<-) and glue (<>)
// | '<' { InputStream.LA(1) != '-' && InputStream.LA(1) != '>' }?
// )+ ;
//
//INLINE_LOGIC_START: '{' ;
//INLINE_LOGIC_END: '}' ;
//
//// All symbols for sequencing: either using the short-hand symbols (https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#types-of-alternatives)
//// or using the multiline blocks (https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#multiline-blocks)
//SEQUENCE_TYPE_SYMBOL_ANNOTATION: [!&~$ ] ;
//
//THREAD_ARROW: '<-' ;
//DIVERT_ARROW: '->' ;
//TUNNEL_ARROW: '->->' ;
//
//// TODO: add all extra character ranges from InkParser_CharacterRanges (LatinBasic, LatinExtendedA, ...), and also remove them from CONTENT_TEXT_NO_ESCAPE_SIMPLE
//IDENTIFIER: [a-zA-Z0-9_]+;

View File

@@ -7,12 +7,42 @@ 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;
}
}
public record Identifier(string[] Elements /* TODO: expressions */);
public record Identifier(string[] Elements /* TODO: expressions */)
{
public virtual bool Equals(Identifier? other)
{
return other is not null && Elements.SequenceEqual(other.Elements);
}
public override string ToString()
{
return "Identifier(" + string.Join('.', Elements) + ")";
}
public override int GetHashCode()
{
return Elements.GetHashCode();
}
}
// <- thread_name
public record ThreadDivert(Identifier Identifier) : IStoryNode;
public record ThreadDivert(Identifier Identifier) : IStoryNode
{
public override string ToString()
{
return $"ThreadDivert({Identifier})";
}
}
// -> ... ->-> // return from tunnel
// or

View File

@@ -1,8 +1,5 @@
using System.Text;
using Antlr4.Runtime;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Dfa;
using Antlr4.Runtime.Sharpen;
namespace InkBlot;
@@ -59,13 +56,13 @@ internal sealed class ParserErrorListener : BaseErrorListener
Diagnostics.Add(diagnostic);
}
// TODO: better to use a "if test" of some kind?
#if DEBUG
public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, bool exact,
BitSet ambigAlts,
ATNConfigSet configs)
{
throw new InvalidOperationException("found ambiguity");
}
#endif
// // TODO: better to use a "if test" of some kind?
// #if DEBUG
// public override void ReportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, bool exact,
// BitSet ambigAlts,
// ATNConfigSet configs)
// {
// throw new InvalidOperationException("found ambiguity");
// }
// #endif
}

View File

@@ -13,7 +13,7 @@ public partial class Listener
public override void ExitContentText(InkBlotAntlrGrammarParser.ContentTextContext context)
{
// escape sequences are captured by this node, but not interpreted
var contentWithEscapes = context.CONTENT_TEXT_NO_ESCAPE_SIMPLE().ToString();
var contentWithEscapes = context.ToString();
if (contentWithEscapes == null)
// when does this happen? :?
throw new InvalidOperationException();

View File

@@ -1,6 +1,5 @@
using Antlr4.Runtime.Tree;
using InkBlot.ParseHierarchy;
using Microsoft.Extensions.Logging;
namespace InkBlot.Visitor;
@@ -12,6 +11,11 @@ public partial class Listener
private readonly ParseTreeProperty<MultiDivertArrowsTail> _multiDivertsArrowsTail = new();
public override void ExitMultiDivert(InkBlotAntlrGrammarParser.MultiDivertContext context)
{
PutStoryNode(context, _multiDiverts.Get(context));
}
public override void ExitMultiDivertThread(InkBlotAntlrGrammarParser.MultiDivertThreadContext context)
{
var threadDivert = new ThreadDivert(
@@ -69,7 +73,7 @@ public partial class Listener
public override void ExitDivertIdentifierWithArguments_name(
InkBlotAntlrGrammarParser.DivertIdentifierWithArguments_nameContext context)
{
var name = context.identifier().Select(identifier => identifier.ToString().AsNotNull()).ToArray();
var name = context.identifier().Select(identifier => identifier.IDENTIFIER().ToString().AsNotNull()).ToArray();
_divertIdentifierNames.Put(context.Parent, name);
}
@@ -82,14 +86,8 @@ public partial class Listener
public override void ExitDivertIdentifierWithArguments(
InkBlotAntlrGrammarParser.DivertIdentifierWithArgumentsContext context)
{
var c = context.divertIdentifierWithArguments_name();
if (c == null)
{
Logger.LogWarning("found ExitDivertIdentifierWithArguments without name");
return;
}
var name = _divertIdentifierNames.Get(c);
var name = _divertIdentifierNames.Get(context);
if (name == null) throw new InvalidOperationException("parsing logic error");
_divertIdentifiers.Put(context, new Identifier(name));
}

View File

@@ -1,13 +1,26 @@
using InkBlot.ParseHierarchy;
using Antlr4.Runtime.Tree;
using InkBlot.ParseHierarchy;
namespace InkBlot.Visitor;
public partial class Listener
{
private readonly ParseTreeProperty<IStoryNode> _storyNodeValue = new();
private Story? _story;
public Story Story => _story ?? throw new InvalidOperationException("No story found yet.");
private void PutStoryNode(IParseTree tree, IStoryNode storyNode)
{
_storyNodeValue.Put(tree, storyNode);
}
private IStoryNode GetStoryNode(IParseTree tree)
{
return _storyNodeValue.Get(tree);
}
public override void ExitStory(InkBlotAntlrGrammarParser.StoryContext context)
{
var storyNodes = context

View File

@@ -1,19 +0,0 @@
using Antlr4.Runtime.Tree;
using InkBlot.ParseHierarchy;
namespace InkBlot.Visitor;
public partial class Listener
{
private readonly ParseTreeProperty<IStoryNode> _storyNodeValue = new();
private void PutStoryNode(IParseTree tree, IStoryNode storyNode)
{
_storyNodeValue.Put(tree, storyNode);
}
private IStoryNode GetStoryNode(IParseTree tree)
{
return _storyNodeValue.Get(tree);
}
}