public override Yarn.Type VisitVariable(YarnSpinnerV1Parser.VariableContext context)
            {
                // The type of the value depends on the declared type of the
                // variable.

                // Note that we've seen a variable by this name, in case we
                // don't see it again and we never decide on a type for it
                var name = context.VAR_ID().GetText();

                this.allSeenVariables.Add(name);

                // Search our list of variable type bindings. If we have
                // precisely one binding at the moment for the variable, we
                // assume that we know its type, and return that value.
                // Otherwise, we return 'undefined' for this value (either
                // because we have no binding for this variable, or because
                // we have more than one.)
                var bindings = this.potentialTypeBindings.Where(b => b.VariableName == name);

                return(bindings.Count() != 1 ? Yarn.Type.Undefined : bindings.First().Type);
            }
Пример #2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="YarnSpinnerV1Parser.variable"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitVariable([NotNull] YarnSpinnerV1Parser.VariableContext context)
 {
 }
 /// <summary>
 /// Visit a parse tree produced by <see cref="YarnSpinnerV1Parser.variable"/>.
 /// <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 VisitVariable([NotNull] YarnSpinnerV1Parser.VariableContext context)
 {
     return(VisitChildren(context));
 }