| |
|
|
p.specht
| |
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 07/04/21 ▲ |
|
|
|
|
Sven Bader | thanks for Presentation! I have it yet verfeinert, clinging in Zeichenketten and Kommentaren go ignoring. as by-product go so too yet apertured Zeichenketten as error recognized.
Proc BracketBalance
Parameters line$
Declare c$, u&, d&, st%
WhileLoop len(line$)
c$ = mid$(line$,&Loop,1)
case (c$ = "\q") : st% = If(st% = 0, 1, 0)
If (st% = 0)'only unless in a Zeichenkette
If (c$ = "'") AND (st% = 0)'with comment is Schluss
break
EndIf
case (c$ = "(") : inc u&
case (c$ = ")") : inc d&
EndIf
EndWhile
'0 = ok, 1 = clinging unausgewogen, 2 = Zeichenkette not gschlossen, 3 = both broken
return (if(u& <> d&,1,0) + if(st% = 1, 2, 0))
ENDPROC
declare s1$, s2$, s3$, s4$
s1$ = "Das is a (\qguter\q) Test! 'with comment :-)"
s2$ = "Das is a (\qguter) Test! 'with comment :-)"
s3$ = "Das is a (\qguter\q Test! 'with comment :-)"
s4$ = "Das is a (guter) \qTest! 'with comment :-)"
print BracketBalance(s1$) + " " + s1$'0 = ok
print BracketBalance(s2$) + " " + s2$'3 = both broken (Klammer only because second ausversehen in Zeichenkette)
print BracketBalance(s3$) + " " + s3$'1 = clinging unausgewogen
print BracketBalance(s4$) + " " + s4$'2 = Zeichenkette not gschlossen
waitinput
end
|
|
|
| |
|
|