public static void Main() { string input = "154216"; Lexer L = new IntLexer(input); try { L.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } //Задание 1 System.Console.WriteLine("\nTask 1:"); input = "0"; Lexer L1 = new NewIntLexer(input); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = ""; L1 = new NewIntLexer(input); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "365"; L1 = new NewIntLexer(input); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "-22"; L1 = new NewIntLexer(input); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "4-2"; L1 = new NewIntLexer(input); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } //Задание 2 System.Console.WriteLine("\nTask 2:"); input = ""; Lexer L2 = new IDLexer(input); try { L2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "d"; L2 = new IDLexer(input); try { L2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "da236E0"; L2 = new IDLexer(input); try { L2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "2abcd"; L2 = new IDLexer(input); try { L2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } //Задание 3 System.Console.WriteLine("\nTask 3:"); input = ""; Lexer L3 = new NewIntLexer2(input); try { L3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "25"; L3 = new NewIntLexer2(input); try { L3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "-73060"; L3 = new NewIntLexer2(input); try { L3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "012"; L3 = new NewIntLexer2(input); try { L3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // Задание 4 System.Console.WriteLine("\nTask 4:"); input = "a"; Lexer L4 = new LetterDigitLexer(input); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "a1b2c3"; L4 = new LetterDigitLexer(input); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "aa2b3c"; L4 = new LetterDigitLexer(input); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "r4c2n"; L4 = new LetterDigitLexer(input); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "0a9u5"; L4 = new LetterDigitLexer(input); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // Задание 5 System.Console.WriteLine("\nTask 5:"); input = "c"; Lexer L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "c,a,b"; L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "c,a;b,5;k"; L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "ca,g,h"; L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "a;b,c;d;e,"; L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "e,f,g;h"; L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } }
public static void Main() { string input = "154216"; Lexer L = new IntLexer(input); try { L.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // 1 System.Console.WriteLine("\n--- Tests for NumLexer --- "); string input1 = "654721"; Lexer L1 = new NumLexer(input1); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input1_1 = "00124"; Lexer L1_1 = new NumLexer(input1_1); try { L1_1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // 2 System.Console.WriteLine("\n--- Tests for IDLexer --- "); string input2 = "a154q216"; Lexer L2 = new IDLexer(input2); try { L2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input2_1 = "bbbbb"; Lexer L2_1 = new IDLexer(input2_1); try { L2_1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input2_2 = "3f67gb"; Lexer L2_2 = new IDLexer(input2_2); try { L2_2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // 3 System.Console.WriteLine("\n--- Tests for SignLexer --- "); string input3 = "-721"; Lexer L3 = new SignLexer(input3); try { L3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input3_1 = "+4561"; Lexer L3_1 = new SignLexer(input3_1); try { L3_1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input3_2 = "-004"; Lexer L3_2 = new SignLexer(input3_2); try { L3_2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // 4 System.Console.WriteLine("\n--- Tests for ALtLexer --- "); string input4 = "a4a7b4"; Lexer L4 = new AltLexer(input4); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input4_1 = "b5hh7m"; Lexer L4_1 = new AltLexer(input4_1); try { L4_1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input4_2 = "4a6n7"; Lexer L4_2 = new AltLexer(input4_2); try { L4_2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // 5 System.Console.WriteLine("\n--- Tests for DelimLexer --- "); string input5 = "a;a,b;z,r,q"; Lexer L5 = new DelimLexer(input5); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input5_1 = "b;a,t,,r,w;w"; Lexer L5_1 = new DelimLexer(input5_1); try { L5_1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input5_2 = "a;"; Lexer L5_2 = new DelimLexer(input5_2); try { L5_2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // дополнительные // 1 System.Console.WriteLine("\n--- Tests for NuSpacesLexer --- "); string input6 = "1 5 3 3 84"; Lexer L6 = new NumSpacesLexer(input6); try { L6.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input6_1 = " 5 788 1 3 9"; Lexer L6_1 = new NumSpacesLexer(input6_1); try { L6_1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input6_2 = "5 3 1 6 "; Lexer L6_2 = new NumSpacesLexer(input6_2); try { L6_2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // 2 System.Console.WriteLine("\n--- Tests for AltElemsLexer --- "); string input7 = "aa12c23dd1"; Lexer L7 = new AltElemsLexer(input7); try { L7.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input7_1 = "m6a123nm8"; Lexer L7_1 = new AltElemsLexer(input7_1); try { L7_1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input7_2 = "5pp8l12a"; Lexer L7_2 = new AltElemsLexer(input7_2); try { L7_2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // 3 System.Console.WriteLine("\n--- Tests for RealLexer --- "); string input8 = "21.455"; Lexer L8 = new RealLexer(input8); try { L8.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input8_1 = "45.124.13"; Lexer L8_1 = new RealLexer(input8_1); try { L8_1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input8_2 = "012.45"; Lexer L8_2 = new RealLexer(input8_2); try { L8_2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // 4 System.Console.WriteLine("\n--- Tests for QuoteLexer --- "); string input9 = "'meow42'"; Lexer L9 = new QuoteLexer(input9); try { L9.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input9_1 = "'nn'ehe'srh"; Lexer L9_1 = new QuoteLexer(input9_1); try { L9_1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input9_2 = "gkdgbk'aqfe'"; Lexer L9_2 = new QuoteLexer(input9_2); try { L9_2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input9_3 = "'xgfm'fgm"; Lexer L9_3 = new QuoteLexer(input9_3); try { L9_3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // 5 System.Console.WriteLine("\n--- Tests for CommentLexer --- "); string input10 = "/*pu pu* pu*/"; Lexer L10 = new CommentLexer(input10); try { L10.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input10_1 = "/*smrjr*/hjtej*/"; Lexer L10_1 = new CommentLexer(input10_1); try { L10_1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input10_2 = "/**/"; Lexer L10_2 = new CommentLexer(input10_2); try { L10_2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } string input10_3 = "/**/sndfy"; Lexer L10_3 = new CommentLexer(input10_3); try { L10_3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } }
public static void Main() { string input = "154216"; Lexer L = new IntLexer(input); try { L.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } //Задание 1 System.Console.WriteLine("\nTask 1:"); input = "0"; Lexer L1 = new NewIntLexer(input); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = ""; L1 = new NewIntLexer(input); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "365"; L1 = new NewIntLexer(input); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "-22"; L1 = new NewIntLexer(input); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "4-2"; L1 = new NewIntLexer(input); try { L1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } //Задание 2 System.Console.WriteLine("\nTask 2:"); input = ""; Lexer L2 = new IDLexer(input); try { L2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "d"; L2 = new IDLexer(input); try { L2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "da236E0"; L2 = new IDLexer(input); try { L2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "2abcd"; L2 = new IDLexer(input); try { L2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } //Задание 3 System.Console.WriteLine("\nTask 3:"); input = ""; Lexer L3 = new NewIntLexer2(input); try { L3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "25"; L3 = new NewIntLexer2(input); try { L3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "-73060"; L3 = new NewIntLexer2(input); try { L3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "012"; L3 = new NewIntLexer2(input); try { L3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // Задание 4 System.Console.WriteLine("\nTask 4:"); input = "a"; Lexer L4 = new LetterDigitLexer(input); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "a1b2c3"; L4 = new LetterDigitLexer(input); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "aa2b3c"; L4 = new LetterDigitLexer(input); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "r4c2n"; L4 = new LetterDigitLexer(input); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "0a9u5"; L4 = new LetterDigitLexer(input); try { L4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // Задание 5 System.Console.WriteLine("\nTask 5:"); input = "c"; Lexer L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "c,a,b"; L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "c,a;b,5;k"; L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "ca,g,h"; L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "a;b,c;d;e,"; L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "e,f,g;h"; L5 = new LettersLexer(input); try { L5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // Дополнительное задание 1 System.Console.WriteLine("\nExtra Task 1:"); input = "4"; Lexer LL1 = new DigitsLexer(input); try { LL1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "4 5 2"; LL1 = new DigitsLexer(input); try { LL1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "4,5 2"; LL1 = new DigitsLexer(input); try { LL1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "1 2 3 4 5"; LL1 = new DigitsLexer(input); try { LL1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "1 2 34 5 6"; LL1 = new DigitsLexer(input); try { LL1.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // Дополнительное задание 2 System.Console.WriteLine("\nExtra Task 2:"); input = "aa12c23dd1"; Lexer LL2 = new DigitsLettersGroupsLexer(input); try { LL2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "4"; LL2 = new DigitsLettersGroupsLexer(input); try { LL2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "4sd35r5d5t03ab"; LL2 = new DigitsLettersGroupsLexer(input); try { LL2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "ab0k"; LL2 = new DigitsLettersGroupsLexer(input); try { LL2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "a4bcd5e"; LL2 = new DigitsLettersGroupsLexer(input); try { LL2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "ab4c,d5e"; LL2 = new DigitsLettersGroupsLexer(input); try { LL2.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // Дополнительное задание 3 System.Console.WriteLine("\nExtra Task 3:"); input = "1.0"; Lexer LL3 = new DoubleLexer(input); try { LL3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "4"; LL3 = new DoubleLexer(input); try { LL3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "55."; LL3 = new DoubleLexer(input); try { LL3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = ".3"; LL3 = new DoubleLexer(input); try { LL3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "12.345"; LL3 = new DoubleLexer(input); try { LL3.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // Дополнительное задание 4 System.Console.WriteLine("\nExtra Task 4:"); input = "a'bcd'"; Lexer LL4 = new StringLexer(input); try { LL4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "'a'"; LL4 = new StringLexer(input); try { LL4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "'a'bcd"; LL4 = new StringLexer(input); try { LL4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "'a123bcd0'"; LL4 = new StringLexer(input); try { LL4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "'123"; LL4 = new StringLexer(input); try { LL4.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // Дополнительное задание 5 System.Console.WriteLine("\nExtra Task 5:"); input = "/*12345"; Lexer LL5 = new CommentLexer(input); try { LL5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "12/*345*/"; LL5 = new CommentLexer(input); try { LL5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "/*1234*/5"; LL5 = new CommentLexer(input); try { LL5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "/*12345*/"; LL5 = new CommentLexer(input); try { LL5.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } // Дополнительное сложное задание System.Console.WriteLine("\nHard Extra Task:"); input = "a225"; Lexer LLL = new IDListLexer(input); try { LLL.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "a225.abcd.e00e00.k"; LLL = new IDListLexer(input); try { LLL.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "a225.abcd e00e00.k"; LLL = new IDListLexer(input); try { LLL.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } input = "a225..abcd.e00e00.k"; LLL = new IDListLexer(input); try { LLL.Parse(); } catch (LexerException e) { System.Console.WriteLine(e.Message); } }