Beispiel #1
0
 public TermInterpreter(PlanningParser.NumericSettingContext numericSettingContext, PlanningParser.TypeDefineContext typeDefineContext,
                        PlanningParser.ObjectDeclarationContext objDecContext)
 {
     BuildNumericConst(numericSettingContext);
     BuildTypeDict(typeDefineContext);
     BuildConstTypeMap(objDecContext);
 }
Beispiel #2
0
        public override void EnterObjectDeclaration(PlanningParser.ObjectDeclarationContext context)
        {
            var listNameContext = context.listName();

            Problem.BuildConstantTypeMap(listNameContext);
            Problem.BuildGroundPredicate();
            Problem.BuildGroundAction();
        }
Beispiel #3
0
        private void BuildConstTypeMap(PlanningParser.ObjectDeclarationContext context)
        {
            _constTypeDict     = new StringDictionary();
            _typeConstListDict = new Dictionary <string, IList <string> >();

            _constTypeDict.Add(Agent1Id, PlanningType.AgentType.Name);
            _constTypeDict.Add(Agent2Id, PlanningType.AgentType.Name);
            _typeConstListDict.Add(PlanningType.AgentType.Name, new List <string> {
                Agent1Id, Agent2Id
            });

            foreach (var pair in _typeDict)
            {
                if (pair.Value is PlanningNumericType)
                {
                    PlanningNumericType type      = pair.Value as PlanningNumericType;
                    List <string>       constList = new List <string>(type.Max - type.Min + 1);
                    for (int i = type.Min; i <= type.Max; i++)
                    {
                        constList.Add(i.ToString());
                    }
                    _typeConstListDict.Add(type.Name, constList);
                }
            }

            if (context != null)
            {
                var listNameContext = context.listName();
                do
                {
                    string type = listNameContext.type() != null
                        ? listNameContext.type().GetText()
                        : PlanningType.ObjectType.Name;

                    IList <string> constList;

                    if (_typeConstListDict.ContainsKey(type))
                    {
                        constList = _typeConstListDict[type];
                    }
                    else
                    {
                        constList = new List <string>(listNameContext.NAME().Count);
                        _typeConstListDict.Add(type, constList);
                    }

                    foreach (var nameNode in listNameContext.NAME())
                    {
                        _constTypeDict.Add(nameNode.GetText(), type);
                        constList.Add(nameNode.GetText());
                    }

                    listNameContext = listNameContext.listName();
                } while (listNameContext != null);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="PlanningParser.objectDeclaration"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitObjectDeclaration([NotNull] PlanningParser.ObjectDeclarationContext context)
 {
 }