[Gambas-devel] PrettyPrinter-0.3.1 for use in IDE
ron
ronstk at ...124...
Sat Sep 25 11:10:39 CEST 2004
Hi charlie,
You did just the oposite as I proposed.
in the PPsettings:
' bool bEmptylineStartsIndenting=TRUE ; // => adding a empty line after a logical Structure
function name(a as i,b as b) as r
dim z as int
for i = 1 to 7___
bla bla \____ logical block
next_____________/
'this line is add as blank if not exist
if a=b then ______
e=6- \
x=1 \___ block \
y=2_/ \
else \_____ logical structure block
p=9- /
q=3 \___ block /
w=5 / /
end if ___________/
'this line is add as blank if not exist
if a=b then
if t=u then
x=1
y=2
endif ' no add blank line,, a ELSE folows
else
if y=p then
q=3
w=5
endif ' no add blank line,, a END folows
end if
'this line is add as blank if not exist
end
'this line is add as blank if not exist
My intention is not start a new indent cycle (i.e. e=6) with a empty
line as the label tells, my wish was _after_ a END keyword, because
it ends the logical Structure, as you have in the comment.
After delete all empty lines the rules could be in text:
bAddLine=false
' was previous line a NEXT closing the FOR..NEXT structure?
if left(trim(sline_prev),4)="NEXT" then bAddLine=true
' Is it a CASE begin and previous not the start SELECT structure ?
if left(trim(sline),4)="CASE" AND left(trim(sline_prev),4)<>"SELECT" then bAddLine=true
' is it a END after IF/WHILE/WITH/SELECT structures but next not END or ELSE ?
if left(trim(sLine),3)="END" then ' end of log. struct.
bAddLine=true
if left(trim(sLine_next),4)"ELSE" then bAddLine=false ' prevent the add
if left(trim(sLine_next),3)"END" then bAddLine=false ' prevent the add
' this also adds a blank line before the next procedure starts
endif
if bAddLine then add_blank_line 'if not already exist
I had a look in your code and despite the variable names are
telling much I could not see exactly where and how you did it now.
' for IF .... Then with args behind THEN
IF sParts[0] ="IF" AND sParts[iLastPart] <> "THEN" THEN
bIfThenRule = TRUE
IF bEmptylineStartsIndenting THEN bSetAEmptyLine = TRUE
ELSE IF iKeyWords > 0 THEN
IF isEndStruc(sParts,iParts,iKeyWords) THEN
iIndentFactor = iIndentFactor - 1
IF iIndentFactor < 0 THEN
iBadIndentFactor = iBadIndentFactor +iIndentFactor
iIndentFactor = 0
ENDIF
IF bEmptylineStartsIndenting THEN bSetAEmptyLine = TRUE
ENDIF
ENDIF
.......
it looks to me here it is OK but the lines are add before
the inner statement block instead after the END ????
The add blank line after a IF q=3 THEN bAlfa=true line was not my intention.
q=5 ' here follows because next is a IF...THEN <dostatement>
IF q=3 THEN bAlfa=true ' not here
IF q=4 THEN bBeta=true 'or here
IF q=5 THEN bCharlie=true 'but maybe here
IF e=6 THEN 'because a no <dostatement> after THEN
bla bla
ELSE
blo blo
ENDIF
I hoop you can follow the explanation of my idea
Ron
More information about the Devel
mailing list