def make_terminal(token: Token) -> Union[Const, Var]: if token.is_const(): return Const(token.value) elif token.is_var(): return Var(token.value) raise BadInput(f"Invalid token passed to make_terminal : {token}")
def variables(cls): return ( Var("destination"), Var("nexthop/(ip-address|discard)", "nexthop_type", default="ip-address"), Var("nexthop/ip-address", "nexthop"), Var("interface"), Var("admin-dist"), Var("metric", vartype="int", default=10, xmldefault=10), )
def variables(cls): return ( Var("from", "fromzone", vartype="member", default=("any", )), Var("to", "tozone", vartype="member", default=("any", )), Var("source", vartype="member", default=("any", )), Var("source-user", vartype="member", default=("any", )), Var("hip-profiles", vartype="member", default=("any", )), Var("destination", vartype="member", default=("any", )), Var("application", vartype="member", default=("any", )), Var("service", vartype="member", default=("application-default", )), Var("category", vartype="member", default=("any", )), Var("action"), Var("log-setting"), Var("log-start", vartype="bool"), Var("log-end", vartype="bool"), Var("description"), Var("rule-type", "type", default="universal"), Var("tag", vartype="member"), Var("negate-source", vartype="bool"), Var("negate-destination", vartype="bool"), Var("disabled", vartype="bool"), Var("schedule"), Var("icmp-unreachable"), Var("option/disable-server-response-inspection", vartype="bool"), Var("profile-setting/group", vartype="member"), Var("profile-setting/profiles/virus", vartype="member"), Var("profile-setting/profiles/spyware", vartype="member"), Var("profile-setting/profiles/vulnerability", vartype="member"), Var("profile-setting/profiles/url-filtering", vartype="member"), Var("profile-setting/profiles/file-blocking", vartype="member"), Var("profile-setting/profiles/wildfire-analysis", vartype="member"), Var("profile-setting/profiles/data-filtering", vartype="member"), )
from base import AbstractExpression, Globals, Var from input_parser import Parser print("Available functions: ", end='') print(*Globals.unary_operators, sep=', ', end='\n\n') print("Use x, y, or z as variables.", end='\n\n') input_string = input("Differentiate: ") var = Var(input("with respect to: ").strip()) expression: AbstractExpression = Parser(input_string).parse() print("Input parsed as: ", expression) print("Result: ", expression.dx(var).simplify())