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

TOPIC:

question about the StatementBlock 17 Dec 2002 11:07 #6299

hi.

I am wondering whether the following function definition is valid or not.

Thanks in advance.

function MyFunc()
{
var integer i;
i := 1;

/* Could the following StatementBlock appear in the function definition? */
{
var integer j;
j := 10;
}
}
--
Engineering is the art of making what you want from
things you can get.
★★★★★★★★★★★★★=A
1铩铩铩铩铩铩铩铩铩铩铩铩铩EF★
★Department of Automation ★
★The University of Science and Technology of China ★
★RoomX11-215,Jinzai Road,Hefei,Anhui,China ★
★ ★
★Tel: +865513630653(H),+865513606534-3016(O) ★
★Email: This email address is being protected from spambots. You need JavaScript enabled to view it.
★★★★★★★★★★★★★=A
1铩铩铩铩铩铩铩铩铩铩铩铩铩EF★

Please Log in to join the conversation.

question about the StatementBlock 17 Dec 2002 14:18 #6301

Hi,

Your question sounds like if the piece of code bounded by "{" and "}"
parenthesis and included inside function or other statement body can be
treated as a block of statements and allow declarations at the beginning?

Personally I do not think.
Please look at the Figure 2 "Hierarchy of scope units".
Usually block of statements is embedded within a compound statement and it
is not distinguished by only parenthesis use but by the whole construct,
which typically is: if-else, while-, do-while, for-, alt-, altstep-, etc.
So from figure 2 comes a conclusion, that inside function next level of
scope is a "block of statements (within a compound statement)" what should
be read: "block of statements BUT (within a compound statement)".

Forgot about descriptions, they are better or worse, please look at the BNF
to check what is allowed nad what not:
The code responsible for a new statement block is defined as:


StatementBlock ::= BeginChar [ FunctionStatementOrDefList ] EndChar



where definition FunctionStatementOrDefList handles const, var, timer or
FunctionStatement definition.

The answer to your question will be given as an answer to question: "if
StatementBlock, bounded by "{" "}" parenthesis may be used as a standalone
definition within BNF?".

I do not see no one case of such a use.
Please look yourself at the listing of all expressions using StatementBlock
definition:

FunctionDef ::= FunctionKeyword FunctionIdentifier
隆掳(隆卤[FunctionFormalParList] 隆卤)隆卤 [RunsOnSpec] [ReturnType]

StatementBlock

TestcaseDef ::= TestcaseKeyword TestcaseIdentifier

隆掳(隆卤[TestcaseFormalParList] 隆卤)隆卤 ConfigSpec

StatementBlock



CallBodyStatement ::= CallBodyGuard StatementBlock



GuardStatement ::= AltGuardChar (AltstepInstance | GuardOp StatementBlock)


ElseStatement ::= "["ElseKeyword "]" StatementBlock



InterleavedGuardElement ::= InterleavedGuard InterleavedAction


InterleavedAction ::= StatementBlock



ForStatement ::= ForKeyword 隆掳(隆卤 Initial SemiColon Final SemiColon Step
隆掳)隆卤

StatementBlock


WhileStatement ::= WhileKeyword 隆掳(隆卤 BooleanExpression
隆掳)隆卤

StatementBlock


DoWhileStatement ::= DoKeyword StatementBlock

WhileKeyword 隆掳(隆卤 BooleanExpression
隆掳)隆卤


ConditionalConstruct ::= IfKeyword 隆掳(隆卤 BooleanExpression
隆掳)隆卤

StatementBlock

{ElseIfClause} [ElseClause]


ElseIfClause ::= ElseKeyword IfKeyword 隆掳(隆卤 BooleanExpression 隆掳)隆卤
StatementBlock



ElseClause ::= ElseKeyword StatementBlock


Voila, I hope that is an answer and you can track the problem now where new
statement block starting with definitions may be placed.

BR,
Mariusz Kupiec




Original Message
From: "jacon_wang" <This email address is being protected from spambots. You need JavaScript enabled to view it.>
To: <This email address is being protected from spambots. You need JavaScript enabled to view it.>
Sent: Tuesday, December 17, 2002 12:07 PM
Subject: question about the StatementBlock


hi.

I am wondering whether the following function definition is valid or not.

Thanks in advance.

