Documentation of 'org.statcato.calculator.TokenScanner' Java class
TokenScanner
org.statcato.calculator

Class TokenScanner



  • public class TokenScanner
    extends java.lang.Object
    A scanner that read Tokens from a string representing a mathematical expression.
    Since:
    1.0
    See Also:
    Token
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      java.lang.String error 
    • Constructor Summary

      Constructors 
      Constructor and Description
      TokenScanner(java.lang.String expr, Spreadsheet spreadsheet)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int consumeColumn()
      Consumes the column at the next scan position.
      double consumeConstant()
      Consumes the constant at the next scan position.
      int consumeFunction()
      Consumes the function at the next scan position.
      double consumeNumber()
      Consumes the number at the next scan position.
      void consumeToken()
      Consumes the current token by advancing the index to the next position.
      void error(java.lang.String msg)
      Adds the given string to the error string.
      boolean expect(java.lang.String name) 
      int getColumn()
      Attempts to parse a column label and returns the column number if successful.
      double getConstant()
      Attempts to parse a constant name and returns the constant if successful.
      double getDecimal()
      Returns the double value that begins with '.' at the current scan position.
      int getFunction()
      Attempts to parse a function name and returns the function number if successful.
      int getInteger()
      Returns the integer value at the current scan position.
      double getNumber()
      Returns the double value at the current scan position.
      java.lang.String getString()
      Returns the next string (delimited by single quotes)
      int getToken()
      Returns the type of the next token.
      void printRemaining()
      Prints the string remaining to be scanned.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • error

        public java.lang.String error
    • Constructor Detail

      • TokenScanner

        public TokenScanner(java.lang.String expr,
                            Spreadsheet spreadsheet)
        Constructor. A string of mathematical expression and the associated spreadsheet is given.
        Parameters:
        expr - string of mathematical expression
    • Method Detail

      • printRemaining

        public void printRemaining()
        Prints the string remaining to be scanned.
      • consumeNumber

        public double consumeNumber()
        Consumes the number at the next scan position.
        Returns:
        double
      • consumeColumn

        public int consumeColumn()
        Consumes the column at the next scan position.
        Returns:
        column number
      • consumeFunction

        public int consumeFunction()
        Consumes the function at the next scan position.
        Returns:
        function number
      • consumeConstant

        public double consumeConstant()
        Consumes the constant at the next scan position.
        Returns:
        constant double
      • getToken

        public int getToken()
        Returns the type of the next token. The token is not consumed.
        Returns:
        token type
      • consumeToken

        public void consumeToken()
        Consumes the current token by advancing the index to the next position. Should be used only after a @url(#getToken} call is called.
      • getColumn

        public int getColumn()
        Attempts to parse a column label and returns the column number if successful.
        Returns:
        column number if a valid column label is parsed or -1 otherwise
      • getFunction

        public int getFunction()
        Attempts to parse a function name and returns the function number if successful.
        Returns:
        function number if a valid function name is parsed or -1 otherwise
      • getConstant

        public double getConstant()
        Attempts to parse a constant name and returns the constant if successful.
        Returns:
        a defined constant of double value if a valid constant name is parsed or MathFunctions.UNDEFINED otherwise
      • expect

        public boolean expect(java.lang.String name)
      • getString

        public java.lang.String getString()
        Returns the next string (delimited by single quotes)
        Returns:
        string
      • getNumber

        public double getNumber()
        Returns the double value at the current scan position.
        Returns:
        double value
      • getInteger

        public int getInteger()
        Returns the integer value at the current scan position.
        Returns:
        integer value
      • getDecimal

        public double getDecimal()
        Returns the double value that begins with '.' at the current scan position.
        Returns:
        double value
      • error

        public void error(java.lang.String msg)
        Adds the given string to the error string.
        Parameters:
        msg -

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.