Example #1
0
        public void HasNextTest()
        {
            //Create list and add dummy tokens to it
            List<Token> tokenStream = new List<Token>();
            Token token1 = new Token();
            Token token2 = new Token();
            tokenStream.Add(token1);
            tokenStream.Add(token2);

            //Create iterator with tokenstream and then test some things out
            TokenIterator iterator = new TokenIterator(tokenStream);

            //Check size
            Assert.IsTrue(iterator.GetSize() == tokenStream.Count);

            //Check if tokens are in list
            Assert.IsTrue(iterator.HasNext());

            //Check also if there are 2 items in list
            Assert.IsTrue(iterator.HasNext(2));

            //Get first token and check

            Token CurrentToken = iterator.NextToken();
            Assert.AreEqual(token1, CurrentToken);

            //Get second token and check
            Assert.IsTrue(iterator.HasNext());
            CurrentToken = iterator.NextToken();
            Assert.AreEqual(token2, CurrentToken);

            //No items in list left
            Assert.IsFalse(iterator.HasNext());
        }
Example #2
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);
 }
Example #3
0
 public StatementParser(TokenIterator iterator)
     : base(iterator)
 {
     //Create subparsers
     predicateParser = new PredicateParser(iterator);
     expressionParser = new ExpressionParser(iterator);
     embeddingParser = new EmbeddingParser(iterator);
     markupParser = new MarkupParser(iterator);
 }
Example #4
0
 /// <summary>
 /// Creates a WaebricParser
 /// </summary>
 /// <param name="tokenStream"></param>
 public WaebricParser(TokenIterator tokenStream)
     : base(tokenStream)
 {
     moduleParser = new ModuleParser(tokenStream);
 }
Example #5
0
 public PredicateParser(TokenIterator iterator)
     : base(iterator)
 {
     //Create subparser
     expressionParser = new ExpressionParser(iterator);
 }
Example #6
0
 public void NextTokenTest()
 {
     List<Token> tokenStream = null; // TODO: Initialize to an appropriate value
     TokenIterator target = new TokenIterator(tokenStream); // TODO: Initialize to an appropriate value
     Token expected = null; // TODO: Initialize to an appropriate value
     Token actual;
     actual = target.NextToken();
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Example #7
0
 public void TokenIteratorConstructorTest()
 {
     List<Token> tokenStream = null; // TODO: Initialize to an appropriate value
     TokenIterator target = new TokenIterator(tokenStream);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Example #8
0
 public FunctionParser(TokenIterator tokenStream)
     : base(tokenStream)
 {
     //Create subparser
     statementParser = new StatementParser(tokenStream);
 }
Example #9
0
 /// <summary>
 /// Creates an AbstractParser with tokenStream and exceptionList
 /// </summary>
 /// <param name="tokenStream">Tokenized Stream</param>
 /// <param name="exceptionList">List of Exceptions</param>
 public AbstractParser(TokenIterator tokenStream)
 {
     this.TokenStream = tokenStream;
 }
Example #10
0
 public MarkupParser(TokenIterator iterator)
     : base(iterator)
 {
     //Create parsers here
     expressionParser = new ExpressionParser(iterator);
 }
Example #11
0
 public ExpressionParser(TokenIterator iterator)
     : base(iterator)
 {
 }
Example #12
0
 /// <summary>
 /// Function to make testing possible
 /// </summary>
 /// <param name="stream">Stream to inject</param>
 public void SetEmbeddingTokenStream(TokenIterator stream)
 {
     EmbeddingTokenStream = stream;
 }
Example #13
0
 public EmbeddingParser(TokenIterator iterator)
     : base(iterator)
 {
 }
Example #14
0
        /// <summary>
        /// Parser for Embedding
        /// </summary>
        /// <returns>Parsed Embedding</returns>
        public Embedding ParseEmbedding()
        {
            //Get iterator for specific embedding
            if (TokenStream.Peek(1).GetType() == TokenType.EMBEDDING)
            {   //Store embedding in internal tokeniterator to parse internally
                CurrentToken = TokenStream.NextToken();
                EmbeddingTokenStream = ((EmbeddingToken)CurrentToken).GetTokenIterator();
            }
            else
            {   //Raise exception
                throw new UnexpectedToken("Embedding expected, but found:", CurrentToken.GetValue().ToString(), CurrentToken.GetLine());
            }

            //Let's parse embedding
            Embedding embedding = new Embedding();

            embedding.SetPreText(ParsePreText());
            embedding.SetEmbed(ParseEmbed());
            embedding.SetTextTail(ParseTextTail());

            return embedding;
        }
Example #15
0
 public SiteParser(TokenIterator tokenStream)
     : base(tokenStream)
 {
     //Create parsers
     markupParser = new MarkupParser(tokenStream);
 }