function MyFunc()
{
var integer i;
i := 1;

/* Could the following StatementBlock appear in the function definition? */
{
var integer j;
j := 10;
}
}
--
Engineering is the art of making what you want from
things you can get.
隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂
隆茂Department of Automation 隆茂
隆茂The University of Science and Technology of China 隆茂
隆茂RoomX11-215,Jinzai Road,Hefei,Anhui,China 隆茂
隆茂 隆茂
隆茂Tel: +865513630653(H),+865513606534-3016(O) 隆茂
隆茂Email: This email address is being protected from spambots. You need JavaScript enabled to view it. 隆茂
隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂

WIADOMOSCI minuta po minucie... >>> link.interia.pl/f16a8







Portal INTERIA.PL zaprasza... >>> link.interia.pl/f16ab

Please Log in to join the conversation.

question about the StatementBlock 17 Dec 2002 15:14 #6302

Just a few lines to complete local definitions question in a statement
blocks.
Not only StatementBlock handles local definitions. There are two exceptions:
for an altstep and for loop index definitions:

AltstepDef ::= AltstepKeyword AltstepIdentifier

隆掳(隆卤[AltstepFormalParList] 隆卤)隆卤 [RunsOnSpec]

BeginChar

AltstepLocalDefList

AltGuardList

EndChar



AltstepLocalDefList ::= { AltstepLocalDef [ SemiColon] }

AltstepLocalDef ::= VarInstance | TimerInstance | ConstDef



ForStatement ::= ForKeyword 隆掳(隆卤 Initial SemiColon Final SemiColon Step
隆掳)隆卤

StatementBlock

Initial ::= VarInstance | Assignment



For your example the answer may be also very simple /forgetting about local
local declarations issue/: because compiler finds "{" character but other
tokens are expected:

FunctionStatementOrDef ::= FunctionLocalDef |

FunctionLocalInst |

FunctionStatement

At the "{" position compiler expects following tokens /skipping whitespace
symbols/:

ptT3const,ptT3var, ptT3timer,ptT3setverdict, ptT3action, ptT3connect,
ptT3disconnect, ptT3map, ptT3unmap, ptT3stop, ptT3TIMERIDENTIFIER,
ptT3TIMERPARIDENTIFIER, ptT3PORTIDENTIFIER, ptT3PORTPARIDENTIFIER, ptT3log,
ptT3for, ptT3while, ptT3do, ptT3if, ptT3any, ptT3all, ptT3execute,
ptT3return, ptT3alt, ptT3interleave, ptT3label, ptT3goto, ptT3repeat,
ptT3deactivate, ptT3ALTSTEPIDENTIFIER,ptT3MODULEIDENTIFIER,
ptT3FUNCTIONIDENTIFIER, ptT3VARIDENTIFIER, ptT3VALUEPARIDENTIFIER.

BR,
Mariusz



Original Message
From: "Mariusz Kupiec" <This email address is being protected from spambots. You need JavaScript enabled to view it.>
To: <This email address is being protected from spambots. You need JavaScript enabled to view it.>
Sent: Tuesday, December 17, 2002 3:18 PM
Subject: Re: question about the StatementBlock


Hi,

Your question sounds like if the piece of code bounded by "{" and "}"
parenthesis and included inside function or other statement body can be
treated as a block of statements and allow declarations at the beginning?

Personally I do not think.
Please look at the Figure 2 "Hierarchy of scope units".
Usually block of statements is embedded within a compound statement and it
is not distinguished by only parenthesis use but by the whole construct,
which typically is: if-else, while-, do-while, for-, alt-, altstep-, etc.
So from figure 2 comes a conclusion, that inside function next level of
scope is a "block of statements (within a compound statement)" what should
be read: "block of statements BUT (within a compound statement)".

Forgot about descriptions, they are better or worse, please look at the BNF
to check what is allowed nad what not:
The code responsible for a new statement block is defined as:


StatementBlock ::= BeginChar [ FunctionStatementOrDefList ] EndChar



where definition FunctionStatementOrDefList handles const, var, timer or
FunctionStatement definition.

The answer to your question will be given as an answer to question: "if
StatementBlock, bounded by "{" "}" parenthesis may be used as a standalone
definition within BNF?".

I do not see no one case of such a use.
Please look yourself at the listing of all expressions using StatementBlock
definition:

