public void Lex_sample_files_and_regenerate(string filename, string content) { // Arrange var lexer = new IlLexer(content); // Act var tokens = lexer.LexAll().ToList(); var actual = ReconstructText(tokens); // Assert Assert.Empty(tokens.Where(m => m.Kind == SyntaxKind.BadToken)); Assert.Equal(content, actual); }
public void Lex_nop_without_newline_at_end() { // Arrange var content = "nop"; var lexer = new IlLexer(content); // Act var tokens = lexer.LexAll().ToList(); // Assert Assert.Equal(2, tokens.Count); Assert.Empty(tokens.Where(m => m.Kind == SyntaxKind.BadToken)); Assert.Equal(SyntaxKind.OpCode_Nop, tokens[0].Kind); Assert.Equal(SyntaxKind.EndOfFileToken, tokens[1].Kind); }
public AbstractParser(string text) { var lexer = new IlLexer(text); _tokens = lexer.LexAll().Where(FilterTokenKind).ToArray();