1# test the lexer 2 3try: 4 eval 5 exec 6except NameError: 7 print("SKIP") 8 raise SystemExit 9 10# __debug__ is a special symbol 11print(type(__debug__)) 12 13# short input 14exec("") 15exec("\n") 16exec("\n\n") 17exec("\r") 18exec("\r\r") 19exec("\t") 20exec("\r\n") 21exec("\nprint(1)") 22exec("\rprint(2)") 23exec("\r\nprint(3)") 24exec("\n5") 25exec("\r6") 26exec("\r\n7") 27print(eval("1")) 28print(eval("12")) 29print(eval("123")) 30print(eval("1\n")) 31print(eval("12\n")) 32print(eval("123\n")) 33print(eval("1\r")) 34print(eval("12\r")) 35print(eval("123\r")) 36 37# line continuation 38print(eval("'123' \\\r '456'")) 39print(eval("'123' \\\n '456'")) 40print(eval("'123' \\\r\n '456'")) 41print(eval("'123'\\\r'456'")) 42print(eval("'123'\\\n'456'")) 43print(eval("'123'\\\r\n'456'")) 44 45# backslash used to escape a line-break in a string 46print('a\ 47b') 48 49# lots of indentation 50def a(x): 51 if x: 52 if x: 53 if x: 54 if x: 55 if x: 56 if x: 57 if x: 58 if x: 59 if x: 60 if x: 61 if x: 62 if x: 63 if x: 64 if x: 65 if x: 66 print(x) 67a(1) 68 69# badly formed hex escape sequences 70try: 71 exec(r"'\x0'") 72except SyntaxError: 73 print("SyntaxError") 74try: 75 exec(r"b'\x0'") 76except SyntaxError: 77 print("SyntaxError") 78try: 79 exec(r"'\u000'") 80except SyntaxError: 81 print("SyntaxError") 82try: 83 exec(r"'\U0000000'") 84except SyntaxError: 85 print("SyntaxError") 86