Sign in Join
Wiki copytemporary

PTop: what changed

Revision 2 to 3. 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
15-` ptop [-v]  [-i  indent]  [-b  bufsize ]  [-c optsfile] infile`
15+```text
16+ ptop [-v] [-i indent] [-b bufsize ] [-c optsfile] infile
17+```
1618
1719- -h : Writes a short description of these switches.
1820- -c configfile : Read options from configuration file. A configuration file is not needed, ptop will revert to internal defaults then. See also -g.
1921- -i ident : Sets the number of indent spaces used for BEGIN END; and other blocks.
2022- -b bufsize : Sets the buffer size to bufsize. Default 255, 0 is considered non-valid and ignored.
2123- -v : be verbose. Currently only outputs the number of lines read/written and some error messages.
2224- -g configfile : Writes a default configuration file to be edited to the file configfile
2325
2426Try 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.
2527
2628## ptop.cfg
2729
2830This is the main configuration file of the ptop.
2931
3032The 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)
3133
3234### Structure
3335
3436The 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)
3537
3638The 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:
3739
38-` keyword=option1,option2,option3,...`
40+```text
41+ keyword=option1,option2,option3,...
42+```
3943
4044If one of the options is "dindonkey" (see further below), a second line (with square brackets) is needed like this:
4145
42-` [keyword]=otherkeyword1,otherkeyword2,otherkeyword3,...`
46+```text
47+ [keyword]=otherkeyword1,otherkeyword2,otherkeyword3,...
48+```
4349
4450As you can see the block contains two types of identifiers , keywords(keyword and otherkeyword1..3 in above example) and options, (option1..3 above).
4551
4652Keywords 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:
4753
4854codeword
4955
5056**Name of codeword**
5157
5258**operator**
5359
5460casevar
5561
5662
5763in a case label (\<\>'colon')
5864
5965becomes
6066
6167
6268=
6369
6470delphicomment
6571
6672//
6773
6874dopencomment
6975
7076(*
7177
7278dclosecomment
7379
7480*)
7581
7682opencomment
7783
7884{
7985
8086closecomment \|\|}
8187
8288semicolon
8389
8490;
8591
8692colon
8793
8894
8995
9096equals
9197
9298=
9399
94100openparen
95101
96102\[
97103
98104closeparen
99105
100106\]
101107
102108period
103109
104110.
105111
106112The Options codewords define actions to be taken when the keyword before the equal sign is found.
107113
108114<caption>Options</caption>
109115<thead>
110116
111117</thead>
112118<tbody>
113119
114120Prints until terminators occur.<br />
115121(terminators are hard-coded in pptop, still needs changing)</td>
116122
117123</tbody>
118124
119125The 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.
120126
121127### Example
122128
123129The lines
124130
125-` else=crbefore,dindonkey,inbytab,upper`\
126-` [else]=if,then,else`
131+```text
132+ else=crbefore,dindonkey,inbytab,upper
133+ [else]=if,then,else
134+```
127135
128136Mean:
129137
130138The 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:
131139
132140- (crbefore) Don't allow other code on the line before the keyword. (ELSE alone on a line)
133141- (dindonkey) De-indent on the keywords in square brackets line (if,then,else)
134142- (inbytab) indent by tab.
135143- (upper) uppercase the keyword (ELSE)
136144
137145Try 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.
138146
139147## Links
140148
141149Other FPC utils:
142150
143151- [[ppdep]]
144152- [[ppudump]]
145153- [[ppumove]]
146154- [[H2Pas]]
147155
148156Original page:
149157
150158<http://www.us.freepascal.org/tools/ptop.html>
151159
152160---
153161*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).*
154162Category: FPC
155163Category: Utilities

Back to history