Node:Preprocessor, Next:Lexical analyzer, Up:Internals

### The Pascal preprocessor

`gpcpp` is based on the C preprocessor, so it does everything `cpp` does (see the cpp manual) and some more. In particular:

- Comments like `cpp` does, but within `{ ... }` and `(* ... *)`, also after `//` if `delphi-comments` is active, never within `/* ... */`. Also mixed comments (`{ ... *)`, `(* ... }`) if enabled (`mixed-comments`) and nested comments (e.g. `{ ... { ... } ... }`) if enabled (`nested-comments`)
- Macros and conditionals like `cpp` does, but both case sensitive and insensitive ones; `no-macros` to turn macro expansion off (e.g., for BP compatibility)
- `ifopt` for short and long options
- Include files like `cpp` does, but also with `{$I ...}` (BP style), which allows the file name extension to be omitted
- Recognize Pascal strings (to avoid looking for comments and directives within strings) enclosed in single (like Standard Pascal) or double quotes (like C).
- Option handling, sharing tables in `gpc-options.h` with the compiler:
  - Default option settings
  - Options can imply other options (e.g., `borland-pascal` -> `no-macros` etc.)
  - Short compiler directives
  - Short directive `W` (warnings) is disabled in `borland-pascal` and `delphi` because it has another meaning there
- Compiler directives (`{$...}` or `(*$...*)`):
  - pass them through, so the compiler can handle them
  - keep track of them for `ifopt`
  - handle those that affect the preprocessor (e.g., about comments)
  - allow comments within compiler directives if nested comments are enabled
  - local directives
  - case insensitive
- Slightly Pascal-like syntax for conditional compilation (`not` -> `!`, `and` -> `&&`, `or` -> `||`, `xor` -> `!=`, `shl` -> `<<`, `shr` -> `>>`, `False` -> `0`, `True` -> `1`, `<>` -> `!=`, `=` -> `==`)
- Line directives like `cpp` does, but recognize BP style (`#42` or `#$f0`) character constants and don't confuse them with line directives (the latter seem to always have a space after the `#`)