Your Ad Here

Saturday, March 14, 2009

Procedural Control statements in e-language

e-language is high-level programming language, it supports all Procedural flow control statements. The defined flow control statements are:

· If-else statement

· Case statement

· For loop

· While loop

· Repeat-Until loop

Ex: If statement execution

<’

struct packet_s {

Flag: bool;

Check_flag (): bool is {

If (flag = TRUE) {
Out (“flag is true”);
}
else {
Out (“flag is false”);
}; // end of if cond
}; // end of method

run() is also {

Check_flag(); // calling the method declared
};
}; // end of declared struct

‘>


Ex: Case Statement Execution

<’
struct packet_s {

Flag: bool;

Check_flag (): bool is {

Case flag {

TRUE: {out (“flag is true”)};

FALSE: {out (“flag is false”)};
}; // end of case statement
}; // end of method

run() is also {

Check_flag();
};

}; // end of struct

‘>

Ex: For loop condition execution
<’

struct packet_d {

! Pkt: Packet_s; // on-the fly generation

No_of_Pkt: uint (bits: 4);

Keep No_of_Pkt in [1.. 10];

Packet_gen () is {

For i from 0 to (no_of_Pkt-1) {

gen Pkt; }; // on_the_fly gen (gen is specman keyword)

}; // end of method


run() is also {

Packet_gen();
};
}; // end of struct

‘>

No comments:

Post a Comment