Simula Standard: 3.2 Boolean expressions Boolean-expression = simple-Boolean-expression | IF Boolean-expression THEN simple-Boolean-expression ELSE Boolean-expression simple-Boolean-expression = Boolean-tertiary { OR ELSE Boolean-tertiary } Boolean-tertiary = equivalence { AND THEN equivalence } equivalence = implication { EQV implication } implication = Boolean-term { IMP Boolean-term } Boolean-term = Boolean-factor { OR Boolean-factor } Boolean-factor = Boolean-secondary { AND Boolean-secondary } Boolean-secondary = [ NOT ] Boolean-primary Boolean-primary = logical-value | variable | function-designator | relation | "(" Boolean-expression ")"A Boolean expression is of type Boolean. It is a rule for computing a logical value. Except for the operators and then and or else (see 3.4) the semantics are entirely analogous to those given for arithmetic expressions.
Variables and function designators entered as Boolean primaries must be of type Boolean. Simula Standard: 3.4 The logical operators
The meaning of the logical operators not, and, or, imp, and eqv is given by the following function table:
b1 false false true true b2 false true false true --------------------------------------------------------- not b1 true true false false b1 and b2 false false false true b1 or b2 false true true true b1 imp b2 true true false true b1 eqv b2 true false false true ----------------------------------------------------------The operation "b1 and then b2" denotes "conditional and". If the value of b1 is false the operation yields the result false, otherwise it yields the result of evaluating b2.
The operation "b1 or else b2" denotes "conditional or". If the value of b1 is true the operator yields the result true, otherwise it yields the result of evaluating b2.
Note: The value of "b1 and then b2" is given by textual substitution of the Boolean expression "(if b1 then b2 else false)". Similarly, the operation "b1 or else b2" is defined by substitution of "(if b1 then true else b2)". These definitions imply that the evaluation of the second operand is suppressed when the evaluation result is already evident from the value of the first operand alone.
Link to GitHub: Source File.
- Author:
- Simula Standard, Øystein Myhre Andersen
-
Field Summary
Modifier and TypeFieldDescriptionprivate Expression
The left hand sideprivate final KeyWord
The Boolean operationprivate Expression
The right hand sideFields inherited from class simula.compiler.syntaxClass.expression.Expression
backLink, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
lineNumber
-
Constructor Summary
ConstructorDescriptionBooleanExpression
(Expression lhs, KeyWord opr, Expression rhs) Create a new BooleanExpression. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Perform semantic checking.boolean
Returns true if this expression may be used as a statement.Generate Java code for this Syntax Class.toString()
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, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED
-
Field Details
-
lhs
The left hand side -
opr
The Boolean operation -
rhs
The right hand side
-
-
Constructor Details
-
BooleanExpression
BooleanExpression(Expression lhs, KeyWord opr, Expression rhs) Create a new BooleanExpression.- Parameters:
lhs
- left hand sideopr
- Boolean operationrhs
- right hand side
-
-
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
-
toString
- Overrides:
toString
in classExpression
-