-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change code style: Tabs after short sub-program
bad tabs searcher: ``` ## procedure WriteInColor(s: string; c: System.ConsoleColor); begin var oc := Console.ForegroundColor; Console.ForegroundColor := c; Write(s); Console.ForegroundColor := oc; end; var r := new Regex( '(?<=\r|\n)'+ // expect line start '((?: )*)(?! )'+ // initial tabs '(?!where)'+ // ignore class where section '(?:(?!//)[^\r\n]*)'+ // ignore commented out stuff '(?<!\Wrecord)'+ // ignore one line record '\W(?:function|procedure|constructor)(?=\W)'+ // method keyword '(?<!''[^\r\n]*)'+ // ignore string literals '(?:\s+\w+|(?<=constructor))'+ // check that sub-program has name (or is constructor) '(?![^\r\n]*\W(?:abstract)\W)'+ // ignore abstract and external '(?![^\r\n]*\)[^\r\n]*:=[^\r\n]*;)'+ // ignore short methods '(?![^\r\n(]*:=[^\r\n]*;)'+ // ignore short methods with no () '[^\r\n]*(?:\r?\n)'+ // up to line break '(?![^\r\n]*(?<!\w)(?:public|private|protected|function|procedure)\W)'+ // ignore if next line is another class member '(?![^\r\n]*{\$endif)'+ // ignore if next line is $endif '(?! *(?://[^\r\n]*)?(?:\r?\n))'+ // ignore if next line is empty '\1(?!(?:begin|try)\W| )', // check wrong tabs RegexOptions.Singleline); var c := 0; var files := EnumerateAllFiles('G:\0Prog\POCGL', '*.pas').ToArray; foreach var fname in files index i do begin $'>>> {fname}'.Println; Console.Title := $'{i}/{files.Length} ({i/files.Length:P})'; var text := ReadAllText(fname); foreach var m: &Match in r.Matches(text) do begin var lc := text.Take(m.Index).CountOf(#10)+1; // count line and char both from 1 var cc := m.Index-text.LastIndexOf(#10,m.Index); $'[{fname}] at line {lc} char {cc}:'.Println; Write( text.Remove(m.Index)?[^100:] ); WriteInColor(m.Value, System.ConsoleColor.Yellow); Write( text.Remove(0,m.Index+m.Length)?[:100] ); Println; Println('='*50); c += 1; while true do begin var s := ReadlnString; case s of 'o': Exec(fname); '': break; else $'Unknown command [{s}]'.Println; end; end; end; end; Console.Title := $'Done'; $'Total {c} found'.Println; Readln; ```
- Loading branch information
Showing
8 changed files
with
183 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.