package Text::Wigwam::Expression;

# The Wigwam expression base class. This class should be inherited by all
# Wigwam Expression objects as a means for detecting such objects.
#
# The 'execute' method is the only truley required method for expression
# objects. However, it is ideal that all expression objects support all of
# the following methods to ensure full seamless interoperability.

    use strict;
    use warnings;
    our $VERSION = '0.01';

     # Should return the number of tokens within the expression.
    sub size { return '(unknown)' }

     # Should return the filename of the expression's originating template
    sub doc { return '(unknown)' }

     # Should return the name of the engine that generated the expression.
    sub engine { return '(engine unknown)'; }

     # Should execute the expression and return the result.
    sub execute { return "Weird.. ".($_[0]->_identify_engine)." has no execute method!" }

     # Should return a beautified version of the expression's code.
    sub beautify { return "(unable to display - beautify method is not implemented in ".($_[0]->_identify_engine).")" }

 # Private methods begin here
    sub _identify_engine { return $_[0]->can( 'engine' ) ? $_[0]->engine : ref($_[0]); }

1;
