org.sc3d.apt.sss.v3
Class SSSNumber

java.lang.Object
  extended by org.sc3d.apt.sss.v3.Token
      extended by org.sc3d.apt.sss.v3.SSSNumber

public class SSSNumber
extends Token

A subclass of Token that represents an SSS number, or any prefix thereof.


Field Summary
 int exponentLength
          The number of characters occupied by the optional exponent part of this SSSNumber, if present, or '0', if absent.
 int fractionLength
          The number of characters occupied by the optional fractional part of this SSSNumber, if present, or '0', if absent.
 int integerLength
          The number of characters occupied by the integer part of this SSSNumber.
 
Fields inherited from class org.sc3d.apt.sss.v3.Token
length, sentence, start, type, TYPE_BRACE, TYPE_CHAR, TYPE_COMMENT, TYPE_CONSTANT, TYPE_IDENTIFIER, TYPE_NUMBER, TYPE_ROUND, TYPE_SQUARE, TYPE_STRING, TYPE_WORD
 
Constructor Summary
SSSNumber(Sentence sentence, int start, int integerLength, int fractionLength, int exponentLength)
          Constructs an SSSNumber, given values for its fields.
 
Method Summary
 char getBase()
          Returns the base character of this SSSNumber.
 java.lang.String getExponentDigits()
          Returns the digits of the exponent part of this SSSNumber.
 java.lang.String getFractionDigits()
          Returns the digits of the fractional part of this SSSNumber.
 java.lang.String getIntegerDigits()
          Returns the digits of the integer part of this SSSNumber.
 java.lang.String getMantissa()
          Returns the concatenation of the integer and fraction digits.
 int getRadix()
          Returns '2', '4', '8', '10' or '16' depending on the base in which this number is written.
 int getShift()
          Returns the exponent minus the number of fractional digits.
 boolean isExponentNegative()
          Returns 'true' if the exponent part is present and includes the optional '-' sign.
static SSSNumber lex(Sentence sentence, int start)
          Constructs an SSSNumber by reading from the middle of a Sentence.
 
Methods inherited from class org.sc3d.apt.sss.v3.Token
addError, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

integerLength

public final int integerLength
The number of characters occupied by the integer part of this SSSNumber. The integer part (if syntactically correct) consists of one or more hexadecimal digits, of which the first must be a decimal digit.


fractionLength

public final int fractionLength
The number of characters occupied by the optional fractional part of this SSSNumber, if present, or '0', if absent. If the fractional part is present, it consists of a '.' followed by zero or more hexadecimal digits. An absent fractional part means the same as "." or ".0".


exponentLength

public final int exponentLength
The number of characters occupied by the optional exponent part of this SSSNumber, if present, or '0', if absent. If the exponent part is present, it consists of a single character identifying the base in which this number is written, an optional '-' sign, and one or more decimal digits. The base character can be one of 'b' for binary, 'q' for quarternary, 'o' for octal, 'd' for decimal, or 'h' for hexadecimal. An absent exponent means the same as an exponent of "d0".

Constructor Detail

SSSNumber

public SSSNumber(Sentence sentence,
                 int start,
                 int integerLength,
                 int fractionLength,
                 int exponentLength)
Constructs an SSSNumber, given values for its fields. It's type will be 'TYPE_NUMBER'.

Method Detail

lex

public static SSSNumber lex(Sentence sentence,
                            int start)
Constructs an SSSNumber by reading from the middle of a Sentence. This method always returns an SSSNumber. If there is a syntax error, the returned SSSNumber will represent the syntactically correct part, and an error will be added to 'sentence'.

Parameters:
sentence - the sentence to read.
start - the index of the first character of the number.
Returns:
a new SSSNumber.

getIntegerDigits

public java.lang.String getIntegerDigits()
Returns the digits of the integer part of this SSSNumber.


getFractionDigits

public java.lang.String getFractionDigits()
Returns the digits of the fractional part of this SSSNumber. If the fractional part is absent or ".", this method returns "0".


getBase

public char getBase()
Returns the base character of this SSSNumber. If the exponent part is absent, this method returns 'd'. See also 'getRadix()'.


isExponentNegative

public boolean isExponentNegative()
Returns 'true' if the exponent part is present and includes the optional '-' sign.


getExponentDigits

public java.lang.String getExponentDigits()
Returns the digits of the exponent part of this SSSNumber. If the exponent is absent or (erroneously) has no digits, this method returns "0".


getMantissa

public java.lang.String getMantissa()
Returns the concatenation of the integer and fraction digits. This can be combined with 'getRadix()' and 'getShift()' to evaluate the number.


getRadix

public int getRadix()
Returns '2', '4', '8', '10' or '16' depending on the base in which this number is written. See also 'getBase()'.


getShift

public int getShift()
Returns the exponent minus the number of fractional digits. In other words, this method returns the number of zeros that must be appended to 'getMantissa()' to evaluate this SSSNumber. This method can return a negative number.