All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class mathbus.parse.MBConvert

java.lang.Object
   |
   +----mathbus.parse.MBConvert

public class MBConvert
extends Object
Class to encapsulate converters to and from the MathBus term structure and formats of various algebra systems (and other systems).

See Also:
Node, YYMBMapleParse, YYMBMathematicaParse

Variable Index

 o debugLevel
 o eBase64Code
 o eMaple
 o eMathematica
 o eMBParenAscii
 o ErrorString
 o MapleFunctions
 o MathematicaFunctions
 o theParsedNode
The parser classes will copy the constructed tree to this variable.
 o UnicodeAscii

Constructor Index

 o MBConvert()
 o MBConvert(int)
Constructs a convert object with Lex and Bison debug information switched on according to the given debugInfo.

Method Index

 o charEscape(int)
Converts the decimal value of an ascii character into either a single character string or an escape sequence if not an ascii character.
 o convertUnicode(String)
Converts a unicode string to an Ascii string translating the Greek letters and other strange things in to sequences of ascii characters.
 o DeclFunctionName(String, String, String)
 o getMathematicaFunctionName(Node)
Translates a mathbus name into a Mathematica name for the special functions; if no special name is found, the identifier corresponding to the label is returned.
 o MapleNoSquotesNecessary(String)
Checks whether the string s can be used as a Maple identifier without enclosing ` and `.
 o MathematicaNoQuotesNecessary(String)
 o parseNode(InputStream, int)
Parses the underlying MathBus tree from the InputStream stream, assuming that the input is given in a syntax specified by parseMode, which can be one of: eBase64Code, eMBParenAscii, eMaple, eMathematica at the moment.
 o printInSyntax(Node, OutputStream, int)
Prints the Node n in a syntax corresponding to the one given by printMode to the OutputStream stream.
 o printMapleAbstractedAlgFun(Node, OutputStream)
Prints a functional expression containing lambda abstractions in the Maple format.
 o printMapleInfixSubterms(SubtermEnumeration, OutputStream, String, int)
 o printMapleNode(Node, OutputStream)
The major function to print a Node in Maple syntax.
 o printMapleNodeRec(Node, OutputStream, int)
Recursive function to print a Node in Maple syntax.
 o printMathematicaAppliedAlgFun(Node, OutputStream)
Prints the application of a function to its arguments in Mathematica syntax.
 o printMathematicaInfixSubterms(SubtermEnumeration, OutputStream, String, int)
 o printMathematicaNode(Node, OutputStream)
The major function to print a Node in Mathematica syntax.
 o printMathematicaNodeRec(Node, OutputStream, int)
 o printString(String, OutputStream)
Prints the low-byte part of the (unicode) string to the stream.
 o stringEscape(String)
Converts a unicode string to an Ascii string escaping the non-ascii characters.
 o UnicodeAsciiRel(int, String)

Variables

 o debugLevel
 protected int debugLevel
 o eBase64Code
 public static final int eBase64Code
 o eMBParenAscii
 public static final int eMBParenAscii
 o eMaple
 public static final int eMaple
 o eMathematica
 public static final int eMathematica
 o theParsedNode
 public static Node theParsedNode
The parser classes will copy the constructed tree to this variable. The constructed tree inside the parsers is stored in yyval, but this variable is protected and thus cannot be accessed by MBConvert. Therefore MBConvert provides a public variable that can be accessed by the parsers.

See Also:
YYMBMapleParse, yyval, parseNode
 o UnicodeAscii
 public static Hashtable UnicodeAscii
 o MapleFunctions
 public static Hashtable MapleFunctions
 o MathematicaFunctions
 public static Hashtable MathematicaFunctions
 o ErrorString
 public static String ErrorString

Constructors

 o MBConvert
 public MBConvert()
 o MBConvert
 public MBConvert(int debugInfo)
Constructs a convert object with Lex and Bison debug information switched on according to the given debugInfo. (debugInfo = 0 is no debug Information, debugInfo > 0 gives some.)

Methods

 o UnicodeAsciiRel
 protected static void UnicodeAsciiRel(int uni,
                                       String str)
 o DeclFunctionName
 protected static void DeclFunctionName(String mb,
                                        String maple,
                                        String math)
 o parseNode
 public synchronized Node parseNode(InputStream stream,
                                    int parseMode)
