Structured Program Lookahead

Abstract Language structures are presented that allow a program to predict the result of executing a block of statements. This result can be used to decide whether to execute the block, or to take some other action. This lookahead facility is, in expressive power, equivalent to backtracking. Unlike general backtracking, lookahead as a language feature lends itself well to structured programming and efficient implementation. Examples are presented that illustrate the use of lookahead. Implementation methods, as embodied in a working compiler, are given.