The Development Environment

Introduction

Depot4 is a translator generator. It behaves quite similar to an ordinary programming environment, just terminology differs somewhat. What is usually called a programming language is now the meta language (Ml4). And what you know as compiling is said to be implementation (or even translation ). If all needed rules have been translated successfully, you can apply (or use) your newly generated translator - quite similar to running a compiled program.
It's essential to distinguish both phases clearly to avoid misunderstanding.

Depot4/Java IDE Interface

The Depot4/Java IDE is an integrated development environment (IDE) for developing and applying (domain specific language) translators. The main frame consists of the following primary components:

Menu bar

The menu bar contains the following menus:

top


Work Cards

Each work card consists of one or two text editor areas. The currently active area is marked by highlighting its border.

These are the standard work cards:

There are two more work cards available:

top



The menus

File
Standard menu group, consisting of
New
Clears the active editor pane and its (eventually) associated file name.
Open
Displays a file selection dialog and loads the selected file's content into the editor pane.
Save
Opens a file selection dialog and save the active editor pane's content in the selected file.
Print
Prints the active editor pane's content.
Quit
Quits the application. (There is no warning regarding unsaved editor panes.)
All but the Quit action are not enabled if there is no current active editing area. The New and Open actions are enabled only if the editing area is a source text area.
Edit
The Edit menu is enabled only if there is a current active editing area. This standard menu group consists of
Clear
Clears the active editor pane but does not change any (eventually) associated file name.
Undo Clear
Undoes one preceeding clear operation.
Cut
Copies the selected text stretch into the system clipboard and clears the selection.
Copy
Copies the selected text stretch into the system clipboard.
Paste
Pastes the clipboard contents.
Goto
Moves the cursor to the required position. This is useful as the translator emits error positions. If there is a text selection that is long enough the position is computed from the begin of the selection. (This is useful as with Translate Selected the error position will be relative to the start of the selection.)
Find...
Simple earch for a certain string.
Find again
Redo the last search.
Font
Opens submenus for selecting font face, font size, and font style.
Translate
All
Starts the translation taking the source text pane of the current work card as input. Actual execution depends from this card.
Selected
As before, but only the selected text stretch is processed. (Hint: Any error positions are locally to this selection then.)
List all nonterminals
Logs the list of all currently known nonterminals and their implementing classes into the log area. (There is an own list for every work card.)
Options
The Options menu contains a number of checkboxes to enable/disable options:
Case sensitive: If not checked, upper and lower case characters in identifiers are considered equal.
Check enabled: If checked, an additional check against unbounded recursion will be done.
Trace: If checked, every invocation of a nonterminal will be logged on entry and exit.
Warnings (only for Ml4 translation): Logs some warnings that may be useful for fixing problems.
Verbose Compiling (only for Ml4 translation): Sets the -verbose switch for the Java compiler.
Logging: Offers a submenu for more individual logging.
Window
Contains actions to add and delete different work cards. It is possible to add customized cards with the Add ... card action. (Examples: Dp4.ide.Counts, Dp4.ide.Tree, Dp4.ide.AST, Dp4.ide.ASTXML)
Save card settings: Save the current card settings (including fonts) to a local configuration file.
Debug
The Debug menu is only enabled if a Debug work card is selected.
Breakpoints
Opens the Breakpoin dialog. Breakpoints may be set on entry and exit of a nonterminal implementation only.
Info
Help
Opens the help viewer.
About
See the about box, which includes current settings and heap usage.

top



The Work Cards

Implementation

Mostly, you look for a translator generator because you want to do some translation. So one usually starts with defining the translator. This is by no means an easy job but a tool like this may be helpful.
Depot4 is a nonterminal based system, i.e. all rules for a single nonterminal are collected in one production. Such productions constitute the basic entities, which the generator handles.
See Ml4 Syntax for a short description of the Ml4 language.
Converting the Ml4 description of a translation rule into an executable form takes two steps. First a Java class definition is generated. Then the Java compiler is called. Usually, this should be of little interest for the user. (As nobody wants to be bothered with object formats when using a compiler.) The only difference is that there may occur error messages from the Java compiler. As most of the possible faults are catched by the Ml4->Java translator this happens seldom. The most likely reasons are the use of Java keywords (such as do) as identifier (this will be catched in a future version) and parameter mismatch with imported objects.
If the translated rule was already loaded it will be reloaded before it is applied again in a Use action.

top


Implement from file list

This allows the joint implementation of a list of Ml4 descriptions. Thus, the text area does not contain any Ml4 text but the respective file names.
There is an additional button Add File which allows you to select files individually by use of the standard file dialog. Their names are appended to the content of the text area. You can save and reload this list as an ordinary text file.
Hint: With some earlier Java version multiple file selection does not work. Add the files one by one then.

top


Use

This is the mode of applying a generated translator. It is defined by giving the name of its root production. Input is taken from the Source text area. Any output, i.e., the first target of the root production, will be displayed in the Target area.

In the text area Module search paths one can add packages and URLs, where to search for translated productions (generated class files). They are separated by newlines (LF orCR).

Syntax
Package
Give the package name as in Java's package statement, e.g. "my.nice.pack"
URL
A full quailified URL of the appropriate directory is expected, e.g. "file://localhost/classes/" (trailing slash may be omitted)
Example
With the above given package and URL, a rule "ThisRule" will be searched for as
  1. ThisRule
  2. This.ThisRule
  3. my.nice.pack.ThisRule
  4. file://localhost/classes/ThisRule.class
  5. Dp4.ThisRule
If it was written Thisrule, THISrule, etc. point 2 is not applied.
Remark: The interface as it is, doesn't fully exploit Depot4's capabilities. Only one target will be displayed (up to eight are possible) and you have to save it explicitly. Let us mention again that this interface is just one way of using translators. One can also use the translators from within any other Java program by calling the translation method of Depot4's runtime. There is just the need to apply the constructor of the source object before. (For more detail, have a look into the code of Dp4Run.java, which is freely available, too.)

top


Debug

This is an additional frame that allows you to set breakpoints at intrance and/or exit of every called production. ( It is possible to stop at every second, third, ... call only, too.) Type the name in the text field, check/unckeck the on entry/on exit boxes and press the "add" button. Doing this again for the same name will change previous settings. Unckecking both boxes is similar to removing a breakpoint.
The function of the "Go" buttons is the same as that of the "Do" one on the Debug card. They are there just for your convenience.
At breakpoints one more frame appears. Pressing its buttons causes the display of information in the Log. One can inspect the current position, the nonterminal's implementation target name (...where the code comes from), the JVM stack trace, the call stack of the parser, and - but only on exit, of course - the accepted source text and the generated target.
You can change breakpoint settings by pressing the "add" button with the new settings again.

top


©J. Lampe 2002-2003                              (20-Mar-2003)