feat: finally able to overcome the base of the base of this f*cked up mess
This commit is contained in:
@@ -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();
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user