Ejemplo n.º 1
0
        protected FIPASLParserResult parseFipaSLExpression(string content)
        {
            FIPASLParserResult result = new FIPASLParserResult();

            FipaSLLexer lex = new FipaSLLexer(new AntlrInputStream(content));
            CommonTokenStream tokens = new CommonTokenStream(lex);
            FipaSLParser parser = new FipaSLParser(tokens);
            parser.content();
            MascaretApplication.Instance.VRComponentFactory.Log("Parsing  : " + content);
            MascaretApplication.Instance.VRComponentFactory.Log("Nb Erreur : " + parser.NumberOfSyntaxErrors);

            if (parser.isAction)
            {

                result.success = true;
                result.isAction = parser.isAction;
                result.isDone = parser.done;
                result.isStarted = parser.started;
                FIPAAction action = new FIPAAction();

                action.actionName = parser.actionName;
                action.performer = parser.performer;
                action.paramName = new List<string>();
                action.paramValue = new List<string>();
                action.paramName = parser.paramName;
                action.paramValue = parser.paramValue;
                MascaretApplication.Instance.VRComponentFactory.Log("Action Name: " + action.actionName);
                MascaretApplication.Instance.VRComponentFactory.Log("Performer: " + action.performer);
                result.action = action;
                MascaretApplication.Instance.VRComponentFactory.Log("MSG : " + action.actionName);

                for (int i = 0; i < action.paramName.Count; i++)
                {
                    MascaretApplication.Instance.VRComponentFactory.Log("MSG" + (i + 2) + " : " + action.paramName[i]);
                    MascaretApplication.Instance.VRComponentFactory.Log("MSG" + (i + 3) + " : " + action.paramValue[i]);
                }
                //System.Console.WriteLine("MSG4 : " + action.paramName[1]);
                //System.Console.WriteLine("MSG5 : " + action.paramValue[1]);
            }
            else if (parser.isEqual)
            {
                if (parser.isIota)
                {
                    result.isEqual = true;
                    result.isIota = true;
                    result.iota = new FIPAIota();
                    result.iota.predicate = parser.predicateSymbol;
                    result.iota.result = parser.askedTerm;
                    result.iota.paramName = new List<string>();
                    result.iota.paramName = parser.paramName;
                    result.iota.value = parser.value;
                }
            }
            else if (parser.isIota)
            {
                result.isIota = true;
                result.iota = new FIPAIota();
                result.iota.predicate = parser.predicateSymbol;
                result.iota.result = parser.askedTerm;
                result.iota.paramName = new List<string>();
                result.iota.paramName = parser.paramName;

                MascaretApplication.Instance.VRComponentFactory.Log("IOTA : " + parser.predicateSymbol + " " + parser.askedTerm + " : " + parser.paramName.Count);

            }
            return result;
        }
        protected FIPASLParserResult parseFipaSLExpression(string content)
        {
            FIPASLParserResult result = new FIPASLParserResult();

            FipaSLLexer       lex    = new FipaSLLexer(new AntlrInputStream(content));
            CommonTokenStream tokens = new CommonTokenStream(lex);
            FipaSLParser      parser = new FipaSLParser(tokens);

            parser.content();
            MascaretApplication.Instance.VRComponentFactory.Log("Parsing  : " + content);
            MascaretApplication.Instance.VRComponentFactory.Log("Nb Erreur : " + parser.NumberOfSyntaxErrors);

            if (parser.isAction)
            {
                result.success   = true;
                result.isAction  = parser.isAction;
                result.isDone    = parser.done;
                result.isStarted = parser.started;
                FIPAAction action = new FIPAAction();

                action.actionName = parser.actionName;
                action.performer  = parser.performer;
                action.paramName  = new List <string>();
                action.paramValue = new List <string>();
                action.paramName  = parser.paramName;
                action.paramValue = parser.paramValue;
                MascaretApplication.Instance.VRComponentFactory.Log("Action Name: " + action.actionName);
                MascaretApplication.Instance.VRComponentFactory.Log("Performer: " + action.performer);
                result.action = action;
                MascaretApplication.Instance.VRComponentFactory.Log("MSG : " + action.actionName);

                for (int i = 0; i < action.paramName.Count; i++)
                {
                    MascaretApplication.Instance.VRComponentFactory.Log("MSG" + (i + 2) + " : " + action.paramName[i]);
                    MascaretApplication.Instance.VRComponentFactory.Log("MSG" + (i + 3) + " : " + action.paramValue[i]);
                }
                //System.Console.WriteLine("MSG4 : " + action.paramName[1]);
                //System.Console.WriteLine("MSG5 : " + action.paramValue[1]);
            }
            else if (parser.isEqual)
            {
                if (parser.isIota)
                {
                    result.isEqual        = true;
                    result.isIota         = true;
                    result.iota           = new FIPAIota();
                    result.iota.predicate = parser.predicateSymbol;
                    result.iota.result    = parser.askedTerm;
                    result.iota.paramName = new List <string>();
                    result.iota.paramName = parser.paramName;
                    result.iota.value     = parser.value;
                }
            }
            else if (parser.isIota)
            {
                result.isIota         = true;
                result.iota           = new FIPAIota();
                result.iota.predicate = parser.predicateSymbol;
                result.iota.result    = parser.askedTerm;
                result.iota.paramName = new List <string>();
                result.iota.paramName = parser.paramName;

                MascaretApplication.Instance.VRComponentFactory.Log("IOTA : " + parser.predicateSymbol + " " + parser.askedTerm + " : " + parser.paramName.Count);
            }
            return(result);
        }