summaryrefslogtreecommitdiff
path: root/zwgc/substitute.h
diff options
context:
space:
mode:
authorGravatar Marc Horowitz <marc@mit.edu>1989-11-01 20:02:01 +0000
committerGravatar Marc Horowitz <marc@mit.edu>1989-11-01 20:02:01 +0000
commitd13d8a046838ce3d0e2643bb5b49f2ff77d679ca (patch)
tree05737bc11e3461836ce817939b9129ed58545ac7 /zwgc/substitute.h
parentfd994e4099ad66fb3bf26cd636ca5d5cae72da68 (diff)
Initial revision
Diffstat (limited to 'zwgc/substitute.h')
-rw-r--r--zwgc/substitute.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/zwgc/substitute.h b/zwgc/substitute.h
new file mode 100644
index 0000000..3558262
--- /dev/null
+++ b/zwgc/substitute.h
@@ -0,0 +1,29 @@
+#ifndef substitute_MODULE
+#define substitute_MODULE
+
+#include "new_string.h"
+
+/*
+ * string substitute(string (*lookup)(string); string text)
+ * Effects: returns the result of expanding all variable
+ * references in text using lookup. Example:
+ * "test $foo.$bar baz" would be translated to
+ * "text <foo>.<bar> baz" where "<foo>" is the value of
+ * lookup("foo") and "<bar>" is the value of lookup("bar").
+ * Variables are case sensitive and have the form
+ * {identifier_char}+ where identifier_char is defined
+ * in lexer.h by is_identifier_char. $(foo) and
+ * ${foo} are alternate forms for $foo. In particular,
+ * ${foo}bar is a reference to foo followed by "bar" while
+ * $foobar is a reference to foobar. Incomplete variable
+ * references like $(foo bar are displayed as if they
+ * were not variable references. To allow quoting, "$$"
+ * is translated to "$". Only the first
+ * MAX_IDENTIFIER_LENGTH characters of an identifier are
+ * significant. The strings returned by lookup are not
+ * modified in any way or freed.
+ */
+
+extern string substitute();
+
+#endif