• Nem Talált Eredményt

Using Object Oriented Techniques at Implementing Compilers

N/A
N/A
Protected

Academic year: 2022

Ossza meg "Using Object Oriented Techniques at Implementing Compilers"

Copied!
1
0
0

Teljes szövegt

(1)

Using Object Oriented Techniques at Implementing Compilers

Zoltán Porkoláb

Object Oriented Programming became well-accepted technology of Computer Science in the recent years. Object Oriented Methods of analysis and design are to standardize and supported by CASE tools.

Programming languages - such C++, ADA95 and JAVA - are in everyday use helping the programmer to implement object oriented techniques with classes, using inheritance, exception handling, etc. In a few fields of Computer Science, however, Object Orientation is still not a mayor player. In specially, in the world of compilers, translators, etc. we can see mostly old-fashioned, not object oriented programs. This is perhaps originated in the event-driven attitude of using finite automaton.

In this article I try to explain another way of writing translators - the object oriented way. In this case the object structure of the program is driven from the internal data structures of translation. Lexical tokens are detected by lexer, and passed to the parser as an object. The parser is building a syntax tree using Predictive Descending Algorithm (Aho, Sethi, Ullman: Compilers. Addison-Wesley, 1986), recursion was eliminating with while loops. However this syntax tree is containing objects from a certain object hierarchy. Each node in the tree is an instance of a class corresponding to a certain operator- group. This way of typing the nodes of syntax tree makes late binding in effect at type checking and code generation.

Type checking makes function overloading possible. Rules of function argument matching are sepa- rated in distinct algorithms. A few case of polymorphic function needs special handling. Code generation also use virtual functions producing ready to compile JAVA source. Exception handling is used not only to break syntax analysis at error but also to generate warnings. Error and warning information is encap- sulated in classes and can be caught.

This translator is a part of a real-word project, implemented in JAVA 1.1. In the project 4GL (Super- NOVA) source code is translated to JAVA (applet) source. The translator is validating the 4GL expres- sions and generate JAVA code. Since this 4GL is based on interpreter and allows run-time evaluation of expressions, the class structure of the translator is also a part of the applet. This way the translator is used in compiling time to check the most of the source and generate static JAVA code, but also activated in run-time if a certain expression is using run-time evaluation. The project has finished in the last year and now the translator is ready to use.

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

This is a time for leaders to make a stand and lead the way… This is a time for business and economics faculties in Romania to take the lead in the social changes of society

The university is accredited in the Unit- ed States, Austria and Hungary, and offers English-language graduate de- gree programs in the social sciences, humanities,

Using syntax trees during the comparison of source code files is also possible, however, there is a substantial difference between comparing source code files and comparing the

Our work also considers access control (as part of the Data Access Protection and Data Gatekeeper components), but in combination with other run-time data protection

The UNA program [8] for the analysis of time invariant linear networks has been written by the author of this paper in the BASIC-PLUS language. It can be run in the

In this paper we presented our tool called 4D Ariadne, which is a static debugger based on static analysis and data dependen- cies of Object Oriented programs written in

If the faulty connection of the controlled object R O to the power source (top event O) at time when it should be disconnected is considered hazardous then the fault tree

30 Example for hardship clause: „If at any time or from time to time during the contract period there has been any substantial change in the economic circumstances relating to