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)); }
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('_')); }
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(), "$"); }
public void scanTestWorkToLong() { try { TokenScanner scanner = new TokenScanner("..\\..\\..\\TestFiles\\ScanTestWordToLong.txt"); Assert.Fail(); } catch(SyntaxError) { } }
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(), "$"); }
public void scanTestFailBadSymbol() { try { TokenScanner scanner = new TokenScanner("..\\..\\..\\TestFiles\\ScanTestFailBadSymbol.txt"); Assert.Fail(); } catch (LexicalException) { } }
public LL1Parser(string contents) { this.scanner = new TokenScanner(contents); parsetable = new ParserGenerator.ParserGenerator(); }