Class TextExpression
Text expression.
Simula Standard: 3.7 Text expressions text-expression = simple-text-expression | if-clause simple-text-expression else text-expression simple-text-expression = text-primary { & text-primary } text-primary = notext | string | variable | function-designator | "(" text-expression ")"
A text expression is of type text. It is a rule for obtaining an identification of a text variable. Apart from possible if-clauses, all constituents of a text expression must be of type text.
Each textual occurrence of a non-empty string corresponds to a unique constant main text frame. A given occurrence always references that same frame, while different occurrences of the same non-empty string always reference different text frames.
The empty string ("") is textually equivalent to notext.
Simula Standard: 3.7.1 Text concatenation
The operator & permits text concatenation. The simple text expression "TP1 & TP2 & ... & TPn", where TPi is a text primary (1<=i<=n), references a new alterable main frame whose contents is formed by concatenating copies of the frames referenced by TP1, TP2, ... , TPn (in that order). The expression is equivalent to CONCATENATE_n(T1,T2,...,Tn) defined by
text procedure CONCATENATE_ _n(T1,T2,...,Tn); text T1,T2,...,Tn; begin text temp; CONCATENATE_ _n :- temp :- blanks(T1.length+T2.length+ ... +Tn.length); temp.sub(1,t1.length) := T1; temp.sub(1+T1.length,T2.length) := T2; ... temp.sub(1+T1.length+T2.length+... ,Tn.length) := Tn; end;
Note: It follows that the text primary constituents of a simple text expression are evaluated in strict lexical order. The evaluation of Ti may influence the result of evaluating Tj, if i<j (due to the specified "by reference" transmission of parameters to the procedures CONCATENATE_n). Observe further that it follows from the syntax (cfr. 3.1.5) that . is evaluated before &, thus the two expressions "T1 & T2.sub(1,2) & T3.main" and "T1 & (T2.sub(1,2)) & (T3.main)" are equivalent.
Link to GitHub: Source File.
- Author:
- Simula Standard, Øystein Myhre Andersen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Expression
The left hand side of &private Expression
The right hand side of &Fields inherited from class simula.compiler.syntaxClass.expression.Expression
backLink, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
CHECKED, lineNumber, OBJECT_SEQU
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Default constructor used by Attribute File I/O(package private)
TextExpression
(Expression lhs, Expression rhs) Create a new TextExpression -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildEvaluation
(Expression rightPart, CodeBuilder codeBuilder) ClassFile coding utility: Build Evaluation Code.void
Perform semantic checking.boolean
Returns true if this expression may be used as a statement.static TextExpression
Read and return an object.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
-
lhs
The left hand side of & -
rhs
The right hand side of &
-
-
Constructor Details
-
TextExpression
TextExpression(Expression lhs, Expression rhs) Create a new TextExpression- Parameters:
lhs
- left hand siderhs
- rigth hand side
-
TextExpression
private TextExpression()Default constructor used by Attribute File I/O
-
-
Method Details
-
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
-
buildEvaluation
Description copied from class:Expression
ClassFile coding utility: Build Evaluation Code.- Specified by:
buildEvaluation
in classExpression
- Parameters:
rightPart
- expressioncodeBuilder
- the codeBuilder used.
-
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 an object.- Parameters:
inpt
- the AttributeInputStream to read from- Returns:
- the object read from the stream.
- Throws:
IOException
- if something went wrong.
-