Esempio n. 1
0
 /// <summary>
 /// Create a ModuleParser
 /// </summary>
 /// <param name="tokenStream"></param>
 /// <param name="exceptionList"></param>
 public ModuleParser(TokenIterator tokenStream)
     : base(tokenStream)
 {
     //Create parsers for sub elements in a module
     siteParser = new SiteParser(tokenStream);
     functionParser = new FunctionParser(tokenStream);
 }
Esempio n. 2
0
        public void ParseDirectoryNameTest()
        {
            //Get tokens and parse it
            TokenIterator tokens = Init("home\\site\\test.wae");
            SiteParser siteParser = new SiteParser(tokens);
            DirName output = siteParser.ParseDirectoryName();
            Dir directory = output.GetDirectory();

            //Check output
            Assert.AreEqual(2, directory.GetDirectoryElements().Count);

            //Get directory's and transfer to array to provide walking
            List<ISyntaxNode>.Enumerator directoryEnumerator = directory.GetDirectoryElements().GetEnumerator();

            //Check directory's
            directoryEnumerator.MoveNext();
            Assert.AreEqual("home", ((PathElement)directoryEnumerator.Current).GetPathElement());
            directoryEnumerator.MoveNext();
            Assert.AreEqual("site", ((PathElement)directoryEnumerator.Current).GetPathElement());
        }
Esempio n. 3
0
 /// <summary>
 /// Create a ModuleParser
 /// </summary>
 /// <param name="tokenStream"></param>
 /// <param name="exceptionList"></param>
 public ModuleParser(TokenIterator tokenStream) : base(tokenStream)
 {
     //Create parsers for sub elements in a module
     siteParser     = new SiteParser(tokenStream);
     functionParser = new FunctionParser(tokenStream);
 }
Esempio n. 4
0
        public void ParseDirectoryTest()
        {
            //Get tokens and parse it
            TokenIterator tokens = Init("directory1\\directory2\\filename.ext");
            SiteParser siteParser = new SiteParser(tokens);
            Dir output = siteParser.ParseDirectory();

            //Check output
            Assert.AreEqual(2, output.GetDirectoryElements().Count);

            //Check directory's
            Assert.AreEqual("directory1", output.GetDirectoryElements().Get(0).ToString());
            Assert.AreEqual("directory2", output.GetDirectoryElements().Get(1).ToString());
        }
Esempio n. 5
0
        public void ParseSiteTest()
        {
            //Get tokens and parse it
            SiteParser siteParser = new SiteParser(Init("site/index.html : home(\"argument\")\nend"));
            Site parsedSite = siteParser.ParseSite();

            //Test mappings of site
            Assert.AreEqual(1, parsedSite.GetMappings().Count);
            Mapping[] mappingArray = (Mapping[]) parsedSite.GetMappings().ToArray();
            Mapping mapping = mappingArray[0];

            //Test path of site
            Assert.AreEqual("site/index.html", mapping.GetPath().ToString());

            //Test markup of site
            Markup parsedMarkup = mapping.GetMarkup();
            Assert.AreEqual("home", parsedMarkup.GetDesignator().GetIdentifier());
            Assert.AreEqual(1, parsedMarkup.GetArguments().Count);

            //Test argument
            Argument[] argumentArray = (Argument[]) parsedMarkup.GetArguments().ToArray();
            Assert.AreEqual(typeof(ExpressionArgument), argumentArray[0].GetType());
            Assert.AreEqual("argument", argumentArray[0].ToString());
        }
Esempio n. 6
0
        public void ParseSingleMappingTest()
        {
            //Set up parser
            TokenIterator tokens = Init("site/home.html : home()");
            SiteParser siteParser = new SiteParser(tokens);
            Mapping mapping = siteParser.ParseMapping();

            //Test path of site
            Assert.AreEqual("site/home.html", mapping.GetPath().ToString());

            //Test markup of site
            Markup parsedMarkup = mapping.GetMarkup();
            Assert.AreEqual("home", parsedMarkup.GetDesignator().GetIdentifier());
            Assert.AreEqual(0, parsedMarkup.GetArguments().Count);
        }
Esempio n. 7
0
        public void ParsePathTest()
        {
            //Get tokens and parse it
            TokenIterator tokens = Init("site/home.html");
            SiteParser siteParser = new SiteParser(tokens);
            Pth path = siteParser.ParsePath();

            //Get structures of path
            Dir directory = path.GetDirectoryName().GetDirectory();
            PathElement pathElement = (PathElement) directory.GetDirectoryElements().Get(0);
            FileName filename = path.GetFilename();

            //Check directory
            Assert.AreEqual(1, directory.GetDirectoryElements().Count);
            Assert.AreEqual("site", pathElement.GetPathElement());

            //Check filename
            Assert.AreEqual("home", filename.GetName().GetPathElement());
            Assert.AreEqual("html", filename.GetFileExtension().GetFileExtension());
        }
Esempio n. 8
0
        public void ParseMappingsTest()
        {
            //Set up parser
            TokenIterator tokens = Init("site/home.html : home(); site2/home.html : home2()");
            SiteParser siteParser = new SiteParser(tokens);
            Mapping[] parsedMappings = (Mapping[]) siteParser.ParseMappings().ToArray();

            //Test mappings
            Assert.AreEqual(2, parsedMappings.Length);
        }
Esempio n. 9
0
        public void ParseFileNameTest()
        {
            //Get tokens and parse it
            TokenIterator tokens = Init("filename.ext");
            SiteParser siteParser = new SiteParser(tokens);
            FileName output = siteParser.ParseFileName();

            Assert.AreEqual("filename", output.GetName().GetPathElement());
            Assert.AreEqual("ext", output.GetFileExtension().GetFileExtension());
        }