Wednesday, September 1, 2010

The prototype of C++ syntax directed editor

C++ syntax directed editor was designed to work with C++ programs. Usually we work with a text on a letter's level using an ordinary text editors. C++ syntax directed editor offers another approach: you work with constructions of the language (statements, declarations, functions and so on). See the next picture (to enlarge a picture click on it).

As a consequence you'll make much less lexical and syntax errors, build a syntax tree automatically, resolve coloring problem and so on.
Let's consider the example. When you start a new program(File/New menu) you'll see the image on the next picture.
You can see the image of a second Constructions window on the next picture.

The editor "knows" a current context of C++ program and depicts allowed constructions of C++ language for that context in the Constructions window. Double click "type variables" in the Constructions window. The "declaration" nest will be changed by "type variables" as you can see on the next picture.

Click on "function_definition" nest(see the next picture). The nest is highlighted by blue color.

The content of Constructions window is changed (see the next picture). Double click "WinMain..." in the Constructions window.

The "function_definition" nest will be changed by the construction as you can see on the next picture.

Now it's clear how syntax directed editor works.
After development of incremental expression's parser lexical and syntax errors will be totally under control.
So C++ syntax directed editor is a powerful, convenient, reliable tool. Rich set of commands(more than 40 commands) makes a work with it easy and enjoyable.
The importance of syntax directed editors will be increased with a development of intentional programming (IP).
I give a citation from the article written by Charles Simonyi:
“Probably the least natural aspect of IP seems to be the requirement that the source tree be edited as a structure and not as text.
Users have historically accepted direct manipulation for graphics, for example.
However, when the source data is shown in terms of characters, the tradition has been to edit the source as it were a character stream.
The syntax directed editors have come the closest to approximating the IP editing problem.
In the syntax directed paradigm, the syntax rules are immediately applied to the user’s input, with two important results: first the input of illegal constructions is prevented at the outset; and second, as a result of parsing, the system has knowledge of what has been typed and this knowledge can be used in turn to help the user with prompts, automatic formatting, defaults and so on.
Despite these advantages, syntax directed editing has never been a commercial success.
One can only surmise the reasons for the user’s dislike of such systems, but one good guess is that a successful system should be modeless and intentional.
Modelesssness means that work on one section of the code can be always suspended and the focus transferred to some other portion.
Intentional here means that the editor commands should directly relate to the intentions rather than the representation of the intentions.
Modelessness is important because programs are seldom constructed in a strict order.
The programmer must be able to express code fragments whether or not they make sense in their intermediate forms.
There should be no interruptions, demanding prompts, or beeps.
IP does have two subtle forms of reminders: incomplete operands are typically highlighted in color, and there is also a “To Do” list with current references to all incomplete or otherwise incorrect code as discovered by a background type checker.
After finishing some coding the programmer can simply scan the screen for highlights and then scan the todo list for any remaining errors.
Of course, there will always be a few obscure errors which will be uncovered only during the reduction/compilation of the program.
The editing model is based on the standard cut/copy/paste operations, but with about seven different selection types as opposed to the single text selection used by text editors.
Just one of the selection types, for example, is necessary for selections within constants, names or comments which can all be edited as text.
The other types select subtrees, lists of subtrees, individual nodes, places in lists, and left or right operands for operations.
While this is quite a bit more complicated than basic word processing, the programmer users are well equipped and motivated to handle the conceptual load.
Having a reliable and multi-step undo facility also help create a comfortable environment where the consequences of mistakes are very much limited and where experimentation is encouraged.”

Tuesday, August 3, 2010

T-Shirt from Stanford

I met a bug in the original MMIX assembler. Professor Donald E. Knuth mailed me a check and a T-Shirt. The T-Shirt shows a table with codes, names and execution’s time of the MMIX instructions (To enlarge an image click on it).

Sunday, July 18, 2010

MMIXAL.NET

Soon professor Donald E. Knuth(from Stanford university) will publish fourth volume of The Art Of Computer Programming book. (To enlarge a picture click on it.)

A chapter devoted to MMIX language was already published as Fascicle 1. He wants to rewrite all programs in the series using MMIX.

Every student (or software programmer) who studies computer algorithms should know the MMIX language.

Donald E. Knuth invented the MMIX language and created an assembler, a simulator and a debugger for DOS-like operating systems.

The MMIXAL.NET project is based on the original work done by Donald E. Knuth.

MMIXAL.NET was designed to work with MMIXAL programs using the Microsoft.NET framework.

MMIXAL.NET project allows you to assemble, debug and simulate MMIXAL programs with a pleasure which MDI and GUI environments provide.

MMIXAL.NET was written in C# language. The hardware requirements are the same as for Microsoft.NET framework.

The project contains some interesting internals (besides an assembling, a simulating and a debugging as a general process ):
_ how to create Tab control from a set of Panel controls;
_ how to create advance console for Windows Forms;
_ how to number lines of RichTextBox control;
_ how to keep debugger's cursor synchronized with binary code and listing lines;
_ how to use Factory patterns and an inheritance to create different kind of Forms;
_ how to bind break points with binary code;
_ how to implement MDI interface for Windows Forms;
_ how to develop a search of regular expressions for RichTextBox control and internal structure to keep regular expressions as a collection;
_ how to implement double buffering technique to fight a flicker;
_ how to implement intellisense box for fast typing instruction's name;
_ how to use treap structure to organize virtual memory; how to keep it balance;
_ how to use a trie structure to organize symbol table;
_ how to develop a print engine to print opened files;
_ how to implement 64-bit integer arithmetic;
_ how to implement 64-bit floating point arithmetic in accordance with IEEE Standard 754;
_ how to structure the object file;
_ how to create a loader (a program which gets an object file into RAM in order to run it);
_ how to use global variables in C#;
_ how to serialize a state of MMIXAL.NET into a file and vise versa;
_ how to synchronize a simulation of the MMIX program with Windows Forms GUI.
To learn details about how to purchase the product or to report bugs or to make an enquiry send an email to peternik2010@yahoo.com.