5. Visual Grammar-Directed Parsing of Visual Languages

The problem with procedurally directed parsing is that knowledge about the syntax of each language is embedded implicitly in procedures, making it hard to understand and modify. In the current work, a spatial parser has been written that utilizes context-free grammars which are both visual and machine-readable. The parser takes two inputs: a region of image space and a visual grammar. The parser employs the grammar in recovering the structure for the elements of the graphic communication object lying within the region. One advantage of a visual grammar is that it makes the syntactic features of the visual language it portrays explicit and obvious. Grammars also increase modularity --- by parameterizing one parser with different grammars, it is easy to change the behavior of the parser to handle new visual languages.

To illustrate spatial parsing using visual grammars, consider the visually notated context-free grammar for the very simple family of bar charts shown in Figure 5. The input region to be parsed is marked by a dashed box. Two different views of the successful parse are shown: the concise spiderweb diagram, and the traditional parse tree with labeled nodes (which unfortunately violates the spatial integrity of the arrangement of input elements; the more concise spiderwebs will be used for the remaining examples). Once a visual expression has been parsed as a bar chart, then semantic processing is straightforward. The piece of text at the lower left of Figure 5 represents the interpretation of the bar chart as a table. Parsing also facilitates other kinds of processing: next to the table is a copy of the original bar chart which has been automatically `prettified'.





Figure 5. A visual grammar for a very simple family of bar charts, the input region, and two views of the resulting parse tree; and then, based on the parse, textual interpretation and automatic `prettifying'.