FunctionDef ::= FunctionKeyword FunctionIdentifier
隆掳(隆卤[FunctionFormalParList] 隆卤)隆卤 [RunsOnSpec] [ReturnType]

StatementBlock

TestcaseDef ::= TestcaseKeyword TestcaseIdentifier

隆掳(隆卤[TestcaseFormalParList] 隆卤)隆卤 ConfigSpec

StatementBlock



CallBodyStatement ::= CallBodyGuard StatementBlock



GuardStatement ::= AltGuardChar (AltstepInstance | GuardOp StatementBlock)


ElseStatement ::= "["ElseKeyword "]" StatementBlock



InterleavedGuardElement ::= InterleavedGuard InterleavedAction


InterleavedAction ::= StatementBlock



ForStatement ::= ForKeyword 隆掳(隆卤 Initial SemiColon Final SemiColon Step
隆掳)隆卤

StatementBlock


WhileStatement ::= WhileKeyword 隆掳(隆卤 BooleanExpression
隆掳)隆卤

StatementBlock


DoWhileStatement ::= DoKeyword StatementBlock

WhileKeyword 隆掳(隆卤 BooleanExpression
隆掳)隆卤


ConditionalConstruct ::= IfKeyword 隆掳(隆卤 BooleanExpression
隆掳)隆卤

StatementBlock

{ElseIfClause} [ElseClause]


ElseIfClause ::= ElseKeyword IfKeyword 隆掳(隆卤 BooleanExpression 隆掳)隆卤
StatementBlock



ElseClause ::= ElseKeyword StatementBlock


Voila, I hope that is an answer and you can track the problem now where new
statement block starting with definitions may be placed.

BR,
Mariusz Kupiec




Original Message
From: "jacon_wang" <This email address is being protected from spambots. You need JavaScript enabled to view it.>
To: <This email address is being protected from spambots. You need JavaScript enabled to view it.>
Sent: Tuesday, December 17, 2002 12:07 PM
Subject: question about the StatementBlock


hi.

I am wondering whether the following function definition is valid or not.

Thanks in advance.

function MyFunc()
{
var integer i;
i := 1;

/* Could the following StatementBlock appear in the function definition? */
{
var integer j;
j := 10;
}
}
--
Engineering is the art of making what you want from
things you can get.
隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂
隆茂Department of Automation 隆茂
隆茂The University of Science and Technology of China 隆茂
隆茂RoomX11-215,Jinzai Road,Hefei,Anhui,China 隆茂
隆茂 隆茂
隆茂Tel: +865513630653(H),+865513606534-3016(O) 隆茂
隆茂Email: This email address is being protected from spambots. You need JavaScript enabled to view it. 隆茂
隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂隆茂

WIADOMOSCI minuta po minucie... >>> link.interia.pl/f16a8







Portal INTERIA.PL zaprasza... >>> link.interia.pl/f16ab






WIADOMOSCI minuta po minucie... >>> link.interia.pl/f16a8

Please Log in to join the conversation.

question about the StatementBlock 17 Dec 2002 15:44 #6303

Hi,

Mariusz interpretation is correct. There is no way to define a block statement in a
block statement as you have without it being associated with a compound statement.


The BNF should be modified so that this is possible.

The code you provided:

> function MyFunc()
> {
> var integer i;
> i := 1;
>
> /* Could the following StatementBlock appear in the function
> definition? */
> {
> var integer j;
> j := 10;
> }
> }

can be simplified:

function MyFunc( ) { var integer i:=1; { var integer j:=10 } }

of course this is under the assumption that nested statement blocks (not associated with compound statements) are legal,
which they currently are not. Something legal would be:

function MyFunc( )
{
var integer i:=1;

if ( true == true ) { // if (true) should also work...
var integer j:=10
}
}

true 'might be' implemented to as a 0 or null value...

Cheers,


