diff options
| author | 2023-11-05 02:39:00 +0800 | |
|---|---|---|
| committer | 2023-11-05 02:39:00 +0800 | |
| commit | 57188fca203643f18409b0fa71d730d771faffed (patch) | |
| tree | cb0e0990ac030f5f0012640fd7c1707b5bde1156 /tests | |
| parent | f5e118d18af7f11854ddc34d1f6f07b48b125acd (diff) | |
| download | TRPGNivis-57188fca203643f18409b0fa71d730d771faffed.tar.gz TRPGNivis-57188fca203643f18409b0fa71d730d771faffed.zip | |
chore: add Token
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/__init__.py | 23 | ||||
| -rw-r--r-- | tests/get_next_token.py | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py index e69de29..c9a0e8f 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1,23 @@ +from os.path import join, abspath, dirname + +DIR = dirname(abspath(__file__)) + +token_dict = {} # 创建一个空字典 + +with open(join(DIR, '..', 'psi', 'Grammar', 'Token'), 'r') as file: + for line in file: + if line := line.strip(): + values = line.split() # 使用空格分割行,得到值列表 + code = values[0] # 第一个值为代码 + symbol = values[1] if len(values) > 1 else None # 第二个值为符号,如果没有第二个值,则设置为None + token_dict[code] = symbol # 将代码和符号添加到字典中 + +# 将字典中的键值对转换为多个变量及其对应的值 +for code, symbol in token_dict.items(): + globals()[code] = symbol + +# 打印变量及其对应的值 +print(LPAR) +print(RPAR) +print(AWAIT) +# 其他变量...
\ No newline at end of file diff --git a/tests/get_next_token.py b/tests/get_next_token.py new file mode 100644 index 0000000..2801337 --- /dev/null +++ b/tests/get_next_token.py @@ -0,0 +1,2 @@ +class ABC: + ...
\ No newline at end of file |
