Next: 2.2 Ambiguous Situations
Up: 2 Position
Previous: 2 Position
Context sensitive situations involve the interpretation of data in which the interpretation of one segment of data is dependent upon the interpretation of another segment. In other words, the meaning of one piece of data can potentially change the meaning of a piece of data elsewhere in the system. This is often the case with data transmission, where signals to change the interpretation mode are encountered regularly, or in situation-reactive systems, where interpretation of data from one set of sensors or instruments affects the interpretation of another set of data. Context sensitive situations are a source of subtle programming errors which are difficult to identify and fix. The solution we are exploring is to define a set of formal languages powerful enough to handle the common context sensitive situations identified in problematic components.
The following example outlines the problem, and shows why concise specification is an extremely important attribute of a well-engineered solution. The basic scenario is simple. A data stream includes the following structure:
startVal count time frame1 frame2... frameendVal
Although the grammar is simple, implementing the parser for the data stream with a context-free (or worse yet, with a hand-built) parser has led to several unintentional errors. In the most straightforward formal specification, the grammar had the following fragment of BNF:
frames::= startVal frameList endVal frameList::=startVal count time frame | frameList frameThe source of errors with this scheme is that the count is ignored; there is no declaration of the legal values for count. Further, the actions for the first frame are different than for the second and subsequent frames. The next fragment attempts to include more context sensitivity, but still tries to do so with a context free grammar.
frames::= frameList frameList::=startVal 1 time frame | startVal 2 time frame frame endVal ...Although there is now a special case for each possible value of count, the actions for processing the frames are replicated
The alternative we propose is an extension of the standard context sensitive grammar (where standard here refers to Chomsky level 2, which has limitation that the length of the left side of a production be less than or equal to the length of the right side of the production, see [3]). The following grammar is compact enough for human verification and also explicitly allows the designer to specify the semantic processing for the frame in exactly one location.
frameList ::= completeFrame | frameList completeFrame completeFrame ::= time frame{processing action for the frame}
time frame::= startVal 1 time frame endVal time frame startVal 1 time ::= startVal 2 time frame time frame startVal 2 time ::= startVal 3 time frame ...time frame startVal maxCount-1 time ::= startVal maxCount time frame
In short, for each production
Even though this is a small generalization of the standard (simplest) context sensitive grammar, the impact on the architecture of the software component studied was enormous: rather than a huge number of `special cases', the component can now be specified with a few dozen compact and precise rules. This example, along with our interactions with the engineers that built the original implementation of the module, leads to several observations:
Stephen J. Bespalko and Alexander Sindt