syntax extension to apply arbitrary scalar function

This commit is contained in:
ignis 2019-05-24 23:47:19 +09:00
parent 5abcf7ed7e
commit 92019f1268
2 changed files with 2 additions and 0 deletions

View file

@ -51,6 +51,7 @@ calc_grammar = """
| "sqrt" -> sqrt
| "abs" -> abs
| "rxn_rate" -> rxn_rate
| "$" NAME -> udf
?derivative: "ddx" -> ddx
| "d2dx" -> d2dx

View file

@ -135,6 +135,7 @@ class ExpToCode(Transformer):
sqrt = lambda self : "sqrt"
abs = lambda self : "dabs"
rxn_rate = lambda self : "rxn_rate"
udf = lambda self, a : a.value