Ejemplo n.º 1
0
        public void xBimSelectFunctionsWithStrings()
        {
            var grammar = new xBimQueryLanguage();
            var language = new LanguageData(grammar);
            var parser = new Parser(language);

            MustRunOk(parser, "select @12275.Representation.Representations.Where(Identifier=='Body')");
            MustRunOk(parser, "select @12275.Representation.Representations.Where(Identifier==\"Body\")");
        }
Ejemplo n.º 2
0
 public void xBimMultipleSelectRoots()
 {
     var grammar = new xBimQueryLanguage();
     var language = new LanguageData(grammar);
     var parser = new Parser(language);
     MustRunOk(parser, "select @IfcWall,IfcWallStandardCase.Where()");
     MustRunOk(parser, "select @IfcWall,IfcWallStandardCase,3.Where()");
     MustRunOk(parser, "select @3,IfcWallStandardCase,7.Where()");
 }
Ejemplo n.º 3
0
        public void xBimSimpleSelectRoots()
        {
            var grammar = new xBimQueryLanguage();
            var language = new LanguageData(grammar);
            var parser = new Parser(language);

            // basic root elements
            MustRunOk(parser, "select @IfcWall");  // all walls
            MustRunOk(parser, "select @3"); // ifclabel 3
            MustRunKO(parser, "select @-3"); // should fail
        }
Ejemplo n.º 4
0
 public void xBimSimpleChildren()
 {
     var grammar = new xBimQueryLanguage();
     var language = new LanguageData(grammar);
     var parser = new Parser(language);
     // chidren and functions
     MustRunOk(parser, "select @3.HasOpenings");
     MustRunOk(parser, "select @IfcWall.Where(false)");
     MustRunOk(parser, "select @*.Where(false)"); // seelct all
     MustRunOk(parser, "select @.HasOpenings"); // start from default element
 }
Ejemplo n.º 5
0
        public void xBimSelectBasicTree()
        {
            var grammar = new xBimQueryLanguage();
            var language = new LanguageData(grammar);
            var parser = new Parser(language);

            MustRunOk(parser, "select @IfcWall.HasOpenings");
            MustRunOk(parser, "select @IfcWall.HasOpenings.RelatedOpeningElement");
            MustRunKO(parser, "select @IfcWall/2"); // this one must fail.
            MustRunOk(parser, "(select @IfcWall.Count())/2"); // this sintax is ok
        }
Ejemplo n.º 6
0
        public void xBimSelectFunctions()
        {
            var grammar = new xBimQueryLanguage();
            var language = new LanguageData(grammar);
            var parser = new Parser(language);

            MustRunOk(parser, "select @itemOne.Where(true)");
            MustRunKO(parser, "select @itemOne.InvalidFunctionName(true)"); // this one musn't match
            MustRunOk(parser, "select @itemOne.Where(true).Range(0)");
            MustRunOk(parser, "select @itemOne.Range(0).ChildProp.Range(2,2)");
            MustRunOk(parser, "select @itemOne.Where(price>35.50)");
            MustRunOk(parser, "select @itemOne.Where(price>35.50 && lenght==1)");
            MustRunOk(parser, "select @itemOne.Where(function(param)>35.50 && function2(par1, par2))");
            MustRunOk(parser, "select @itemOne.Where(function(param)>35.50 || (function2(par2) && Function3(tre)))");
        }
Ejemplo n.º 7
0
        public static object Query(this XbimModel model, string query)
        {
            var grammar = new xBimQueryLanguage(model);
            var _language = new LanguageData(grammar);
            var parser = new Irony.Parsing.Parser(_language);
            ParseTree _parseTree = parser.Parse(query);

            if (_parseTree.ParserMessages.Count > 0)
                return null;

            var iRunner = _language.Grammar as ICanRunSample;
            var args = new RunSampleArgs(_language, query, _parseTree);

            // string output = iRunner.RunSample(args);
            return grammar.Run(args);
        }