-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestscanner.py
More file actions
19 lines (17 loc) · 774 Bytes
/
testscanner.py
File metadata and controls
19 lines (17 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import scanner.token as st
import scanner.scannerprocessor as sp
f_name = 'test.txt'
scanner = sp.Scanner(f_name)
if scanner.filepointer is not None:
print("token_type lexeme value ptr")
print("------------------------------------------------------")
while True: # 一次读入一个token
token = scanner.GetToken() # 以空格分开
if token.type != st.Token_Type.NONTOKEN:
print("{:20s}|{:12s}|{:12f}|{}".format(
token.type, token.lexeme, token.value, token.funcptr))
else:
break
print("The text has", scanner.LineNo, "lines.")
else:
print("File open failed")