Beispiel #1
0
        public override ResultSentence <string> GetPL1UniverseIdentifier(IWorldPL1Structure pL1WorldStructure, Dictionary <string, string> dictVariables)
        {
            PL1Structure       pl1Structure = pL1WorldStructure.GetPl1Structure();
            ConstDictionary    constDict    = pl1Structure.GetConsts();
            FunctionDictionary funcDict     = pl1Structure.GetFunctions();
            ResultSentence <List <string> > universeIdentifier = GetUniverseIdentifier(Arguments, pL1WorldStructure, dictVariables);
            ListDictionary listDict = funcDict.TryGetValue(Name);

            if (pL1WorldStructure is IWorldSignature worldSignature)
            {
                Signature signature = worldSignature.GetSignature();
                if (!signature.Functions.Any(elem => elem.Item1 == Name && elem.Item2 == Arguments.Count))
                {
                    return(ResultSentence <string> .CreateResult(EValidationResult.UnknownSymbol, false, "", "Function " + Name + " not found in signature."));
                }
            }

            if (!universeIdentifier.IsValid)
            {
                return(ResultSentence <string> .CreateResult(universeIdentifier.ValidationResult, false, universeIdentifier.Value.FirstOrDefault(), universeIdentifier.ErrorMessage));
            }

            string result = listDict.TryGetValue(universeIdentifier.Value);

            return(ResultSentence <string> .CreateResult(true, result));
        }
Beispiel #2
0
        public string GetWorldConstant(IWorldPL1Structure pL1WorldStructure, Dictionary <string, string> dictVariables)
        {
            PL1Structure            pl1Structure       = pL1WorldStructure.GetPl1Structure();
            ConstDictionary         constDict          = pl1Structure.GetConsts();
            FunctionDictionary      funcDict           = pl1Structure.GetFunctions();
            Result <List <string> > universeIdentifier = GetUniverseIdentifier(Arguments, pL1WorldStructure, dictVariables);
            ListDictionary          listDict           = funcDict.TryGetValue(Name);

            string result = listDict.TryGetValue(universeIdentifier.Value);

            foreach (KeyValuePair <string, string> valuePair in constDict)
            {
                if (result == valuePair.Value)
                {
                    return(valuePair.Key);
                }
            }

            return("WorldConstant not found");
        }