Class Parser



  • public class Parser
    extends Scanner
    Create an expression of the ASTNode class-hierarchy from a math formulas string representation See Operator -precedence parser for the idea, how to parse the operators depending on their precedence.
    • Constructor Detail

      • Parser

        public Parser​()
        Instantiates a new parser.
      • Parser

        public Parser​(boolean relaxedSyntax)
               throws SyntaxError
        Instantiates a new parser.
        Parameters:
        relaxedSyntax - if true, use '('...')' as brackets for arguments
        Throws:
        SyntaxError - the syntax error
      • Parser

        public Parser​(org.matheclipse.parser.client.ast.IParserFactory factory,
                      boolean relaxedSyntax)
               throws SyntaxError
        Instantiates a new parser.
        Parameters:
        factory - the factory
        relaxedSyntax - if true, use '('...')' as brackets for arguments
        Throws:
        SyntaxError - the syntax error
    • Method Detail

      • setFactory

        public void setFactory​(org.matheclipse.parser.client.ast.IParserFactory factory)
        Sets the factory.
        Parameters:
        factory - the new factory
      • getFactory

        public org.matheclipse.parser.client.ast.IParserFactory getFactory​()
        Gets the factory.
        Returns:
        the factory
      • parse

        public org.matheclipse.parser.client.ast.ASTNode parse​(java.lang.String expression)
                                                        throws SyntaxError
        Parse the given expression String into an ASTNode.
        Parameters:
        expression - a formula string which should be parsed.
        Returns:
        the parsed ASTNode representation of the given formula string
        Throws:
        SyntaxError - the syntax error