Class Constant
java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.expression.Expression
simula.compiler.syntaxClass.expression.Constant
Constant.
All constants are treated by the Lexicographical Scanner.
Syntax: Constant = unsigned-number | string | character-constant | NONE | NOTEXT
Link to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
- See Also:
-
Field Summary
FieldsFields inherited from class simula.compiler.syntaxClass.expression.Expression
backLink, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
CHECKED, lineNumber, OBJECT_SEQU
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
appendHex
(StringBuilder sb, char c) Java Encoding Utility: Edit hex(c) and append it to the given StringBuilder.void
buildEvaluation
(Expression rightPart, CodeBuilder codeBuilder) ClassFile coding utility: Build Evaluation Code.static void
buildIntConst
(CodeBuilder codeBuilder, boolean b) ClassFile coding: Build boolean const as an integer 1:true or 0:false.static void
buildIntConst
(CodeBuilder codeBuilder, int i) ClassFile coding: Build integer const.(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.static Constant
Read and return a Constant.Generate Java code for this Syntax Class.toString()
void
Write a SyntaxClass object to a AttributeOutputStream.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, buildByteCode, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED, setLineNumber
-
Field Details
-
value
The constant's value
-
-
Constructor Details
-
Constant
-
Constant
private Constant()Default constructor used by Attribute File I/O
-
-
Method Details
-
createRealType
-
getType
-
evaluate
-
evaluate
-
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
-
appendHex
Java Encoding Utility: Edit hex(c) and append it to the given StringBuilder.- Parameters:
sb
- the StringBuilderc
- the input character
-
buildEvaluation
Description copied from class:Expression
ClassFile coding utility: Build Evaluation Code.- Specified by:
buildEvaluation
in classExpression
- Parameters:
rightPart
- expressioncodeBuilder
- the codeBuilder used.
-
buildIntConst
ClassFile coding: Build boolean const as an integer 1:true or 0:false.- Parameters:
codeBuilder
- the codeBuilder to use.b
- the actual boolean value.
-
buildIntConst
ClassFile coding: Build integer const.- Parameters:
codeBuilder
- the codeBuilder to use.i
- the actual integer value.
-
toString
- Overrides:
toString
in classExpression
-
writeObject
Description copied from class:SyntaxClass
Write a SyntaxClass object to a AttributeOutputStream.- Overrides:
writeObject
in classSyntaxClass
- Parameters:
oupt
- the AttributeOutputStream to write to.- Throws:
IOException
- if something went wrong.
-
readObject
Read and return a Constant.- Parameters:
inpt
- the AttributeInputStream to read from- Returns:
- the Constant read from the stream.
- Throws:
IOException
- if something went wrong.
-