archivesOfToyLang/tshunhue/中秋節相關東西/pattern_pair.py

20 lines
732 B
Python
Raw Normal View History

2023-09-30 22:30:08 +08:00
#!/usr/bin/env python3
# pattern pair
ptn_pair = [
('L_PARA', "[(]"),
('R_PARA', "[)]"),
('POS_INT', "[+]?\d+"),
('NEG_INT', "[-]\d+"),
('ZER_INT', "0+"),
('BOOL', "#[tf]"),
('DOUBLE', "[+-]?([0-9]*[.])?[0-9]+"),
('STR', '\\"(([^\\\\]|\\\\)+)\\"'),
('FUNC_INF', '->'), # operator
('OP', '[+\-*/]'), # operator
('SYMBOL', "[a-zA-Z_%][a-zA-Z0-9_%+*/\-]*"), #SYMBOL
('CMT', ";.*"), #COMMENT
('WS', "([ ]|\t)+"), # Whitespace
('NL', "\n"), # Newline
('ELSE', ".+"), # elsewhere
]