Пример #1
0
 /// <summary>
 /// Creates a WaebricParser
 /// </summary>
 /// <param name="tokenStream"></param>
 public WaebricParser(TokenIterator tokenStream)
     : base(tokenStream)
 {
     moduleParser = new ModuleParser(tokenStream);
 }
Пример #2
0
 /// <summary>
 /// Creates a WaebricParser
 /// </summary>
 /// <param name="tokenStream"></param>
 public WaebricParser(TokenIterator tokenStream)
     : base(tokenStream)
 {
     moduleParser = new ModuleParser(tokenStream);
 }
Пример #3
0
        public void ModuleParserSiteTest()
        {
            SyntaxTree tree = new SyntaxTree();

            //Create lexer to tokenize stream
            WaebricLexer lexer = new WaebricLexer(new StringReader("module test\n\nsite\n  site/index.html : home() ; site/index2.html : home()\nend"));
            lexer.LexicalizeStream();

            //Parse tokenized stream
            ModuleParser parser = new ModuleParser(lexer.GetTokenIterator());
            tree.SetRoot(parser.ParseModule());

            //Check module
            Module module = tree.GetRoot();
            Assert.IsTrue(module.GetModuleId().ToString() == "test");
            Assert.AreEqual(0, module.GetImports().Count); //No imports
            Assert.AreEqual(0, module.GetFunctionDefinitions().Count); //No function definitions
            Assert.AreEqual(1, module.GetSites().Count); //One site

            //Check site
            Site site = (Site) module.GetSites().Get(0);
            Assert.AreEqual(2, site.GetMappings().Count);
        }