Exemplo n.º 1
0
        public Variable GetVariable(string name, ParserRuleContext ctx)
        {
            if (ctx.GetType().IsAssignableFrom(StatementContextType) &&
                _environmentsByContext.TryGetValue(ctx, out var env))
            {
                return(env.GetVariable(name));
            }

            var statementAncestor = ctx.FindParentOfType <QuestScriptParser.StatementContext>();

            if (statementAncestor != null &&
                _environmentsByContext.TryGetValue(statementAncestor, out var statementEnvironment))
            {
                return(statementEnvironment.GetVariable(name));
            }

            return(null);
        }
Exemplo n.º 2
0
 public static bool HasParentOfType <TParent>(this ParserRuleContext ctx) where TParent : ParserRuleContext
 {
     return(ctx.FindParentOfType <TParent>() != null);
 }