Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/cpphs/docs/design

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Design for hspp

First pass:
-----------
  * traverse the file,
      - processing #if's and #ifdef's
      - reading #include's and recursively doing this pass on them
      - leaving #line's behind
      - whilst taking account of #define's and #undef's
  * only needs to look at lines beginning with a #
  * should discard C-style comments?  (no)
  * DO NOT gather the #define's for macros - their sequence matters!

pass1 :: SymTab -> String -> String

Second pass:
------------
  * traverse the residual file,
      - keeping track of #define'd macros
      - expanding #define'd macros when an instance is encountered
  * needs a whitespace-preserving tokeniser with odd rules to
    cover e.g. token concatenation.  Within Haskell, quotation marks start
    strings, haskell comments are preserved.  Within a cpp directive,
    quotation marks do not start a string, and C-style comments are
    converted to whitespace.
  * Line continuation characters are tricky; probably should only
    be recognised within a macro definition, not in ordinary code.

pass2 :: SymTab -> String -> String

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.