summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/opsymbols.pl
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-06-08 13:46:05 +0000
committerKarl Berry <karl@freefriends.org>2010-06-08 13:46:05 +0000
commita960e44eb527236f39aec81babc0474911a86078 (patch)
tree9950eca71791d90820a80a521a7cc252c0955db5 /Build/source/utils/asymptote/opsymbols.pl
parent6443467452320c296faa1f43f0606a9457bd4463 (diff)
asy 1.96
git-svn-id: svn://tug.org/texlive/trunk@18817 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/opsymbols.pl')
-rw-r--r--Build/source/utils/asymptote/opsymbols.pl53
1 files changed, 53 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/opsymbols.pl b/Build/source/utils/asymptote/opsymbols.pl
new file mode 100644
index 00000000000..16ade5374ac
--- /dev/null
+++ b/Build/source/utils/asymptote/opsymbols.pl
@@ -0,0 +1,53 @@
+#!/usr/bin/env perl
+#####
+# opsymbols.pl
+# Andy Hammerlindl 2010/06/01
+#
+# Extract mapping such as '+' --> SYM_PLUS from camp.l
+#####
+
+open(header, ">opsymbols.h") ||
+ die("Couldn't open opsymbols.h for writing");
+
+print header <<END;
+/*****
+ * This file is automatically generated by opsymbols.pl
+ * Changes will be overwritten.
+ *****/
+
+// If the OPSYMBOL macro is not defined for a specific purpose, define it with
+// the default purpose of using SYM_PLUS etc. as external pre-translated
+// symbols.
+
+#ifndef OPSYMBOL
+#define OPSYMBOL(str, name) extern symbol *name
+#endif
+
+END
+
+sub add {
+ print header "OPSYMBOL(\"".$_[0]."\", " . $_[1] . ");\n";
+ my $sym = $_[0];
+ my $name = $_[1];
+ print header <<END;
+#ifndef PRESYM
+#define $name symbol::opTrans("$sym")
+#endif
+END
+}
+
+open(lexer, "camp.l") ||
+ die("Couldn't open camp.l");
+
+while (<lexer>) {
+ #print $_;
+ #if (m/^"(\S+)"\s+\{\s+DEFSYMBOL\((\w+)\);/) {
+ if (m/^"(\S+)"\s*{\s*DEFSYMBOL\((\w+)\);/) {
+ print $1 . " " . $2 . "\n";
+ add($1, $2);
+ }
+ if (m/^(\w+)\s*{\s*DEFSYMBOL\((\w+)\);/) {
+ print $1 . " " . $2 . "\n";
+ add($1, $2);
+ }
+}