protected static IEnumerable <NodeBase> Parse(string source) { var lexer = new LensLexer(source); var parser = new LensParser(lexer.Lexems); return(parser.Nodes); }
public void StringEscapeTest() { void TestEscape(string str, string expectedString) { var lexer = new LensLexer(str); Assert.AreEqual(lexer.Lexems.Count, 2); Assert.AreEqual(lexer.Lexems[0].Type, LexemType.String); Assert.AreEqual(lexer.Lexems[0].Value, expectedString); } TestEscape(@"""\n""", "\n"); TestEscape(@"""\t""", "\t"); TestEscape(@"""\r""", "\r"); TestEscape(@"""\\""", "\\"); TestEscape("\"\\\\\"", "\\"); }
public void CharEscapeTest() { void TestEscape(string str, string expectedChar) { var lexer = new LensLexer(str); Assert.AreEqual(lexer.Lexems.Count, 2); Assert.AreEqual(lexer.Lexems[0].Type, LexemType.Char); Assert.AreEqual(lexer.Lexems[0].Value, expectedChar); } TestEscape(@"'\n'", "\n"); TestEscape(@"'\t'", "\t"); TestEscape(@"'\r'", "\r"); TestEscape(@"'\\'", "\\"); TestEscape("'\\\\'", "\\"); }
private void Test(string str, params LexemType[] types) { var lexer = new LensLexer(str); Assert.AreEqual(types, lexer.Lexems.Select(l => l.Type).ToArray()); }