Class TextExpression


public final class TextExpression extends Expression

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 Details

    • lhs

      private Expression lhs
      The left hand side of &
    • rhs

      private Expression rhs
      The right hand side of &
  • Constructor Details

    • TextExpression

      TextExpression(Expression lhs, Expression rhs)
      Create a new TextExpression
      Parameters:
      lhs - left hand side
      rhs - 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 class SyntaxClass
    • maybeStatement

      public boolean maybeStatement()
      Description copied from class: Expression
      Returns true if this expression may be used as a statement.
      Specified by:
      maybeStatement in class Expression
      Returns:
      true if this expression may be used as a statement
    • toJavaCode

      public String toJavaCode()
      Description copied from class: SyntaxClass
      Generate Java code for this Syntax Class.
      Overrides:
      toJavaCode in class SyntaxClass
      Returns:
      Java code
    • buildEvaluation

      public void buildEvaluation(Expression rightPart, CodeBuilder codeBuilder)
      Description copied from class: Expression
      ClassFile coding utility: Build Evaluation Code.
      Specified by:
      buildEvaluation in class Expression
      Parameters:
      rightPart - expression
      codeBuilder - the codeBuilder used.
    • toString

      public String toString()
      Overrides:
      toString in class Expression
    • writeObject

      public void writeObject(AttributeOutputStream oupt) throws IOException
      Description copied from class: SyntaxClass
      Write a SyntaxClass object to a AttributeOutputStream.
      Overrides:
      writeObject in class SyntaxClass
      Parameters:
      oupt - the AttributeOutputStream to write to.
      Throws:
      IOException - if something went wrong.
    • readObject

      public static TextExpression readObject(AttributeInputStream inpt) throws IOException
      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.