[Gambas-devel] gambas editor added PrettyPrinter

Benoit Minisini gambas at ...1...
Wed Jul 14 21:49:00 CEST 2004

On Monday 12 July 2004 00:46, Charlie Reinl wrote:
> Salut,
> based on 0.94 (not 0.94a) I added to the gb.qt.editor a PrettyPrinter.
> ( editor.TabLength return a int now, I changed it for this version)
> I send you a gambas project (Indenter4-0.0.4.tar.gz) to test it and the
> *.cpp and *.h files I changed (editor_new.tar.gz) ,  copy them to
> /.../gambas-0.94/src/lib/qt/editor/ then compile/install it.
> The PrettyPrinter does not make the sourcecode only readable, he also
> detects Errors .
> When sourcecode loos his Structure a if/endif , for/next etc. is not closed
> correctly.
> Please let me know what you think about.
> Amicalement
> Charlie
> PS: Try to post that mail since yesterday late night , and had problems
> till now

Hi, Charlie

Having a pretty printer is a good idea, but I think that the way you 
implemented it is not the good way! You should have told me before...

The good way would have been using the gb.eval component that includes the 
gambas compiler parser in its code. With a few changes in the parser code 
(just to keep the spaces in a beginning of a line), rewriting a line of code 
from its result is very simple!

As for the detection of error in code structure, the compiler already detect 
that, so it is not useful to add it in the pretty-printer. It is not its 

If you are interested, look at ./lib/eval/eval_read.c or ./comp/gbc_read.c. 
Add #define DEBUG at the beginning of ./comp/gbc_read.c and the compiler will 
display the result of the parser at each compilation.


Benoit Minisini
mailto:gambas at ...1...

More information about the Devel mailing list