tra-analysis/analysis-master/tra_analysis/equation/Expression.py

37 lines
888 B
Python
Raw Normal View History

2020-12-09 01:30:21 +00:00
# Titan Robotics Team 2022: Expression submodule
# Written by Arthur Lu
# Notes:
# this should be imported as a python module using 'from tra_analysis.Equation import Expression'
2020-12-09 03:56:22 +00:00
# TODO:
# - add option to pick parser backend
# - fix unit tests
2020-12-09 01:30:21 +00:00
# setup:
__version__ = "0.0.1-alpha"
__changelog__ = """changelog:
0.0.1-alpha:
2020-12-09 03:56:22 +00:00
- used the HybridExpressionParser as backend for Expression
2020-12-09 01:30:21 +00:00
"""
__author__ = (
"Arthur Lu <learthurgo@gmail.com>",
)
2020-12-09 03:56:22 +00:00
__all__ = {
"Expression"
}
2020-12-09 01:30:21 +00:00
import re
2020-12-09 03:56:22 +00:00
from .parser import BNF, RegexInplaceParser, HybridExpressionParser, Core, equation_base
2020-12-09 01:30:21 +00:00
2020-12-09 03:56:22 +00:00
class Expression(HybridExpressionParser):
2020-12-09 01:30:21 +00:00
expression = None
2020-12-09 03:56:22 +00:00
core = None
2020-12-09 01:30:21 +00:00
2020-12-09 03:56:22 +00:00
def __init__(self,expression,argorder=[],*args,**kwargs):
self.core = Core()
equation_base.equation_extend(self.core)
self.core.recalculateFMatch()
super().__init__(self.core, expression, argorder=[],*args,**kwargs)