[Gambas-devel] gambas editor added PrettyPrinter
Charlie
karl.reinl at ...16...
Sat Jul 17 17:47:57 CEST 2004
Benoit Minisini schrieb:
> 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)
>>
>> .........................
>>
> 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 role.
>
> 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.
>
> Regards,
>
>
Salut Benoît,
first thanks for your patience with me.
I had a look to /comp/gbc_read.c and the output too.
Every valid line commes out word for word and is qualified last of line
is a NEWLINE.
So for some parts I could use it begin and end of Sub and Function .
But I also have to know
Is the line a declaration of an Variable
starts or ends a:
If / Then / Endif section
or a For/next section
or a While / Wend etc.
Because I have to indent the line for one unit or unindent one unit.
For that I use my lists, it would be better to use a common resource.
for the detection of error : if one of these sections are not closed
correctly, the END of the
Function or Sub will not be at left, or the last Line(s) are also at
left and you can follow up backwarts to find
your missing/plus ENDIF etc..
in this Example the compiler say, you have an unclosed ENDIF at the line
where
are the END of the Sub.
PUBLIC SUB mySub()
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
ENDIF
ENDIF
ENDIF
'ENDIF ' this one is comment out
ENDIF
ENDIF
END
The PrettyPrinter will give you that:
PUBLIC SUB mySub()
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
ENDIF
ENDIF
ENDIF
'ENDIF ' this one is comment out
ENDIF
ENDIF
END
PUBLIC SUB mySub()
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
IF TRUE THEN
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF ENDIF
ENDIF' this one is to much
END
So you can find easier the missing/plus ENDIF.
Very usefull in Sub/Function which are very long.
Amicalemnet
Charlie
More information about the Devel
mailing list