java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.declaration.Declaration
simula.compiler.syntaxClass.declaration.SimpleVariableDeclaration
- All Implemented Interfaces:
Externalizable
,Serializable
- Direct Known Subclasses:
LabelDeclaration
public sealed class SimpleVariableDeclaration
extends Declaration
implements Externalizable
permits LabelDeclaration
Simple Variable Declaration.
Simula Standard: 5.1 Simple variable declarations simple-variable-declaration = type type-list type-list = type-list-element { , type-list-element } type-list-element = identifier | constant-element constant-element = identifier "=" value-expression | identifier "=" text-expressionLink to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class simula.compiler.syntaxClass.declaration.Declaration
Declaration.Kind
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
Constant indicator.The constant initial value.Fields inherited from class simula.compiler.syntaxClass.declaration.Declaration
declarationKind, declaredIn, externalIdent, identifier, isProtected, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
lineNumber
-
Constructor Summary
ConstructorDescriptionDefault constructor used by Externalization.SimpleVariableDeclaration
(Type type, String identifier) Create a new SimpleVariableDeclaration.SimpleVariableDeclaration
(Type type, String identifier, boolean constant, Constant constantElement) Create a new SimpleVariableDeclaration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Perform semantic checking.void
Output possible declaration code.(package private) static void
expectSimpleVariable
(Type type, DeclarationList declarationList) Parse a simple variable declaration.boolean
Constant indicator.void
printTree
(int indent) Utility print syntax tree method.void
readExternal
(ObjectInput inpt) Generate Java code for this Syntax Class.toString()
void
writeExternal
(ObjectOutput oupt) Methods inherited from class simula.compiler.syntaxClass.declaration.Declaration
getJavaIdentifier, isCompatibleClasses, modifyIdentifier, parseDeclaration
Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED
-
Field Details
-
constant
private boolean constantConstant indicator. Is used to prevent assignment of a new value. -
constantElement
The constant initial value.
-
-
Constructor Details
-
SimpleVariableDeclaration
Create a new SimpleVariableDeclaration.- Parameters:
type
- the variable typeidentifier
- the variable identifier
-
SimpleVariableDeclaration
Create a new SimpleVariableDeclaration.- Parameters:
type
- the variable typeidentifier
- the variable identifierconstant
- the constant indicatorconstantElement
- a constant initial value
-
SimpleVariableDeclaration
public SimpleVariableDeclaration()Default constructor used by Externalization.
-
-
Method Details
-
isConstant
public boolean isConstant()Constant indicator. Is used to prevent assignment of a new value.- Returns:
- the constant indicator
-
expectSimpleVariable
Parse a simple variable declaration.Syntax: simple-variable-declaration = type type-list type-list = type-list-element { , type-list-element } type-list-element = identifier | constant-element constant-element = identifier "=" value-expression | identifier "=" text-expression
Precodition: Type is already read.- Parameters:
type
- the variable typedeclarationList
- the declaration list to update
-
doChecking
public void doChecking()Description copied from class:SyntaxClass
Perform semantic checking.This must be redefined in every subclass.
- Overrides:
doChecking
in classSyntaxClass
-
doDeclarationCoding
public void doDeclarationCoding()Description copied from class:SyntaxClass
Output possible declaration code.- Overrides:
doDeclarationCoding
in classSyntaxClass
-
toJavaCode
Description copied from class:SyntaxClass
Generate Java code for this Syntax Class.- Overrides:
toJavaCode
in classSyntaxClass
- Returns:
- Java code
-
printTree
public void printTree(int indent) Description copied from class:SyntaxClass
Utility print syntax tree method.- Overrides:
printTree
in classSyntaxClass
- Parameters:
indent
- number of spaces leading the lines
-
toString
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-