Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Simplification of loop and conditional constructs

Simplification of loop and conditional constructs 17 Jan 2003 19:21 #6358

Hi,

I think about some constructs simplification. Currently for 'for and 'while'.
This example:

for (i:=1; i<=10; i:=i+1) {

for (j:=1; j<=10; j:=j+1) {

for (k:=1; k<=10; k:=k+1) {

:

}
}
}

may be written as :

for (i:=1; i<=10; i:=i+1)

for (j:=1; j<=10; j:=j+1)

for (k:=1; k<=10; k:=k+1) {

:

}

In the same way:

var integer i;

while (i<=10) {

for (j:=1; j<=10; j:=j+1) {

for (k:=1; k<=10; k:=k+1) {

:

}
}
}

may be replaced by:

while (i<=10)

for (j:=1; j<=10; j:=j+1)

for (k:=1; k<=10; k:=k+1) {

:

}


The BNF changes may be:

ForStatement ::= ForKeyword "(" Initial SemiColon Final SemiColon Step ")"
( StatementBlock | LoopConstruct | ConditionalConstruct )

WhileStatement ::= WhileKeyword "(" BooleanExpression ")"
( StatementBlock | LoopConstruct | ConditionalConstruct )


BR,
Mariusz Kupiec
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin