You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
333 B
15 lines
333 B
2 years ago
|
import re
|
||
|
|
||
|
def isChar(n):
|
||
|
return re.match(r'[a-z]', str(n)) is not None
|
||
|
|
||
|
def isNumber(n):
|
||
|
return re.match(r'\d+', str(n)) is not None
|
||
|
|
||
|
def getPrecedence(tok):
|
||
|
if tok == "(" or tok == "" or tok == "^":
|
||
|
return 4
|
||
|
elif tok == "*" or tok == "/":
|
||
|
return 3
|
||
|
elif tok == "+" or tok == "-":
|
||
|
return 2
|