4.7. Parsing

Interscript is a language, and needs a parser. Parsing is a complex task. The main control algorithm, however, uses a very simple syntax driven parsing engine. The parser table is a Python list of pairs. Each pair is a tuple consisting of a compiled regular expression and a function. The parser gets one line at a time from the source, and runs through the list, attempting to match the line against a regular expression. When a match is found, the corresponding function is called with the match and source reference data as an argument.

Because this scheme is very simple, it can be extended or modified easily by the end user.

Because the function invoked can read further lines from the input, more sophisticated parsing can be programmed. For example, the Python suite execution function matches against a line starting with an @ and ending with an : or other character that indicates an incomplete suite. The function reads further lines up to the end of the script before executing the lot as a single Python suite.