Abstract
J. M. Foster (1968) has described a program called SID (Syntax Improving Device) which can take in a syntax rule set containing embedded actions, automatically produce an equivalent one-track form, and then output a syntax analyser to run on a given object machine. The form of the analyser is ideally a code program which checks the syntactic legality of the input data and arranges the calling of embedded actions as and when required; it does not produce a formal parsing of the input data, although the actions could be programmed to perform this function. SID has proved to be a valuable aid in compiler writing over a wide range of practical applications, extending from simple assembly languages through to quite complicated high level languages (Currie and Griffiths, 1967). The work described in this paper is based on a program called SAG (Syntax Analyser Generator, Simpson, 1968). SAG and SID require similar forms of input data and can produce similar forms of output analyser. However, SAG does not undertake automatic rule transformation; instead it checks the syntax for one-track properties and outputs data to assist in the process of manual transformation into an equivalent one-track set. SAG is a simpler program than SID and can be quickly and easily implemented on quite small computers with limited software facilities. Nonetheless it provides a powerful and flexible aid, particularly when writing compilers to a given specification. Early versions of SAG produced syntax analyser programs in code which were identical in form to analysers produced by SID. However, for certain machines, this led to a rather lengthy analyser, and so an alternative interpretive form of output was developed. In this case SAG produces data which can be operated on by a simple interpreter program. The resulting analyser can be made extremely compact with very little penalty in terms of running time. This paper concerns itself entirely with the interpretive form. The principal elements of the technique are illustrated in Fig. 1. Syntax rules containing actions are processed by SAG; SAG may reject the results if they do not correspond to an acceptable one-track form. If the rules are one-track, then SAG produces a data set which can be operated on by a simple interpreter program. This data set represents a close-packed form of the rules, and includes additional information to assist in the process of syntax analysis. The data set and the interpreter program together form a syntax analyser which can operate on basic symbols generated by a preprocessor. The preprocessor derives the basic symbols from the syntactic content of the input data. The analyser matches the basic symbols against the data set representing the syntax rules and generates a stream of action calls. These action calls control the sequence and timing of the actions which must be programmed to effect the required transformation between input and output. The actions may require value data associated with the input; the preprocessor derives this value data from the semantic content of the input. Also the actions may need global workspace for intercommunication purposes and the storage of intermediate results. This is a very condensed summary of the technique; the various component parts are fully discussed in the paper and a number of examples illustrate how the method might be used in practice. This paper shows how syntax directed techniques can be applied in a direct and straightforward manner. The content of the paper covers four main areas:
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.