1 / 19

Introducing ASML

Introducing ASML. ASML version 2, “Steps and Updates ” Lecture 9 Software Engineering COMP201. The Executable Specification Language - ASML 2. Compiler asmlc [name of the program] Example D:>asmlc test.asml D:> test.exe. I. Steps. The general syntax for steps is

kevina
Download Presentation

Introducing ASML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introducing ASML ASML version 2, “Steps and Updates ” Lecture 9 Software Engineering COMP201

  2. The Executable Specification Language -ASML 2 • Compiler • asmlc [name of the program] • Example • D:\>asmlc test.asml • D:\> test.exe

  3. I. Steps The general syntax for steps is Step [label] [stopping-condition] statement block • a statement block consists of indented statement that follow • a label is an optional string, number of identifier followed by a colon (“:”) • stopping condition is any these forms: until fixpoint untilexpression whileexpression A step can be introduced independently or as part of sequence of steps in the form: step … step …

  4. Initial if count < 10 then count:= count+1 count:= 1 Started count  10 Finished Stopping for fixed point “until fixed point” enum EnumMode Initial Started Finished var mode = Initial var count = 0 Main() step until fixpoint if mode = Initial then mode :=Started count:=1 if mode = Started and count < 10 then count:= count+1 if mode = Started and count >=10 then mode:= Finished

  5. Stopping for conditions “while” & “until” Either while or until may be used to give an explicit stopping condition for iterated sequential steps of the machine. whileexpression untilexpression var x as Integer = 1 Main() step while x < 10 WriteLine(x) x:= x + 1 var x as Integer = 1 Main() step until x > 9 WriteLine(x) x:= x + 1 Running each of these examples produces nine steps. It will print numbers: 1,2,3,4,5,6,7,8 and 9 as output

  6. Conditions eq = ne  lt < gt > in  notin  subset  superset  subseteq  superseteq 

  7. Sequences of steps • The syntax step … step … indicates a sequence of steps that will be performed in order var F as File? = undef var Fcontents as String = “” Main () step 1: F :=open(“mfile.txt”) step 2: FContents :=fread (F,1) step 3: FContents := FContents + fread (F,1) step 4: writeln (FContents) • Labels after the “step” keyword are optional but helpful as documentation.

  8. Be wary ! • Be wary of introducing unnecessary steps • This can occur if two operations are reallynot order-dependentbut are given as two sequential steps, regardless • It is very easy to fall into this trap, sincemost people are used to the sequential structures used by other programming languages

  9. Iteration over collections Another common idiom for iteration is to do one step per element in some finite collection such as a set or sequence step foreachident1in expr1, ident2in expr2… statement-block myList = [1,2,3] Main() step foreach i in myList WriteLine (i) Sequential, step-based iteration is available for sets as well as sequences, but in the case of sets, the order is not specified

  10. Guidelines for using steps

  11. II. Updates “How are variables updated?” • A program defines state variables and operations • The most important concept is that state is a dictionary of (name,value) pairs • Each name identifies an occurrence for state variables • Operations may propose new values for state variables • But effect of these changes is only visible in subsequent step

  12. The update statement Update symbol “: =”(reads as “gets”) var x = 0 var y = 1 Main() step WriteLine(“In the first step, x =” + x) // x is 0 WriteLine (“In the first step, y =” + y) // y is 1 x:=2 step // updates occur here WriteLine(“In the second step, x =” + x)//x is 2 WriteLine(“In the second step, y =” + y)//y is 1

  13. Delayed effect of updates Updates don’t actually occur until the step following the one in which they are written var x = 0 var y = 1 Main() step WriteLine(“In the first step, x =” + x) // x is 0 WriteLine(“In the first step, y =” + y) // y is 1 step x:=2 WriteLine (“In the second step, x =” + x) // x is 0 step WriteLine (“In the third step, x =” + x) // x is 2

  14. When updates occur • All updates given within a single step occur simultaneously at the end of the step. • Conceptually, the updates are applied “in between” the steps. Swapping values

  15. Consistency of updates • The order within a step does not matter, but all of updates in the step must be consistent • None of the updates given within a step may contradict each other • If updates do contradict, then they are called “inconsistent updates”and an error occur

  16. Total and partial updates • An update of the variable can either be total or partial • Total update is a simple replacement of variable’s value with a new value • Partial updates apply to variables that have structure • The left hand side of the update operation “ X : = val ” indicates whether the update is total or partial

  17. Total update of a set-valued variable var Students as Set of String = {} Main() step WriteLine (“The initial roster is = ” + Students) Students := {“Bill”,“Carol”, “Ted”, “Alice”} step WriteLine (“The final roster is = ” + Students) • The variable Students was, initially, an empty set • It was then updated to contain the names of the four students • Update became visible in the second step as the finial roster

  18. Partial update of a set-valued variable var Students as Set of String = {} Main() step WriteLine (“The initial roster is = ” + Students) Students(“Bill”) := true Students(“Carol”) := true Students(“Ted”) := true Students(“Alice”) := true step WriteLine (“The final roster is = ” + Students) • “ X : = val ” is update operation • If X ends with an index form, then the update is partial • If X ends with a variable name, then the update is total

  19. Updating a set-valued variable var Students as Set of String = {} Main() step WriteLine (“The initial roster is = ” + Students) Students := {“Bill”,“Carol”, “Ted”, “Alice”} step WriteLine (“The current roster is = ” + Students) Students ( “Bill”) := false // ( * ) step WriteLine (“The final roster is = ” + Students) • Updating the set Students with updating statement (*)removes “Bill ” from the set • The update is partial in the sense that other students may be added to the set Students in the same step without contradiction

More Related