Class AbstractNumericLiteral<T>
java.lang.Object
autumn.lang.compiler.ast.literals.AbstractNumericLiteral<T>
- Direct Known Subclasses:
BigDecimalLiteral,BigIntegerLiteral,ByteLiteral,CharLiteral,DoubleLiteral,FloatLiteral,IntLiteral,LongLiteral,ShortLiteral
Instances of this class represent numeric literals in Autumn source-code.
- Author:
- Mackenzie High
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanThis method determines whether this literal can be converted to a number accurately.abstract booleanThis method determines whether this literal would be recognized by the parser.final Stringsource()This method returns the source-code representation of this literal.final StringThis method returns the source-code representation of this literal with underscores removed.final StringtoString()This method returns a string representation of this literal.abstract Tvalue()This method converts this literal to its numeric equivalent.
-
Constructor Details
-
AbstractNumericLiteral
Sole Constructor.- Parameters:
source- is this literal as it appeared in the source-code.- Throws:
NullPointerException- if source is null.IllegalArgumentException- if source.length() equals zero.
-
-
Method Details
-
value
This method converts this literal to its numeric equivalent.- Returns:
- the numeric representation of this literal, or null, if a lossless conversion is not possible.
-
isParsable
public abstract boolean isParsable()This method determines whether this literal would be recognized by the parser.Note: Under some circumstances, a literal may be malformed and parse-able.
- Returns:
- true, iff the parser would recognize this literal.
-
source
This method returns the source-code representation of this literal.- Returns:
- this literal, as it appeared in the source code.
-
sourceWithoutUnderscores
This method returns the source-code representation of this literal with underscores removed.- Returns:
- this literal, as it appeared in the source code, excluding any underscores.
-
isMalformed
public final boolean isMalformed()This method determines whether this literal can be converted to a number accurately.- Returns:
- true, if a conversion would lose information.
-
toString
This method returns a string representation of this literal.
-