
Macro Processing
Andrew Davison, ad@coe.psu.ac.th, May 2026

This directory contains two Python versions of a Macro processor describe by Kernighan and Plauger in "Software Tools in Pascal". 

Due to the book's age, I've included a copy of the macro processing chapter and its source code here.

The Python code and tests:
=========================
* macro3.py   -- close to Pascal version
* rdMacro.py  -- uses recursive descent parsing

* define.m3
* expr.m3
* ifelse.m3
* len.m3
* substr.m3
* changeq.m3
* nested.m3
* deep.m3
* multiTests.m3, multiTests2.m3

Usage:
> python macro3.py define.m3
> python macro3.py -trace changeq.m3

> python rdMacro.py define.m3
> python rdMacro.py -trace changeq.m3


The Original Pascal Code
=========================
From:
  "Software Tools in Pascal"
  Brian W. Kernighan, P. J. Plauger
  Addison-Wesley, 1981
  Chapter 8
  1981 by Bell Labs. and Whitesmiths Ltd.

A copy of chapter 8:
* STP-Ch8.pdf

The Pascal source code for chapter 8:
* define3.pas
* macro3.pas
* utils.pas  -- general purpose utilities 

The book is currently available for borrowing from the Internet Archive at  
https://archive.org/details/softwaretoolsinp00kern

All of the source code from the book has been preserved by Shuo Chen at
https://github.com/chenshuo/software-tools-in-c
