Pic is a domain-specific language by Brian W. Kernighan for specifying diagrams. It is mostly used in combination with the groff typesetting system but is also a valid input format for some programs found in the plotutils package.
A typical document preparation workflow using the PIC preprocessor could look like this:
The following input was used to create this picture:
.PS
ellipse "document"
arrow
box "PIC"
arrow
box "TBL/EQN" "(optional)" dashed
arrow
box "TROFF"
arrow
ellipse "typesetter"
.PE
The following limitations are known.
Macros are not part of the Pic language. When the scanner finds a macro call, it does a simple text replacement using the macro parameters. Neither the macro definition nor the macro call needs to be a correct Pic statement or expression. This makes is impossible to parse all macros correctly.
See the following example which is perfectly legal code for pic
:
define foo { circle at $1 $2 }
foo((2,2), diam 1)
foo((3,5), rad 1)
Consider the following piece of code:
copy thru X
box "$1"
X
10
When GNU pic parses this code, it checks if X
has been defined as a macro. If it is a macro, then it is called using the following three lines as data. If X
is not defined as a macro, then it is parsed as a character delimiter and the block between the two X
characters is used as an inline macro.
The tree-sitter implementation doesn't record the defined macros and may therefore parse this specific piece of code differently. You can use longer macro names and non-alphabetic letters as inline macro delimiters to avoid this ambiguity.
- Brian W. Kernighan, PIC - A Graphics Language for Typesetting - User Manual
- Eric S. Raymond, Making Pictures with GNU PIC
- W. Richard Stevens, Examples of pic Macros