Sign in Join
Wiki copytemporary

PTop: what changed

Revision 3 to 4. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## About
22
33ptop - The FPC Pascal configurable source beautifier. Name means "Pascal-TO-Pascal".
44
55ptop is a more or less configurable source beautifier for pascal sources and specially the ones supported by FPC. ptop belongs to the FPC utils package, which currently also contains ppdep, h2pas, ppudump and ppumove.
66
77## Author
88
99Michael van Canneyt.
1010
1111## Usage
1212
1313ptop basically reformats "infile" and outputs the result to "outfile". It uses a configuration file explained further below, and can generate a default configuration file for you to edit. (not needed if you use the defaults)
1414
1515```text
1616 ptop [-v] [-i indent] [-b bufsize ] [-c optsfile] infile
1717```
1818
1919- -h : Writes a short description of these switches.
2020- -c configfile : Read options from configuration file. A configuration file is not needed, ptop will revert to internal defaults then. See also -g.
2121- -i ident : Sets the number of indent spaces used for BEGIN END; and other blocks.
2222- -b bufsize : Sets the buffer size to bufsize. Default 255, 0 is considered non-valid and ignored.
2323- -v : be verbose. Currently only outputs the number of lines read/written and some error messages.
2424- -g configfile : Writes a default configuration file to be edited to the file configfile
2525
2626Try to play with ptop and its configfile until you find the effect you desire. The configurability and possibilities of ptop are quite large compared to shareware source beautifier found on e.g. SIMTEL.
2727
2828## ptop.cfg
2929
3030This is the main configuration file of the ptop.
3131
3232The configuration file for ptop(1) isn't necessarily called ptop.cfg, and is also not auto-loaded, so the name doesn't matter much. This man-page describes the structure of such a configuration file for ptop(1)
3333
3434### Structure
3535
3636The structure of a ptop configuration file is a simple buildingblock repeated several (20-30) times, for each pascal keyword known to the ptop program. (see the default configuration file or ptopu.pp source to find out which keywords are known)
3737
3838The basic building block of the configuration file consists out of one or two lines, describing how ptop should react on a certain keyword. First a line without square brackets with the following format:
3939
4040```text
4141 keyword=option1,option2,option3,...
4242```
4343
4444If one of the options is "dindonkey" (see further below), a second line (with square brackets) is needed like this:
4545
4646```text
4747 [keyword]=otherkeyword1,otherkeyword2,otherkeyword3,...
4848```
4949
5050As you can see the block contains two types of identifiers , keywords(keyword and otherkeyword1..3 in above example) and options, (option1..3 above).
5151
5252Keywords are the built-in valid Pascal structure-identifiers like BEGIN, END, CASE, IF, THEN, ELSE, IMPLEMENTATION. The default configuration file lists most of these. Besides the real Pascal keywords, some other codewords are used for operators and comment expressions. These are listed in the following table:
5353
5454codeword
5555
5656**Name of codeword**
5757
5858**operator**
5959
6060casevar
6161
6262
6363in a case label (\<\>'colon')
6464
6565becomes
6666
6767
6868=
6969
7070delphicomment
7171
7272//
7373
7474dopencomment
7575
7676(*
7777
7878dclosecomment
7979
8080*)
8181
8282opencomment
8383
8484{
8585
8686closecomment \|\|}
8787
8888semicolon
8989
9090;
9191
9292colon
9393
9494
9595
9696equals
9797
9898=
9999
100100openparen
101101
102102\[
103103
104104closeparen
105105
106106\]
107107
108108period
109109
110110.
111111
112112The Options codewords define actions to be taken when the keyword before the equal sign is found.
113113
114-<caption>Options</caption>
115-<thead>
116-
117-</thead>
118-<tbody>
119-
120-Prints until terminators occur.<br />
121-(terminators are hard-coded in pptop, still needs changing)</td>
114+**Options**
122115
123-</tbody>
116+| Option | does what |
117+|---|---|
118+| crsupp | suppress CR before the keyword. |
119+| crbefore | force CR before keyword (doesn't go with crsupp :) ) |
120+| blinbefore | blank line before keyword. |
121+| dindonkey | de-indent on assiociated keywords (see below) |
122+| dindent | deindent (always) |
123+| spbef | space before |
124+| spaft | space after |
125+| gobsym | Print symbols which follow a keyword but which do not affect layout. · Prints until terminators occur. · (terminators are hard-coded in pptop, still needs changing) |
126+| inbytab | indent by tab. |
127+| crafter | force CR after keyword. |
128+| upper | prints keyword all uppercase |
129+| lower | prints keyword all lowercase |
130+| capital | capitalizes keyword: 1st letter uppercase, rest lowercase. |
124131
125132The option "dindonkey" requires some extra parameters, which are set by a second line for that keyword (the one with the square brackets), which is therefore only needed if the options contain "dinkdonkey" (contraction of de-indent on assiociated keyword). "dinkdonkey" deindents if any of the keywords specified by the extra options of the square-bracket line is found.
126133
127134### Example
128135
129136The lines
130137
131138```text
132139 else=crbefore,dindonkey,inbytab,upper
133140 [else]=if,then,else
134141```
135142
136143Mean:
137144
138145The keyword this is about is else , it's on the LEFT side of both equal signs. When the ptop parser finds ELSE, the options tell it to do the following things:
139146
140147- (crbefore) Don't allow other code on the line before the keyword. (ELSE alone on a line)
141148- (dindonkey) De-indent on the keywords in square brackets line (if,then,else)
142149- (inbytab) indent by tab.
143150- (upper) uppercase the keyword (ELSE)
144151
145152Try to play with the configfile until you find the effect you desire. The configurability and possibilities of ptop are quite large compared to shareware source beautifier found on e.g. SIMTEL.
146153
147154## Links
148155
149156Other FPC utils:
150157
151158- [[ppdep]]
152159- [[ppudump]]
153160- [[ppumove]]
154161- [[H2Pas]]
155162
156163Original page:
157164
158165<http://www.us.freepascal.org/tools/ptop.html>
159166
160167---
161168*From the Free Pascal wiki, page "PTop", as it stood on 2014-11-20 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
162169Category: FPC
163170Category: Utilities

Back to history