Sign in Join
Wiki copytemporary

PTop: what changed

Revision 1 to 2. 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` ptop [-v]  [-i  indent]  [-b  bufsize ]  [-c optsfile] infile`
1616
1717- -h : Writes a short description of these switches.
1818- -c configfile : Read options from configuration file. A configuration file is not needed, ptop will revert to internal defaults then. See also -g.
1919- -i ident : Sets the number of indent spaces used for BEGIN END; and other blocks.
2020- -b bufsize : Sets the buffer size to bufsize. Default 255, 0 is considered non-valid and ignored.
2121- -v : be verbose. Currently only outputs the number of lines read/written and some error messages.
2222- -g configfile : Writes a default configuration file to be edited to the file configfile
2323
2424Try 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.
2525
2626## ptop.cfg
2727
2828This is the main configuration file of the ptop.
2929
3030The 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)
3131
3232### Structure
3333
3434The 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)
3535
3636The 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:
3737
3838` keyword=option1,option2,option3,...`
3939
4040If one of the options is "dindonkey" (see further below), a second line (with square brackets) is needed like this:
4141
4242` [keyword]=otherkeyword1,otherkeyword2,otherkeyword3,...`
4343
4444As you can see the block contains two types of identifiers , keywords(keyword and otherkeyword1..3 in above example) and options, (option1..3 above).
4545
4646Keywords 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:
4747
48-<table>
49-<caption>codeword</caption>
50-<thead>
51-<tr>
52-<th><p>Name of codeword</p></th>
53-<th><p>operator</p></th>
54-</tr>
55-</thead>
56-<tbody>
57-<tr>
58-<td><p>casevar</p></td>
59-<td><dl>
60-<dt></dt>
61-<dd>
62-in a case label (&lt;&gt;'colon')
63-</dd>
64-</dl></td>
65-</tr>
66-<tr>
67-<td><p>becomes</p></td>
68-<td><dl>
69-<dt></dt>
70-<dd>
48+codeword
49+
50+**Name of codeword**
51+
52+**operator**
53+
54+casevar
55+
56+
57+in a case label (\<\>'colon')
58+
59+becomes
60+
61+
7162=
72-</dd>
73-</dl></td>
74-</tr>
75-<tr>
76-<td><p>delphicomment</p></td>
77-<td><p>//</p></td>
78-</tr>
79-<tr>
80-<td><p>dopencomment</p></td>
81-<td><p>(*</p></td>
82-</tr>
83-<tr>
84-<td><p>dclosecomment</p></td>
85-<td><p>*)</p></td>
86-</tr>
87-<tr>
88-<td><p>opencomment</p></td>
89-<td><p>{</p></td>
90-</tr>
91-<tr>
92-<td><p>closecomment ||}</p></td>
93-<td></td>
94-</tr>
95-<tr>
96-<td><p>semicolon</p></td>
97-<td><p>;</p></td>
98-</tr>
99-<tr>
100-<td><p>colon</p></td>
101-<td><dl>
102-<dt></dt>
103-<dd>
104-&#10;</dd>
105-</dl></td>
106-</tr>
107-<tr>
108-<td><p>equals</p></td>
109-<td><p>=</p></td>
110-</tr>
111-<tr>
112-<td><p>openparen</p></td>
113-<td><p>[</p></td>
114-</tr>
115-<tr>
116-<td><p>closeparen</p></td>
117-<td><p>]</p></td>
118-</tr>
119-<tr>
120-<td><p>period</p></td>
121-<td><p>.</p></td>
122-</tr>
123-</tbody>
124-</table>
12563
64+delphicomment
65+
66+//
67+
68+dopencomment
69+
70+(*
71+
72+dclosecomment
73+
74+*)
75+
76+opencomment
77+
78+{
79+
80+closecomment \|\|}
81+
82+semicolon
83+
84+;
85+
86+colon
87+
88+
89+
90+equals
91+
92+=
93+
94+openparen
95+
96+\[
97+
98+closeparen
99+
100+\]
101+
102+period
103+
104+.
105+
126106The Options codewords define actions to be taken when the keyword before the equal sign is found.
127107
128-<table>
129108<caption>Options</caption>
130109<thead>
131-<tr>
132-<th>Option</th>
133-<th>does what</th>
134-</tr>
110+
135111</thead>
136112<tbody>
137-<tr>
138-<td>crsupp</td>
139-<td>suppress CR before the keyword.</td>
140-</tr>
141-<tr>
142-<td>crbefore</td>
143-<td>force CR before keyword (doesn't go with crsupp :) )</td>
144-</tr>
145-<tr>
146-<td>blinbefore</td>
147-<td>blank line before keyword.</td>
148-</tr>
149-<tr>
150-<td>dindonkey</td>
151-<td>de-indent on assiociated keywords (see below)</td>
152-</tr>
153-<tr>
154-<td>dindent</td>
155-<td>deindent (always)</td>
156-</tr>
157-<tr>
158-<td>spbef</td>
159-<td>space before</td>
160-</tr>
161-<tr>
162-<td>spaft</td>
163-<td>space after</td>
164-</tr>
165-<tr>
166-<td>gobsym</td>
167-<td>Print symbols which follow a keyword but which do not affect layout.<br />
113+
168114Prints until terminators occur.<br />
169115(terminators are hard-coded in pptop, still needs changing)</td>
170-</tr>
171-<tr>
172-<td>inbytab</td>
173-<td>indent by tab.</td>
174-</tr>
175-<tr>
176-<td>crafter</td>
177-<td>force CR after keyword.</td>
178-</tr>
179-<tr>
180-<td>upper</td>
181-<td>prints keyword all uppercase</td>
182-</tr>
183-<tr>
184-<td>lower</td>
185-<td>prints keyword all lowercase</td>
186-</tr>
187-<tr>
188-<td>capital</td>
189-<td>capitalizes keyword: 1st letter uppercase, rest lowercase.</td>
190-</tr>
116+
191117</tbody>
192-</table>
193118
194119The 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.
195120
196121### Example
197122
198123The lines
199124
200125` else=crbefore,dindonkey,inbytab,upper`\
201126` [else]=if,then,else`
202127
203128Mean:
204129
205130The 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:
206131
207132- (crbefore) Don't allow other code on the line before the keyword. (ELSE alone on a line)
208133- (dindonkey) De-indent on the keywords in square brackets line (if,then,else)
209134- (inbytab) indent by tab.
210135- (upper) uppercase the keyword (ELSE)
211136
212137Try 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.
213138
214139## Links
215140
216141Other FPC utils:
217142
218143- [[ppdep]]
219144- [[ppudump]]
220145- [[ppumove]]
221146- [[H2Pas]]
222147
223148Original page:
224149
225150<http://www.us.freepascal.org/tools/ptop.html>
226151
227152---
228153*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).*
229154Category: FPC
230155Category: Utilities

Back to history