[Gambas-devel] about PrettyPrinter
Charlie
karl.reinl at ...16...
Sat Aug 14 18:25:16 CEST 2004
Benoit Minisini schrieb:
>On Friday 13 August 2004 23:53, Charlie wrote:
>
>
>>Benoit Minisini schrieb:
>>
>>
>>>On Sunday 08 August 2004 11:49, Benoit Minisini wrote:
>>>
>>>
>>>>I think... I think :-)
>>>>
>>>>
>>>I continue...
>>>
>>>
>>>
>>>>Wouldn't it be a better idea to pretty print the code directly with the
>>>>compiler, or to create a pretty-printer program that uses the same
>>>>sources than the compiler ? This need passing many options to the
>>>>command line, but I think syntax analyzing code must be centralized as
>>>>much as possible.
>>>>
>>>>
>>>I think you could have wrote your pretty printer in Gambas, as the
>>>GambasEditor class has a method, Analyze() that splits a line into
>>>symbols, spaces, comments, operators... and tells you what is what. I
>>>made it to implement automatic completion, display method signatures and
>>>find symbol definitions in code.
>>>
>>>
>>The first PrettyPrinte was written in gambas-0.56 and posted to the list
>>(25.05.2003) .
>>Then I wrote it in C to re-get in touche with C in Linux and for reason
>>speed .
>>The Indenter4 is mostly part of it. Now keeped to choose the Parameters.
>>
>>
>>
>>>I think it would be a good idea. Is it a problem for you to rewrite your C
>>>pretty printer in Gambas, if I tell you how to use the Analyze() method ?
>>>
>>>
>>No it (I think) will not be a problem, to rewrite it, let us know about
>>Analyze().
>>I will have a look at it, but hints about will be welcome.
>>
>>Amicalement
>>Charlie
>>
>>
>>
>
>The GambasEditor offers the following static methods and properties:
>
>
>STATIC SUB Analyze(sLine AS String)
>
>This function split a Gambas line code into its syntactic components.
>
>
>STATIC PROPERTY READ Symbols AS String[]
>
>Returns an array of symbols included in the analyzed line. For example,
>the following line:
>
>IF Message.Warning(("The file has been modified."), ("Reload"), ("Cancel")) <>
>1 THEN RETURN
>
>will be splitted in the following array:
>
>[ "IF", "Message", ".", "Warning", "(", "(", "The file has been modified.",
>")", ",", "(", "Reload", ")", "(", "Cancel", ")", ")", "<>", "1", "THEN",
>"RETURN" ]
>
>
>STATIC PROPERTY READ Types AS String[]
>
>Returns an array of integer giving the "type" (actually the color) of the
>corresponding symbol in the array returned by the Symbols property.
>
>Use the GambasEditor.Color.* constants.
>
>
>If you have more questions, tell them :-)
>
>And soory for asking you to rewrite your pretty printer back in Gambas, but at
>the 0.56 version, the previous functions didn't exist.
>
>Regards,
>
Salut Benoît,
this is just for my comprehenion.
The GambasEditor.Color.* constants have nothing to do with the visible Editor.Colors
You see my thinkings, a white background and the rest is black.
I tested it, it stills works, but may be I failed my tests.
Amicalement
Charlie
More information about the Devel
mailing list