P5-math-symbolicx-parserextensionfactory

Jul 20, 2023

Generate parser extensions

This module provides a simple way to extend the MathSymbolic parser with arbitrary functions that return any valid MathSymbolic tree. The return value of the function call is inserted into the complete parse tree at the point at which the function call is parsed. Familiarity with the MathSymbolic module will be assumed throughout the documentation.

This module is not object oriented. It does not export anything. You should not call any subroutines directly nor should you modify any class data directly. The complete interface is the call to use MathSymbolicXParserExtensionFactory and its arguments. The reason for the long module name is that you should not have to call it multiple times in your code because it modifies the parser for good. It is intended to be a pain to type. -

The aim of the module is to allow for hooks into the parser without modifying the parser yourself because that requires rather in-depth knowledge of the module code. By specifying key => value pairs of function names and function implementations code references as arguments to the use call of the module, this module extends the parser that is stored in the $MathSymbolicParser variable with the specified functions and whenever “yourfunctionany argument string not containing an unescaped \ “ occurs in the code, the subroutine reference is called with the argument string as argument.

The subroutine is expected to return any MathSymbolic tree. That means, as of version 0.133, a MathSymbolicOperator, a MathSymbolicVariable, or a MathSymbolicConstant object. The returned object will be incorporated into the MathSymbolic tree that results from the parse at the exact position at which the custom function call was parsed.

Please note that the usage of this module will be quite slow at compile time because it has to regenerate the complete MathSymbolic parser the first time you use this module in your code. The run time performance penalty should be low, however.



Checkout these related ports:
  • Zn_poly - C library for polynomial arithmetic
  • Zimpl - Language to translate the LP models into .lp or .mps
  • Zegrapher - Software for plotting mathematical objects
  • Zarray - Dynamically typed N-D expression system based on xtensor
  • Z3 - Z3 Theorem Prover
  • Yices - SMT solver
  • Yacas - Yet Another Computer Algebra System
  • Xtensor - Multi-dimensional arrays with broadcasting and lazy computing
  • Xtensor-python - Python bindings for xtensor
  • Xtensor-io - Xtensor plugin to read/write images, audio files, numpy npz and HDF5
  • Xtensor-blas - BLAS extension to xtensor
  • Xspread - Spreadsheet program for X and terminals
  • Xppaut - Graphical tool for solving differential equations, etc
  • Xplot - X11 plotting package
  • Xlife++ - XLiFE++ eXtended Library of Finite Elements in C++