diff examples/dsl/symbol.h @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/dsl/symbol.h	Sat Dec 22 17:52:45 2007 -0500
@@ -0,0 +1,92 @@
+/*****
+
+ AnaGram Programming Examples
+
+ A Dos Script Language
+ Symbol Table Declarations
+
+ Copyright 1993 Parsifal Software. All Rights Reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty.  In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+    claim that you wrote the original software. If you use this software
+    in a product, an acknowledgment in the product documentation would be
+    appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+    misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+*****/
+
+#ifndef SYMBOL_H
+#define SYMBOL_H
+
+#include "array.h"
+#include "charsink.h"
+#include "strdict.h"
+
+struct action_pointer {
+  unsigned char *pointer;
+  int line, column;
+};
+
+enum symbol_type {
+  undefined_type,
+  dos_type,
+  action_type,
+  value_type,
+  internal_type,
+  integer_type,
+  string_type,
+  formula_type,
+  built_in_function_type
+};
+
+struct action_descriptor {
+  int n_args;
+  unsigned *args;
+  action_pointer ap;
+};
+
+struct symbol_table_entry {
+  symbol_type type;
+  union {
+    char *text;
+    int (*proc)(int, char *[]);
+    long (*func)(void);
+    action_descriptor *action;
+    long integer;
+  } data;
+};
+
+struct internal_commands_descriptor {
+  const char *name;
+  int (*proc)(int n_args, char *args[]);
+};
+
+struct built_ins_descriptor {
+  const char *name;
+  long (*proc) (void);
+};
+
+extern string_accumulator        sa;
+extern string_dictionary         sd;
+extern array<symbol_table_entry> st;
+
+void define_action(int n);
+void define_integer(const char *name, long value);
+void define_string(void);
+void expand_formula(const int *s);
+void init_dos_internals(void);
+void release(action_descriptor *d);
+void release(symbol_table_entry &s);
+void set_arg(int, char *);
+
+#endif