Beispiel #1
0
    private static void AddSynonymsToScope(string name, parameter inst)
    {
        var sl      = new StackLocation(name, scopeDepth, inst);
        var keyname = name.FirstWord();

        if (scope.ContainsKey(keyname))
        {
            scope[keyname].Add(sl);
        }
        else
        {
            scope.Add(keyname, new List <StackLocation>()
            {
                sl
            });
        }
    }
Beispiel #2
0
    // 0) er, traditionally, upon a func call, the previous func's vars temporarily disappear from scope....
    // 1) But didn't an early doc of complish allow referencing anything up the call stack? Meaning, the "current past"?
    // 2) And doesn't the current doc say we can "take" return values from already-returned calls?  The "recent past"?
    // Well, if a func is called from multiple places, the "inherited locals" will be different.

    /// <summary> When parsing the (invocation of) a simple noun, like a variable name or a local parameter name.</summary>
    public static instance MatchToNamedStackLocation(List <string> words)
    {
        string firstWord = words[index];

        if (!scope.ContainsKey(firstWord))
        {
            return(null);
        }
        var           possibles        = scope[firstWord];
        StackLocation bestmatch        = null;
        int           MostWordsMatched = 0;
        bool          conflict         = false;

        foreach (StackLocation sl in possibles)
        {
            if (!Program.Match(words, sl.name))
            {
                continue;
            }
            if (Program.MatchCount < MostWordsMatched)
            {
                continue;
            }
            // Accept an unconditional match if 1) it matches the most words, or 2) it matches the same number but is nested deeper (more local)
            if (bestmatch != null)
            {
                conflict = (MostWordsMatched == Program.MatchCount && bestmatch.depth == sl.depth);                    // avoid null deref
            }
            if (!conflict)
            {
                MostWordsMatched = Program.MatchCount;
                bestmatch        = sl;
            }
        }
        if (conflict)
        {
            Console.WriteLine("  multiple interpretations of the {1} words '{0}'", Program.Say(words, 0, MostWordsMatched), MostWordsMatched);
            return(null);
        }
        index += MostWordsMatched;
        return(new instance()
        {
            var = bestmatch.inst, toAccess = Indirectedness.local_parameter, type = bestmatch.inst.type
        });
    }
Beispiel #3
0
 public static void SetStackLocation(DependencyObject obj, StackLocation value)
 {
     obj.SetValue(StackLocationProperty, value);
 }
 public static void SetStackLocation(DependencyObject obj, StackLocation value)
 {
     obj.SetValue(StackLocationProperty, value);
 }
 public static void SetStackLocation(IndexingStackPanel element, StackLocation value)
 {
     element.SetValue(StackLocationProperty, value);
 }