コード例 #1
0
ファイル: Compiler.cs プロジェクト: wzzwzz687510/YarnSpinner
 // we have found a new node
 // set up the currentNode var ready to hold it and otherwise continue
 public override void EnterNode(YarnSpinnerParser.NodeContext context)
 {
     if (currentNode != null)
     {
         string newNode = context.header().header_title().TITLE_TEXT().GetText().Trim();
         string message = string.Format(CultureInfo.CurrentCulture, "Discovered a new node {0} while {1} is still being parsed", newNode, currentNode.name);
         throw new Yarn.ParseException(message);
     }
     currentNode = new Node();
     rawTextNode = false;
 }
コード例 #2
0
        public override Yarn.Type VisitNode(YarnSpinnerParser.NodeContext context)
        {
            currentNodeContext = context;
            foreach (var header in context.header())
            {
                if (header.header_key.Text == "title")
                {
                    currentNodeName = header.header_value.Text;
                }
            }
            Visit(context.body());

            return(Yarn.Type.Undefined);
        }
コード例 #3
0
        public override int VisitNode(YarnSpinnerParser.NodeContext context)
        {
            currentNodeContext = context;

            List <string> tags = new List <string>();

            foreach (var header in context.header())
            {
                string headerKey   = header.header_key.Text;
                string headerValue = header.header_value?.Text ?? string.Empty;

                if (headerKey.Equals("title", StringComparison.InvariantCulture))
                {
                    currentNodeName = header.header_value.Text;
                }

                if (headerKey.Equals("tags", StringComparison.InvariantCulture))
                {
                    // Split the list of tags by spaces, and use that
                    tags = new List <string>(headerValue.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                }
            }

            if (string.IsNullOrEmpty(currentNodeName) == false && tags.Contains("rawText"))
            {
                // This is a raw text node. Use its entire contents as a
                // string and don't use its contents.
                var lineID = Compiler.GetLineIDForNodeName(currentNodeName);
                stringTableManager.RegisterString(context.body().GetText(), fileName, currentNodeName, lineID, context.body().Start.Line, null);
            }
            else
            {
                // This is a regular node
                // this.Visit(context.body());

                var body = context.body();
                if (body != null)
                {
                    this.Visit(body);
                }
                // String table generator: don't crash if a node has no body
            }

            return(0);
        }
コード例 #4
0
        public override Yarn.IType VisitNode(YarnSpinnerParser.NodeContext context)
        {
            currentNodeContext = context;
            foreach (var header in context.header())
            {
                if (header.header_key.Text == "title")
                {
                    currentNodeName = header.header_value.Text;
                }
            }

            var body = context.body();

            if (body != null)
            {
                base.Visit(body);
            }

            return(null);
        }
コード例 #5
0
        public override string VisitNode([NotNull] YarnSpinnerParser.NodeContext context)
        {
            string title    = null;
            string tracking = null;

            foreach (var header in context.header())
            {
                var headerKey = header.header_key.Text;
                if (headerKey.Equals("title"))
                {
                    title = header.header_value?.Text;
                }
                else if (headerKey.Equals("tracking"))
                {
                    tracking = header.header_value?.Text;
                }
            }

            if (title != null && tracking != null)
            {
                if (tracking.Equals("always"))
                {
                    TrackingNode.Add(title);
                }
                else if (tracking.Equals("never"))
                {
                    NeverVisitNodes.Add(title);
                }
            }

            if (context.body() != null)
            {
                return(Visit(context.body()));
            }
            return(null);
        }
コード例 #6
0
ファイル: Compiler.cs プロジェクト: mgilski/YarnSpinner
 // have left the current node store it into the program wipe the
 // var and make it ready to go again
 public override void ExitNode(YarnSpinnerParser.NodeContext context)
 {
     Program.Nodes[CurrentNode.Name] = CurrentNode;
     CurrentNode = null;
     RawTextNode = false;
 }
コード例 #7
0
ファイル: Compiler.cs プロジェクト: mgilski/YarnSpinner
 // we have found a new node set up the currentNode var ready to
 // hold it and otherwise continue
 public override void EnterNode(YarnSpinnerParser.NodeContext context)
 {
     CurrentNode = new Node();
     RawTextNode = false;
 }
コード例 #8
0
ファイル: Compiler.cs プロジェクト: wzzwzz687510/YarnSpinner
 // have left the current node
 // store it into the program
 // wipe the var and make it ready to go again
 public override void ExitNode(YarnSpinnerParser.NodeContext context)
 {
     program.nodes[currentNode.name] = currentNode;
     currentNode = null;
     rawTextNode = false;
 }
コード例 #9
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="YarnSpinnerParser.node"/>.
 /// <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 VisitNode([NotNull] YarnSpinnerParser.NodeContext context)
 {
     return(VisitChildren(context));
 }
コード例 #10
0
ファイル: Compiler.cs プロジェクト: stalhandske/YarnSpinner
 public override void ExitNode(YarnSpinnerParser.NodeContext context)
 {
     // Add this node to the graph
     graph.nodes.Add(currentNode);
 }
コード例 #11
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="YarnSpinnerParser.node"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitNode([NotNull] YarnSpinnerParser.NodeContext context)
 {
 }