summaryrefslogtreecommitdiff
path: root/graphics/asymptote/opsymbols.pl
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/asymptote/opsymbols.pl
Initial commit
Diffstat (limited to 'graphics/asymptote/opsymbols.pl')
-rwxr-xr-xgraphics/asymptote/opsymbols.pl50
1 files changed, 50 insertions, 0 deletions
diff --git a/graphics/asymptote/opsymbols.pl b/graphics/asymptote/opsymbols.pl
new file mode 100755
index 0000000000..06491ad1c6
--- /dev/null
+++ b/graphics/asymptote/opsymbols.pl
@@ -0,0 +1,50 @@
+#!/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 sym::symbol name
+#endif
+
+END
+
+sub add {
+ print header "OPSYMBOL(\"".$_[0]."\", " . $_[1] . ");\n";
+}
+
+open(lexer, "camp.l") ||
+ die("Couldn't open camp.l");
+
+while (<lexer>) {
+ if (m/^"(\S+)"\s*{\s*DEFSYMBOL\((\w+)\);/) {
+ add($1, $2);
+ }
+ if (m/^(\w+)\s*{\s*DEFSYMBOL\((\w+)\);/) {
+ add($1, $2);
+ }
+ if (m/^\s*EXTRASYMBOL\(\s*(\w+)\s*,\s*(\w+)\s*\)/) {
+ add($1, $2);
+ }
+}
+
+print header <<END
+
+/* This file is automatically generated. */
+END