Claude.
>
Original Message
> From: Mariusz Kupiec [This email address is being protected from spambots. You need JavaScript enabled to view it.]
> Sent: 17 December 2002 14:18
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: question about the StatementBlock
>
>
> Hi,
>
> Your question sounds like if the piece of code bounded by "{" and "}"
> parenthesis and included inside function or other statement
> body can be
> treated as a block of statements and allow declarations at
> the beginning?
>
> Personally I do not think.
> Please look at the Figure 2 "Hierarchy of scope units".
> Usually block of statements is embedded within a compound
> statement and it
> is not distinguished by only parenthesis use but by the whole
> construct,
> which typically is: if-else, while-, do-while, for-, alt-,
> altstep-, etc.
> So from figure 2 comes a conclusion, that inside function
> next level of
> scope is a "block of statements (within a compound
> statement)" what should
> be read: "block of statements BUT (within a compound statement)".
>
> Forgot about descriptions, they are better or worse, please
> look at the BNF
> to check what is allowed nad what not:
> The code responsible for a new statement block is defined as:
>
>
> StatementBlock ::= BeginChar [ FunctionStatementOrDefList ] EndChar
>
>
>
> where definition FunctionStatementOrDefList handles const,
> var, timer or
> FunctionStatement definition.
>
> The answer to your question will be given as an answer to
> question: "if
> StatementBlock, bounded by "{" "}" parenthesis may be used as
> a standalone
> definition within BNF?".
>
> I do not see no one case of such a use.
> Please look yourself at the listing of all expressions using
> StatementBlock
> definition:
>
>
> FunctionDef ::= FunctionKeyword FunctionIdentifier
> “(”[FunctionFormalParList] ”)” [RunsOnSpec] [ReturnType]
>
> StatementBlock
>
> TestcaseDef ::= TestcaseKeyword TestcaseIdentifier
>
> “(”[TestcaseFormalParList] ”)” ConfigSpec
>
> StatementBlock
>
>
>
> CallBodyStatement ::= CallBodyGuard StatementBlock
>
>
>
> GuardStatement ::= AltGuardChar (AltstepInstance | GuardOp
> StatementBlock)
>
>
> ElseStatement ::= "["ElseKeyword "]" StatementBlock
>
>
>
> InterleavedGuardElement ::= InterleavedGuard InterleavedAction
>
>
> InterleavedAction ::= StatementBlock
>
>
>
> ForStatement ::= ForKeyword “(” Initial SemiColon Final SemiColon Step
> “)”
>
> StatementBlock
>
>
> WhileStatement ::= WhileKeyword “(” BooleanExpression
> “)”
>
> StatementBlock
>
>
> DoWhileStatement ::= DoKeyword StatementBlock
>
> WhileKeyword “(”
> BooleanExpression
> “)”
>
>
> ConditionalConstruct ::= IfKeyword “(”
> BooleanExpression
> “)”
>
> StatementBlock
>
> {ElseIfClause}
> [ElseClause]
>
>
> ElseIfClause ::= ElseKeyword IfKeyword “(” BooleanExpression “)”
> StatementBlock
>
>
>
> ElseClause ::= ElseKeyword StatementBlock
>
>
>
> Voila, I hope that is an answer and you can track the problem
> now where new
> statement block starting with definitions may be placed.
>
> BR,
> Mariusz Kupiec
>
>
>
>
>
Original Message
> From: "jacon_wang" <This email address is being protected from spambots. You need JavaScript enabled to view it.>
> To: <This email address is being protected from spambots. You need JavaScript enabled to view it.>
> Sent: Tuesday, December 17, 2002 12:07 PM
> Subject: question about the StatementBlock
>
>
> hi.
>
> I am wondering whether the following function definition is
> valid or not.
>
> Thanks in advance.
>
> function MyFunc()
> {
> var integer i;
> i := 1;
>
> /* Could the following StatementBlock appear in the function
> definition? */
> {
> var integer j;
> j := 10;
> }
> }
> --
> Engineering is the art of making what you want from
> things you can get.
> ★★★★★★★★★★★★★★★★★★★★★★★★★★★★
> ★Department of Automation ★
> ★The University of Science and Technology of China ★
> ★RoomX11-215,Jinzai Road,Hefei,Anhui,China ★
> ★ ★
> ★Tel: +865513630653(H),+865513606534-3016(O) ★
> ★Email: This email address is being protected from spambots. You need JavaScript enabled to view it.
> ★★★★★★★★★★★★★★★★★★★★★★★★★★★★
>
>
> WIADOMOSCI minuta po minucie... >>> link.interia.pl/f16a8
>
>
>
>
>
>
>
>
> Portal INTERIA.PL zaprasza... >>> link.interia.pl/f16ab
>

Please Log in to join the conversation.

  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin