java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.expression.Expression
simula.compiler.syntaxClass.expression.Constant
- All Implemented Interfaces:
Externalizable
,Serializable
Constant.
All constants are treated by the Lexicographical Scanner.
Syntax: Constant = unsigned-number | string | character-constant | NONE | NOTEXTLink to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
- See Also:
-
Field Summary
Fields inherited from class simula.compiler.syntaxClass.expression.Expression
backLink, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
lineNumber
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
appendHex
(StringBuilder sb, char c) Encoding Utility: Edit hex(c) and append it to the given StringBuilder.(package private) static Constant
createRealType
(Object value) Create a real type Constant.void
Perform semantic checking.private String
Encode a string with escape sequences.(package private) static Constant
Simplify this Constant.(package private) static Constant
Simplify this Constant.private static Type
Returns the type of this number.boolean
Returns true if this expression may be used as a statement.void
readExternal
(ObjectInput inpt) Generate Java code for this Syntax Class.toString()
void
writeExternal
(ObjectOutput oupt) Methods inherited from class simula.compiler.syntaxClass.expression.Expression
acceptExpression, checkCompatibility, evaluate, expectExpression, get, getInt, getNumber, getQualification, getWriteableVariable, printTree, put
Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED
-
Field Details
-
value
The constant's value
-
-
Constructor Details
-
Constant
Create a new Constant.- Parameters:
type
- the constant's typevalue
- the constant's value
-
Constant
public Constant()Default constructor used by Externalization.
-
-
Method Details
-
createRealType
Create a real type Constant.- Parameters:
value
- a real type value- Returns:
- the resulting Constant
-
getType
Returns the type of this number.- Parameters:
n
- the number- Returns:
- the type of this number.
-
evaluate
Simplify this Constant.- Parameters:
opr
- an unary operationrhn
- a right hand Number- Returns:
- the resulting Constant
-
evaluate
Simplify this Constant.- Parameters:
lhn
- a left hand Numberopr
- an binary operationrhn
- a right hand Number- Returns:
- the resulting Constant
-
doChecking
public void doChecking()Description copied from class:SyntaxClass
Perform semantic checking.This must be redefined in every subclass.
- Overrides:
doChecking
in classSyntaxClass
-
maybeStatement
public boolean maybeStatement()Description copied from class:Expression
Returns true if this expression may be used as a statement.- Specified by:
maybeStatement
in classExpression
- Returns:
- true if this expression may be used as a statement
-
toJavaCode
Description copied from class:SyntaxClass
Generate Java code for this Syntax Class.- Overrides:
toJavaCode
in classSyntaxClass
- Returns:
- Java code
-
encode
Encode a string with escape sequences.- Parameters:
s
- the string- Returns:
- a string with escape sequences.
-
appendHex
Encoding Utility: Edit hex(c) and append it to the given StringBuilder.- Parameters:
sb
- the StringBuilderc
- the input character
-
toString
- Overrides:
toString
in classExpression
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-