01: /*************************************************************************
02: * *
03: * 1) This source code file, in unmodified form, and compiled classes *
04: * derived from it can be used and distributed without restriction, *
05: * including for commercial use. (Attribution is not required *
06: * but is appreciated.) *
07: * *
08: * 2) Modified versions of this file can be made and distributed *
09: * provided: the modified versions are put into a Java package *
10: * different from the original package, edu.hws; modified *
11: * versions are distributed under the same terms as the original; *
12: * and the modifications are documented in comments. (Modification *
13: * here does not include simply making subclasses that belong to *
14: * a package other than edu.hws, which can be done without any *
15: * restriction.) *
16: * *
17: * David J. Eck *
18: * Department of Mathematics and Computer Science *
19: * Hobart and William Smith Colleges *
20: * Geneva, New York 14456, USA *
21: * Email: eck@hws.edu WWW: http://math.hws.edu/eck/ *
22: * *
23: *************************************************************************/package edu.hws.jcm.data;
24:
25: /**
26: * A ParserExtension can be defined to add new capabilities to a
27: * standard Parser. Examples include user-defined functions and
28: * summations (using a notation of the form "sum(i, 0, n, x^n/i!)").
29: * A ParserExtension is a MathObject, so it has a name and can be
30: * registered with a Parser. When the Parser encounters the name
31: * in a string, it turns control of the parsing process over to
32: * the ParserExtension, which must parse any necessary arguments
33: * and generate any ExpressionProgram commands.
34: *
35: */
36: public interface ParserExtension extends MathObject {
37: /**
38: * Parses the part of an expression string associated with this ParserExtension.
39: * This method must add commands to context.prog that will generate exactly ONE
40: * number on the stack when they are executed. Parsing routines from the Parse class,
41: * such as parseFactor and parseExpression, can be called
42: * to parse sub-parts of the string. The name of the command
43: * has already been read from the ParseContext when doParse() is called.
44: * (At the time this is called, context.tokenString is the
45: * name under which this ParserExtension was registered with the
46: * Parser. This makes it possible to register the same ParserExtension
47: * under several names, with each name represnting a different
48: * meaning.)
49: */
50: public void doParse(Parser parser, ParserContext context);
51: }
|