Simula Standard: 3.1 Variables Simula Standard: 3.1.3. Array elements Simula Standard: 3.1.4. Function designators variable = simple-variable | subscripted-variable | simple-object-expression . variable simple-object-expression = NONE | variable | function-designator | object-generator | local-object | qualified-object | ( object-expression ) simple-variable = identifier subscripted-variable = function-designator | array-element function-designator = procedure-identifier ( [ actual-parameter-part ] ) actual-parameter-part = actual-parameter { , actual-parameter } actual-parameter = expression | array-identifier1 | switch-identifier1 | procedure-identifier1 identifier1 = identifier | remote-identifier remote-identifier = simple-object-expression . attribute-identifier | text-primary . attribute-identifier array-element = array-identifier [ subscript-list ] subscript-list = arithmetic-expression { , arithmetic-expression }Function designators:
A function designator defines a value which results through the application of a given set of rules defined by a procedure declaration (see 5.4) to a fixed set of actual parameters. The rules governing specification of actual parameters are given in 4.6. Note: Not every procedure declaration defines rules for determining the value of a function designator (cf. 5.4.1).
Array elements:
Subscripted variables designate values which are components of multi- dimensional arrays. Each arithmetic expression of the subscript list occupies one subscript position of the subscripted variable and is called a subscript. The complete list of subscripts is enclosed by the subscript parentheses ( ). The array component referred to by a subscripted variable is specified by the actual value of its subscripts.
Each subscript position acts like a variable of type integer and the evaluation of the subscript is understood to be equivalent to an assignment to this fictitious variable. The value of the subscripted variable is defined only if the actual integer value of each subscript expression is within the associated subscript bounds of the array. A subscript expression value outside its associated bounds causes a run time error.
Link to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
-
Field Summary
Modifier and TypeFieldDescriptionThe checked parameters set by doChecking.The variable's identifier.The meaning of this variable.(package private) Vector
<Expression> The parsed parameters.private boolean
Indicates that this variable is remotely accessed.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 TypeMethodDescriptionvoid
Perform semantic checking.doGetELEMENT
(String var) Coding utility: doGetELEMENT.doPutELEMENT
(String var, String rightPart) Coding utility: doPutELEMENT.edIdentifierAccess
(boolean destination) Coding utility: Edit identifier access.private String
edIdentifierAccess
(String id, boolean destination) Coding Utility: Edit identifier access.private String
editVariable
(String rightPart) Coding Utility: Edit this Variable.static VariableExpression
expectVariable
(String ident) Parse Utility: Expect Variable.get()
Generate code for getting the value of this Expression(package private) String
Returns a suitable java identifier for this variable.(package private) Meaning
Returns the meaning.Get a writeable variable.boolean
Returns true if this variable has arguments.boolean
Returns true if this expression may be used as a statement.void
printTree
(int indent) Utility print syntax tree method.Generate code for putting the value into this Expression(package private) void
setRemotelyAccessed
(Meaning meaning) This variable is remotely accessed through 'meaning'.Generate Java code for this Syntax Class.toString()
Methods inherited from class simula.compiler.syntaxClass.expression.Expression
acceptExpression, checkCompatibility, evaluate, expectExpression, getInt, getNumber, getQualification
Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED
-
Field Details
-
identifier
The variable's identifier. -
meaning
The meaning of this variable. -
remotelyAccessed
private boolean remotelyAccessedIndicates that this variable is remotely accessed. -
params
Vector<Expression> paramsThe parsed parameters. -
checkedParams
The checked parameters set by doChecking.
-
-
Constructor Details
-
VariableExpression
Create a new Variable.- Parameters:
identifier
- the variable's identifier
-
-
Method Details
-
hasArguments
public boolean hasArguments()Returns true if this variable has arguments.- Returns:
- true if this variable has arguments
-
getJavaIdentifier
String getJavaIdentifier()Returns a suitable java identifier for this variable.- Returns:
- a suitable java identifier
-
setRemotelyAccessed
This variable is remotely accessed through 'meaning'.- Parameters:
meaning
- before dot
-
getMeaning
Meaning getMeaning()Returns the meaning.If meaning is not set by setRemotelyAccessed then meaning by identifier will be set.
- Returns:
- the meaning
-
expectVariable
Parse Utility: Expect Variable.Variable = Identifier | SubscriptedVariable SubscriptedVariable = Identifier "(" Expression { , Expression } ")"
Precondition: Identifier is already read.- Parameters:
ident
- the variable identifier- Returns:
- the created Variable
-
getWriteableVariable
Description copied from class:Expression
Get a writeable variable.This method is redefined in Variable, RemoteVariable and TypeConversion
- Overrides:
getWriteableVariable
in classExpression
- Returns:
- a writeable variable or null
-
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
-
put
Description copied from class:Expression
Generate code for putting the value into this Expression- Overrides:
put
in classExpression
- Parameters:
rightPart
- a evaluated expression.- Returns:
- the resulting Java code
-
get
Description copied from class:Expression
Generate code for getting the value of this Expression- Overrides:
get
in classExpression
- Returns:
- the resulting Java code
-
doGetELEMENT
Coding utility: doGetELEMENT.- Parameters:
var
- the variable- Returns:
- a suitable java code
-
doPutELEMENT
Coding utility: doPutELEMENT.- Parameters:
var
- the variablerightPart
- the right hand side- Returns:
- a suitable java code
-
editVariable
Coding Utility: Edit this Variable.- Parameters:
rightPart
- When destination, this is the right part of the assignment- Returns:
- the resulting Java source code
-
edIdentifierAccess
Coding utility: Edit identifier access.- Parameters:
destination
- true if this variable is a destination- Returns:
- a suitable java code
-
edIdentifierAccess
Coding Utility: Edit identifier access.- Parameters:
id
- the identifierdestination
- true if destination- Returns:
- a suitable java code
-
printTree
public void printTree(int indent) Description copied from class:SyntaxClass
Utility print syntax tree method.- Overrides:
printTree
in classExpression
- Parameters:
indent
- number of spaces leading the lines
-
toString
- Overrides:
toString
in classExpression
-