Пример #1
0
        public void isaLetterTest()
        {
            TokenScanner scanner = new TokenScanner();
            Assert.IsTrue(scanner.isaLetter('a'));
            Assert.IsTrue(scanner.isaLetter('z'));
            Assert.IsTrue(scanner.isaLetter('q'));
            Assert.IsTrue(scanner.isaLetter('A'));
            Assert.IsTrue(scanner.isaLetter('Z'));
            Assert.IsTrue(scanner.isaLetter('S'));

            Assert.IsFalse(scanner.isaLetter('0'));
            Assert.IsFalse(scanner.isaLetter('*'));
            Assert.IsFalse(scanner.isaLetter(' '));
            Assert.IsFalse(scanner.isaLetter('~'));
            Assert.IsFalse(scanner.isaLetter((char)3));
        }
Пример #2
0
        public void isaDigitTest()
        {
            TokenScanner scanner = new TokenScanner();
            Assert.IsTrue(scanner.isaDigit('0'));
            Assert.IsTrue(scanner.isaDigit('1'));
            Assert.IsTrue(scanner.isaDigit('2'));
            Assert.IsTrue(scanner.isaDigit('3'));
            Assert.IsTrue(scanner.isaDigit('4'));
            Assert.IsTrue(scanner.isaDigit('5'));
            Assert.IsTrue(scanner.isaDigit('6'));
            Assert.IsTrue(scanner.isaDigit('7'));
            Assert.IsTrue(scanner.isaDigit('8'));
            Assert.IsTrue(scanner.isaDigit('9'));

            Assert.IsFalse(scanner.isaDigit('a'));
            Assert.IsFalse(scanner.isaDigit('_'));
        }
Пример #3
0
 public void scanBreakUp()
 {
     TokenScanner scanner = new TokenScanner("..\\..\\..\\TestFiles\\ScanTestBreakUp.txt");
     Assert.AreEqual(scanner.peekToken(), "break");
     Assert.AreEqual(scanner.getToken(), "break");
     Assert.AreEqual(scanner.getToken(), "(");
     Assert.AreEqual(scanner.getToken(), "up");
     Assert.AreEqual(scanner.getToken(), ")");
     Assert.AreEqual(scanner.getToken(), "(");
     Assert.AreEqual(scanner.getToken(), "this");
     Assert.AreEqual(scanner.getToken(), ")");
     Assert.AreEqual(scanner.getToken(), "(");
     Assert.AreEqual(scanner.getToken(), ")");
     Assert.AreEqual(scanner.getToken(), ";");
     Assert.AreEqual(scanner.getToken(), "l");
     Assert.AreEqual(scanner.getToken(), ";");
     Assert.AreEqual(scanner.getToken(), "ol");
     Assert.AreEqual(scanner.getToken(), "$");
     Assert.AreEqual(scanner.peekToken(), "$");
 }
Пример #4
0
        public void scanTestWorkToLong()
        {
            try
            {
                TokenScanner scanner = new TokenScanner("..\\..\\..\\TestFiles\\ScanTestWordToLong.txt");
                Assert.Fail();
            }
            catch(SyntaxError)
            {

            }
        }
Пример #5
0
 public void scanTestPass()
 {
     TokenScanner scanner = new TokenScanner("..\\..\\..\\TestFiles\\scanTestPass.txt");
     Assert.AreEqual(scanner.getToken(), "begin");
     Assert.AreEqual(scanner.getToken(), "hi");
     Assert.AreEqual(scanner.getToken(), "=");
     Assert.AreEqual(scanner.getToken(), "a");
     Assert.AreEqual(scanner.getToken(), "union");
     Assert.AreEqual(scanner.getToken(), "b");
     Assert.AreEqual(scanner.getToken(), ";");
     Assert.AreEqual(scanner.getToken(), "end");
     Assert.AreEqual(scanner.getToken(), "$");
 }
Пример #6
0
        public void scanTestFailBadSymbol()
        {
            try
            {
                TokenScanner scanner = new TokenScanner("..\\..\\..\\TestFiles\\ScanTestFailBadSymbol.txt");
                Assert.Fail();
            }
            catch (LexicalException)
            {

            }
        }
Пример #7
0
 public LL1Parser(string contents)
 {
     this.scanner = new TokenScanner(contents);
     parsetable = new ParserGenerator.ParserGenerator();
 }