NAME

Math::SymbolicX::Calculator::Interface - Miscallaneous routines for interfaces

SYNOPSIS

Do not use this in your scripts. Use one of the ::Interface::Foo classes.

DESCRIPTION

This is very much an internal class.

This module is a base class for interfaces to Math::SymbolicX::Calculator. It is not an interface by itself. It doesn't even define stubs for all methods of an interface and as such isn't an interface definition for Calculator::Interfaces. Instead, it contains various miscellaneous methods which may be of use to classes which actually implement interfaces.

METHODS RELATED TO PARSING

These methods parse commands of a somewhat generic syntax.

When defining the form of the accepted input strings below, I'll be using certain variables:

$SYMBOL         => An identifier matching /[A-Za-z][A-Za-z0-9_]*/
$FORMULA        => String that can be parsed as a Math::Symbolic tree
$PATTERN        => String that can be parsed as a
                   Math::Symbolic::Custom::Transformation. (*)
$REPLACEMENT    => String that can be parsed as the replacement part
                   of a Math::Symbolic::Custom::Transformation (*).
$TRANSFORMATION => String that can be parsed as a transformation in
                   the calculator context. (*) This means it has the
                   following form: $PATTERN -> $REPLACEMENT
$GROUP          => A group of transformations. Grouping is done in
                   []-braces and the group elements are chained with
                   one of &, |, or ",". Form: [ $x & $x & .... ]
                   (Same for | or , but not mixed!)
                   $x is either another $GROUP, a $TRANSFORMATION
                   or a $SYMBOL in case of the latter, the symbol
                   table of the calculator is accessed to map the
                   $SYMBOL to a $TRANSFORMATION.
                   The ultimate result of parsing such a thing is a
                   Math::Symbolic::Custom::Transformation::Group
                   object (**).

(*) $PATTERNs, $REPLACEMENTs and $TRANSFORMATIONs may contain some special syntax. Instead of the TREE_foo, VAR_foo, and CONST_foo special variables: You can write ?foo, $foo and !foo respectively.

(**) Math::Symbolic::Custom::Transformation::Group objects are also Math::Symbolic::Custom::Transformations.

If errors occurr, these methods call the error() method with a description and then return the empty list.

If these methods require access to certain attributes of the interface objects, this is mentioned in the docs.

_parse_assignment

Parses an expression of one of the forms

$SYMBOL = $FORMULA
$SYMBOL = $TRANSFORMATION
$SYMBOL = $GROUP

Returns an instance of Math::SymbolicX::Calculator::Command::Assignment which assigns either a formula or a transformation(-group) when executed.

Uses $self-calc()> and expects it to return the Calculator object. Uses the _parse_trafo_group method.

_parse_transformation

This method parses expressions of the form

$SYMBOL =~ $SYMBOL2
$SYMBOL =~ $TRANSFORMATION
$SYMBOL =~ $GROUP

or

$SYMBOL =~~ $SYMBOL2 (*)
... and so on ...

(*) The =~ operator stands for recursive application of the transformation whereas the =~~ operator stands for shallow application.

These expressions generally stand for the application of the transformation given on the right to the function $SYMBOL stands for. This method returns a Math::SymbolicX::Calculator::Command::Transformation object on success or calls the error() method and returns an empty list on failure.

This methods expects $self-calc()> to return the Calculator object. It also uses the _parse_trafo_group method.

_parse_trafo_group

Parses a string of the form:

$SYMBOL
$GROUP
$TRANSFORMATION

In case of $SYMBOL, it accesses the Calculator symbol table to fetch the referenced Transformation. (And throws an error if it's not one.)

Returns a Math::Symbolic::Custom::Transformation object or calls the error() method and returns the empty list on failure.

This method uses Parse::RecDescent. Expects the calc() method to return the Calculator object. Uses the method _parse_simple_transformation.

_parse_simple_transformation

Parses a string of the form "pattern -> replacement", i.e. a simple $TRANSFORMATION.

Returns a Math::Symbolic::Custom::Transformation object or the empty list on failure.

SEE ALSO

Math::SymbolicX::Calculator, Math::SymbolicX::Calculator::Interface::Shell

AUTHOR

Steffen Müller, <smueller@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2006, 2013 by Steffen Mueller

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6 or, at your option, any later version of Perl 5 you may have available.