示例#1
0
        // semi-free form text that gets passed along to the game
        // for things like <<turn fred left>> or <<unlockAchievement FacePlant>>
        public override int VisitCommand_statement(YarnSpinnerParser.Command_statementContext context)
        {
            GenerateFormattedText(context.command_formatted_text().children, out var composedString, out var expressionCount);

            // TODO: look into replacing this as it seems a bit odd
            switch (composedString)
            {
            case "stop":
                // "stop" is a special command that immediately stops
                // execution
                compiler.Emit(OpCode.Stop);
                break;

            default:
                compiler.Emit(OpCode.RunCommand, new Operand(composedString), new Operand(expressionCount));
                break;
            }

            return(0);
        }
示例#2
0
        // semi-free form text that gets passed along to the game for things
        // like <<turn fred left>> or <<unlockAchievement FacePlant>>
        public override int VisitCommand_statement(YarnSpinnerParser.Command_statementContext context)
        {
            var expressionCount = 0;
            var sb = new StringBuilder();

            foreach (var node in context.command_formatted_text().children)
            {
                if (node is ITerminalNode)
                {
                    sb.Append(node.GetText());
                }
                else if (node is ParserRuleContext)
                {
                    // Generate code for evaluating the expression at runtime
                    this.Visit(node);

                    // Don't include the '{' and '}', because it will have been
                    // added as a terminal node already
                    sb.Append(expressionCount);
                    expressionCount += 1;
                }
            }

            var composedString = sb.ToString();

            // TODO: look into replacing this as it seems a bit odd
            switch (composedString)
            {
            case "stop":
                // "stop" is a special command that immediately stops
                // execution
                this.compiler.Emit(OpCode.Stop, context.command_formatted_text().Start);
                break;

            default:
                this.compiler.Emit(OpCode.RunCommand, context.command_formatted_text().Start, new Operand(composedString), new Operand(expressionCount));
                break;
            }

            return(0);
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="YarnSpinnerParser.command_statement"/>.
 /// <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 VisitCommand_statement([NotNull] YarnSpinnerParser.Command_statementContext context)
 {
     return(VisitChildren(context));
 }
 /// <summary>
 /// Exit a parse tree produced by <see cref="YarnSpinnerParser.command_statement"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitCommand_statement([NotNull] YarnSpinnerParser.Command_statementContext context)
 {
 }