feat: first chunk of lexer/parser translation.

This commit is contained in:
mattia
2025-02-16 20:49:20 +01:00
parent d386c50499
commit 4f8e83da9d
15 changed files with 2593 additions and 49 deletions

View File

@@ -11,8 +11,8 @@ public class ContentTextTest
[InlineData("Hel\\lo!", "Hello!", 0)]
[InlineData("Hel<lo!", "Hel<lo!", 0)]
// TODO: check error situations better when diverts (->), threads (<-) and tags (#) are supported
[InlineData("Hel->lo!", "", 1)]
[InlineData("Hel<-lo!", "", 1)]
// [InlineData("Hel->lo!", "", 1)]
// [InlineData("Hel<-lo!", "", 1)]
[InlineData("Hel#lo!", "", 1)]
public void TestBaseContentSuccess(string inkInput, string result, int numErrors)
{

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +1,34 @@
Whitespace=1
CONTENT_TEXT_NO_ESCAPE_SIMPLE=2
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

View File

@@ -48,6 +48,54 @@ public partial class InkBlotAntlrGrammarBaseListener : IInkBlotAntlrGrammarListe
/// <param name="context">The parse tree.</param>
public virtual void ExitStory([NotNull] InkBlotAntlrGrammarParser.StoryContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.topLevelStatements"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterTopLevelStatements([NotNull] InkBlotAntlrGrammarParser.TopLevelStatementsContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.topLevelStatements"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitTopLevelStatements([NotNull] InkBlotAntlrGrammarParser.TopLevelStatementsContext 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>
@@ -59,6 +107,162 @@ public partial class InkBlotAntlrGrammarBaseListener : IInkBlotAntlrGrammarListe
/// </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>
/// <param name="context">The parse tree.</param>
public virtual void EnterMultiDivert([NotNull] InkBlotAntlrGrammarParser.MultiDivertContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.multiDivert"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitMultiDivert([NotNull] InkBlotAntlrGrammarParser.MultiDivertContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.divertIdentifierWithArguments"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterDivertIdentifierWithArguments([NotNull] InkBlotAntlrGrammarParser.DivertIdentifierWithArgumentsContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.divertIdentifierWithArguments"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitDivertIdentifierWithArguments([NotNull] InkBlotAntlrGrammarParser.DivertIdentifierWithArgumentsContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.identifier"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterIdentifier([NotNull] InkBlotAntlrGrammarParser.IdentifierContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.identifier"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void ExitIdentifier([NotNull] InkBlotAntlrGrammarParser.IdentifierContext context) { }
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.expression"/>.
/// <para>The default implementation does nothing.</para>
/// </summary>
/// <param name="context">The parse tree.</param>
public virtual void EnterExpression([NotNull] InkBlotAntlrGrammarParser.ExpressionContext context) { }
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.expression"/>.
/// <para>The default implementation does nothing.</para>
/// </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

@@ -45,6 +45,46 @@ public partial class InkBlotAntlrGrammarBaseVisitor<Result> : AbstractParseTreeV
/// <return>The visitor result.</return>
public virtual Result VisitStory([NotNull] InkBlotAntlrGrammarParser.StoryContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.topLevelStatements"/>.
/// <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 VisitTopLevelStatements([NotNull] InkBlotAntlrGrammarParser.TopLevelStatementsContext 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)"/>
@@ -54,4 +94,134 @@ public partial class InkBlotAntlrGrammarBaseVisitor<Result> : AbstractParseTreeV
/// <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)"/>
/// on <paramref name="context"/>.
/// </para>
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
public virtual Result VisitMultiDivert([NotNull] InkBlotAntlrGrammarParser.MultiDivertContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.divertIdentifierWithArguments"/>.
/// <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 VisitDivertIdentifierWithArguments([NotNull] InkBlotAntlrGrammarParser.DivertIdentifierWithArgumentsContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.identifier"/>.
/// <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 VisitIdentifier([NotNull] InkBlotAntlrGrammarParser.IdentifierContext context) { return VisitChildren(context); }
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.expression"/>.
/// <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 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

@@ -33,7 +33,11 @@ public partial class InkBlotAntlrGrammarLexer : Lexer {
protected static DFA[] decisionToDFA;
protected static PredictionContextCache sharedContextCache = new PredictionContextCache();
public const int
Whitespace=1, CONTENT_TEXT_NO_ESCAPE_SIMPLE=2;
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;
public static string[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
@@ -43,7 +47,11 @@ public partial class InkBlotAntlrGrammarLexer : Lexer {
};
public static readonly string[] ruleNames = {
"Whitespace", "CONTENT_TEXT_NO_ESCAPE_SIMPLE"
"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"
};
@@ -57,9 +65,16 @@ public partial class InkBlotAntlrGrammarLexer : Lexer {
}
private static readonly string[] _LiteralNames = {
null, "'.'", "'('", "','", "')'", "'-'", "'|'", null, null, null, null,
"'{'", "'}'", null, null, null, null, null, null, null, "'<-'", "'->'",
"'->->'"
};
private static readonly string[] _SymbolicNames = {
null, "Whitespace", "CONTENT_TEXT_NO_ESCAPE_SIMPLE"
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"
};
public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames);
@@ -90,7 +105,7 @@ public partial class InkBlotAntlrGrammarLexer : Lexer {
}
public override bool Sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
switch (ruleIndex) {
case 1 : return CONTENT_TEXT_NO_ESCAPE_SIMPLE_sempred(_localctx, predIndex);
case 9 : return CONTENT_TEXT_NO_ESCAPE_SIMPLE_sempred(_localctx, predIndex);
}
return true;
}
@@ -103,14 +118,72 @@ public partial class InkBlotAntlrGrammarLexer : Lexer {
}
private static int[] _serializedATN = {
4,0,2,21,6,-1,2,0,7,0,2,1,7,1,1,0,4,0,7,8,0,11,0,12,0,8,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,4,1,18,8,1,11,1,12,1,19,0,0,2,1,1,3,2,1,0,3,2,0,9,9,32,32,
5,0,10,10,13,13,35,60,92,92,123,125,1,0,0,65535,25,0,1,1,0,0,0,0,3,1,0,
0,0,1,6,1,0,0,0,3,17,1,0,0,0,5,7,7,0,0,0,6,5,1,0,0,0,7,8,1,0,0,0,8,6,1,
0,0,0,8,9,1,0,0,0,9,2,1,0,0,0,10,18,8,1,0,0,11,12,5,92,0,0,12,18,7,2,0,
0,13,14,5,45,0,0,14,18,4,1,0,0,15,16,5,60,0,0,16,18,4,1,1,0,17,10,1,0,
0,0,17,11,1,0,0,0,17,13,1,0,0,0,17,15,1,0,0,0,18,19,1,0,0,0,19,17,1,0,
0,0,19,20,1,0,0,0,20,4,1,0,0,0,4,0,8,17,19,0
4,0,23,200,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,1,9,1,9,4,9,85,8,9,11,9,12,9,86,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,101,8,13,1,
13,1,13,1,14,1,14,1,14,1,14,1,14,1,14,1,14,3,14,112,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,125,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,139,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,158,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,181,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,197,8,
22,11,22,12,22,198,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,5,0,10,10,13,13,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,214,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,84,1,0,0,0,21,
88,1,0,0,0,23,90,1,0,0,0,25,92,1,0,0,0,27,94,1,0,0,0,29,104,1,0,0,0,31,
115,1,0,0,0,33,128,1,0,0,0,35,142,1,0,0,0,37,161,1,0,0,0,39,184,1,0,0,
0,41,187,1,0,0,0,43,190,1,0,0,0,45,196,1,0,0,0,47,48,5,46,0,0,48,2,1,0,
0,0,49,50,5,40,0,0,50,4,1,0,0,0,51,52,5,44,0,0,52,6,1,0,0,0,53,54,5,41,
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,85,8,1,0,0,78,79,5,92,0,0,79,85,
7,2,0,0,80,81,5,45,0,0,81,85,4,9,0,0,82,83,5,60,0,0,83,85,4,9,1,0,84,77,
1,0,0,0,84,78,1,0,0,0,84,80,1,0,0,0,84,82,1,0,0,0,85,86,1,0,0,0,86,84,
1,0,0,0,86,87,1,0,0,0,87,20,1,0,0,0,88,89,5,123,0,0,89,22,1,0,0,0,90,91,
5,125,0,0,91,24,1,0,0,0,92,93,7,3,0,0,93,26,1,0,0,0,94,95,5,111,0,0,95,
96,5,110,0,0,96,97,5,99,0,0,97,98,5,101,0,0,98,100,1,0,0,0,99,101,3,13,
6,0,100,99,1,0,0,0,100,101,1,0,0,0,101,102,1,0,0,0,102,103,5,58,0,0,103,
28,1,0,0,0,104,105,5,99,0,0,105,106,5,121,0,0,106,107,5,99,0,0,107,108,
5,108,0,0,108,109,5,101,0,0,109,111,1,0,0,0,110,112,3,13,6,0,111,110,1,
0,0,0,111,112,1,0,0,0,112,113,1,0,0,0,113,114,5,58,0,0,114,30,1,0,0,0,
115,116,5,115,0,0,116,117,5,104,0,0,117,118,5,117,0,0,118,119,5,102,0,
0,119,120,5,102,0,0,120,121,5,108,0,0,121,122,5,101,0,0,122,124,1,0,0,
0,123,125,3,13,6,0,124,123,1,0,0,0,124,125,1,0,0,0,125,126,1,0,0,0,126,
127,5,58,0,0,127,32,1,0,0,0,128,129,5,115,0,0,129,130,5,116,0,0,130,131,
5,111,0,0,131,132,5,112,0,0,132,133,5,112,0,0,133,134,5,105,0,0,134,135,
5,110,0,0,135,136,5,103,0,0,136,138,1,0,0,0,137,139,3,13,6,0,138,137,1,
0,0,0,138,139,1,0,0,0,139,140,1,0,0,0,140,141,5,58,0,0,141,34,1,0,0,0,
142,143,5,115,0,0,143,144,5,104,0,0,144,145,5,117,0,0,145,146,5,102,0,
0,146,147,5,102,0,0,147,148,5,108,0,0,148,149,5,101,0,0,149,150,1,0,0,
0,150,151,3,13,6,0,151,152,5,111,0,0,152,153,5,110,0,0,153,154,5,99,0,
0,154,155,5,101,0,0,155,157,1,0,0,0,156,158,3,13,6,0,157,156,1,0,0,0,157,
158,1,0,0,0,158,159,1,0,0,0,159,160,5,58,0,0,160,36,1,0,0,0,161,162,5,
115,0,0,162,163,5,104,0,0,163,164,5,117,0,0,164,165,5,102,0,0,165,166,
5,102,0,0,166,167,5,108,0,0,167,168,5,101,0,0,168,169,1,0,0,0,169,170,
3,13,6,0,170,171,5,115,0,0,171,172,5,116,0,0,172,173,5,111,0,0,173,174,
5,112,0,0,174,175,5,112,0,0,175,176,5,105,0,0,176,177,5,110,0,0,177,178,
5,103,0,0,178,180,1,0,0,0,179,181,3,13,6,0,180,179,1,0,0,0,180,181,1,0,
0,0,181,182,1,0,0,0,182,183,5,58,0,0,183,38,1,0,0,0,184,185,5,60,0,0,185,
186,5,45,0,0,186,40,1,0,0,0,187,188,5,45,0,0,188,189,5,62,0,0,189,42,1,
0,0,0,190,191,5,45,0,0,191,192,5,62,0,0,192,193,5,45,0,0,193,194,5,62,
0,0,194,44,1,0,0,0,195,197,7,4,0,0,196,195,1,0,0,0,197,198,1,0,0,0,198,
196,1,0,0,0,198,199,1,0,0,0,199,46,1,0,0,0,14,0,62,65,68,75,84,86,100,
111,124,138,157,180,198,0
};
public static readonly ATN _ATN =

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +1,34 @@
Whitespace=1
CONTENT_TEXT_NO_ESCAPE_SIMPLE=2
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

View File

@@ -41,6 +41,46 @@ public interface IInkBlotAntlrGrammarListener : IParseTreeListener {
/// <param name="context">The parse tree.</param>
void ExitStory([NotNull] InkBlotAntlrGrammarParser.StoryContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.topLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterTopLevelStatements([NotNull] InkBlotAntlrGrammarParser.TopLevelStatementsContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.topLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitTopLevelStatements([NotNull] InkBlotAntlrGrammarParser.TopLevelStatementsContext 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>
@@ -50,4 +90,134 @@ public interface IInkBlotAntlrGrammarListener : IParseTreeListener {
/// </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>
void EnterMultiDivert([NotNull] InkBlotAntlrGrammarParser.MultiDivertContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.multiDivert"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitMultiDivert([NotNull] InkBlotAntlrGrammarParser.MultiDivertContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.divertIdentifierWithArguments"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterDivertIdentifierWithArguments([NotNull] InkBlotAntlrGrammarParser.DivertIdentifierWithArgumentsContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.divertIdentifierWithArguments"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitDivertIdentifierWithArguments([NotNull] InkBlotAntlrGrammarParser.DivertIdentifierWithArgumentsContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.identifier"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterIdentifier([NotNull] InkBlotAntlrGrammarParser.IdentifierContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.identifier"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void ExitIdentifier([NotNull] InkBlotAntlrGrammarParser.IdentifierContext context);
/// <summary>
/// Enter a parse tree produced by <see cref="InkBlotAntlrGrammarParser.expression"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
void EnterExpression([NotNull] InkBlotAntlrGrammarParser.ExpressionContext context);
/// <summary>
/// Exit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.expression"/>.
/// </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

@@ -38,9 +38,111 @@ public interface IInkBlotAntlrGrammarVisitor<Result> : IParseTreeVisitor<Result>
/// <return>The visitor result.</return>
Result VisitStory([NotNull] InkBlotAntlrGrammarParser.StoryContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.topLevelStatements"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitTopLevelStatements([NotNull] InkBlotAntlrGrammarParser.TopLevelStatementsContext 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>
/// <return>The visitor result.</return>
Result VisitMultiDivert([NotNull] InkBlotAntlrGrammarParser.MultiDivertContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.divertIdentifierWithArguments"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitDivertIdentifierWithArguments([NotNull] InkBlotAntlrGrammarParser.DivertIdentifierWithArgumentsContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.identifier"/>.
/// </summary>
/// <param name="context">The parse tree.</param>
/// <return>The visitor result.</return>
Result VisitIdentifier([NotNull] InkBlotAntlrGrammarParser.IdentifierContext context);
/// <summary>
/// Visit a parse tree produced by <see cref="InkBlotAntlrGrammarParser.expression"/>.
/// </summary>
/// <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

@@ -2,6 +2,138 @@ grammar InkBlotAntlrGrammar;
import InkBlotAntlrLexer;
story: contentText+ ;
/*
* STORY
*/
contentText: CONTENT_TEXT_NO_ESCAPE_SIMPLE ;
story: topLevelStatements ;
/*
* STATEMENTS FOR THE VARIOUS LEVELS
*/
topLevelStatements:
contentText+
;
knotLevelStatements:
contentText+
;
stitchLevelStatements:
contentText+
;
innerBlockLevelStatements:
contentText+
;
/*
* 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
INLINE_LOGIC_END
;
innerLogic:
WS?
sequenceTypeAnnotation innerSequenceObjects
// TODO: the rest of InkParser_Logic => InnerLogic
;
multiDivert:
WS?
(
THREAD_ARROW divertIdentifierWithArguments
// here be dragons: trying to express the various "Possible patterns" of InkParser_Divert => MultiDivert
| (DIVERT_ARROW divertIdentifierWithArguments)+ TUNNEL_ARROW divertIdentifierWithArguments
| (DIVERT_ARROW divertIdentifierWithArguments)+ TUNNEL_ARROW
| (DIVERT_ARROW divertIdentifierWithArguments)+ DIVERT_ARROW
| TUNNEL_ARROW
| DIVERT_ARROW // TODO: this is only valid in default choices ( https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#fallback-choices )
)
;
divertIdentifierWithArguments:
WS? identifier WS? ('.' WS? identifier WS? )*
WS?
(
'('
expression (',' expression)*
')'
)?
WS?
;
identifier:
// TODO: reject numbers-only identifier - see InkParser_Logic => Identifier
IDENTIFIER
;
expression:
// TODO: temporary stuff here
IDENTIFIER
;
// all possible symbols or word(s) for sequencing
sequenceTypeAnnotation:
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?)+
;

View File

@@ -1,6 +1,11 @@
lexer grammar InkBlotAntlrLexer;
Whitespace: [ \t]+ ;
// 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
@@ -19,4 +24,24 @@ CONTENT_TEXT_NO_ESCAPE_SIMPLE:
| '-' { 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_]+;

View File

@@ -1,5 +1,8 @@
using System.Text;
using Antlr4.Runtime;
using Antlr4.Runtime.Atn;
using Antlr4.Runtime.Dfa;
using Antlr4.Runtime.Sharpen;
namespace InkBlot;
@@ -55,4 +58,14 @@ 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
}

View File

@@ -10,11 +10,10 @@ public partial class Listener
public override void ExitStory(InkBlotAntlrGrammarParser.StoryContext context)
{
var storyNodes = context.children.Select(child => child switch
{
InkBlotAntlrGrammarParser.ContentTextContext contentText => new Content(GetContentText(contentText)),
_ => throw new InvalidOperationException($"unknown context of type {child.GetType()}")
});
var storyNodes = context
.topLevelStatements()
.contentText()
.Select(child => new Content(GetContentText(child)));
_story = new Story(storyNodes);
}
}