Parses the underlying MathBus tree from the InputStream stream, assuming that the input is given in a syntax specified by parseMode, which can be one of: eBase64Code, eMBParenAscii, eMaple, eMathematica at the moment.

Parameters:
stream - the input stream
parseMode - the syntax the data in the stream are supposed to be in
Returns:
the parsed structure as a mathbus term structure
See Also:
printInSyntax, eBase64Code, eMBParenAscii, eMaple, eMathematica
 o printInSyntax
 public static void printInSyntax(Node n,
                                  OutputStream stream,
                                  int printMode) throws NodeException, IOException
Prints the Node n in a syntax corresponding to the one given by printMode to the OutputStream stream.

Parameters:
n - the node to be printed
stream - the used output stream
printMode - the syntax to be used
Throws: NodeException
the mathbus term structure contains commands that cannot be converted into the given syntax
Throws: IOException
indicates problems writing to stream
See Also:
parseNode, eBase64Code, eMBParenAscii, eMaple, eMathematica
 o printMapleNode
 public static void printMapleNode(Node n,
                                   OutputStream stream) throws NodeException, IOException
The major function to print a Node in Maple syntax.

 o printMapleNodeRec
 protected static void printMapleNodeRec(Node n,
                                         OutputStream stream,
                                         int topPrecedence) throws NodeException, IOException
Recursive function to print a Node in Maple syntax. Precidence levels are used to control the generation of parentheses in the output.
Precedences:
5: EquationEqual
10: Plus
20: Times
30: Exponentiate

 o printMapleAbstractedAlgFun
 protected static void printMapleAbstractedAlgFun(Node n,
                                                  OutputStream stream) throws NodeException, IOException
Prints a functional expression containing lambda abstractions in the Maple format. (Will always use -> or unapply even for the special functions in order to allow Currying.)

 o MapleNoSquotesNecessary
 public static boolean MapleNoSquotesNecessary(String s)
Checks whether the string s can be used as a Maple identifier without enclosing ` and `.

 o convertUnicode
 public static String convertUnicode(String uni)
Converts a unicode string to an Ascii string translating the Greek letters and other strange things in to sequences of ascii characters.

 o stringEscape
 public static String stringEscape(String uni)
Converts a unicode string to an Ascii string escaping the non-ascii characters.

 o charEscape
 public static String charEscape(int c)
Converts the decimal value of an ascii character into either a single character string or an escape sequence if not an ascii character.

 o printMapleInfixSubterms
 protected static void printMapleInfixSubterms(SubtermEnumeration enum,
                                               OutputStream stream,
                                               String infixOp,
                                               int topPrecedence) throws IOException, NodeException
 o printString
 public static void printString(String s,
                                OutputStream stream) throws IOException
Prints the low-byte part of the (unicode) string to the stream. Because of the unicode encoding no truncation occurs for iso-latin1 characters.

 o printMathematicaNode
 public static void printMathematicaNode(Node n,
                                         OutputStream stream) throws NodeException, IOException
The major function to print a Node in Mathematica syntax.

 o printMathematicaNodeRec
 protected static void printMathematicaNodeRec(Node n,
                                               OutputStream stream,
                                               int topPrecedence) throws NodeException, IOException
 o printMathematicaAppliedAlgFun
 protected static void printMathematicaAppliedAlgFun(Node n,
                                                     OutputStream stream) throws NodeException, IOException
Prints the application of a function to its arguments in Mathematica syntax.

 o getMathematicaFunctionName
 public static String getMathematicaFunctionName(Node n) throws NodeException
Translates a mathbus name into a Mathematica name for the special functions; if no special name is found, the identifier corresponding to the label is returned.

 o MathematicaNoQuotesNecessary
 public static boolean MathematicaNoQuotesNecessary(String s)
 o printMathematicaInfixSubterms
 protected static void printMathematicaInfixSubterms(SubtermEnumeration enum,
                                                     OutputStream stream,
                                                     String infixOp,
                                                     int topPrecedence) throws IOException, NodeException

All Packages  Class Hierarchy  This Package  Previous  Next  Index