Пример #1
0
        public void TestScope2()
        {
            MemoryStream   ms   = Content.GenerateContent2();
            MiniZincLexer  scnr = new MiniZincLexer(ms);
            MiniZincParser pars = new MiniZincParser(scnr);

            pars.Parse();
            ZincModel model = pars.Result;

            Assert.IsNotNull(model);
            model.CloseScope(null);
            ZincIdentNameRegister zinr     = model.NameRegister;
            List <IZincIdent>     iz       = zinr.Elements().ToList();
            List <string>         result   = iz.Select(x => x.Name).ToList();
            List <string>         expected = new List <string> (new string[] { "size", "d", "total", "end" });

            Assert.AreEqual(expected.Count, result.Count);
            foreach (string si in expected)
            {
                Assert.Contains(si, result);
            }
            Assert.AreEqual(6, model.Items.Count());
            Assert.AreEqual(5, model.Items.OfType <ZincVarDeclItem> ().Count());
            Assert.AreEqual(1, model.Items.OfType <ZincSolveItem> ().Count());
            List <ZincVarDeclItem> zvd = new List <ZincVarDeclItem> ();

            foreach (string si in expected)
            {
                ZincVarDeclItem zvdi = model.Items.OfType <ZincVarDeclItem> ().Where(x => x.DeclaredIdentifier.Name == si).FirstOrDefault();
                Assert.NotNull(zvdi);
                Assert.Contains(zvdi.DeclaredIdentifier, iz);
                zvd.Add(zvdi);
            }
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZincScopeElementBase"/> class with a given initial name register.
 /// </summary>
 /// <param name="nameRegister">The name register that will store the identifiers defined in this scope.</param>
 protected ZincScopeElementBase(ZincIdentNameRegister nameRegister = null)
 {
     if (nameRegister != null) {
         this.nameRegister = nameRegister;
     } else {
         this.nameRegister = new ZincIdentNameRegister (null);
     }
 }
Пример #3
0
 protected ZincFileBase(ZincIdentNameRegister nameRegister = null)
     : base(nameRegister)
 {
 }
Пример #4
0
 protected ZincFileBase(ZincIdentNameRegister nameRegister = null) : base(nameRegister)
 {
 }