comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 /*****
2
3 AnaGram Programming Examples
4
5 A Dos Script Language
6 Symbol Table Declarations
7
8 Copyright 1993 Parsifal Software. All Rights Reserved.
9
10 This software is provided 'as-is', without any express or implied
11 warranty. In no event will the authors be held liable for any damages
12 arising from the use of this software.
13
14 Permission is granted to anyone to use this software for any purpose,
15 including commercial applications, and to alter it and redistribute it
16 freely, subject to the following restrictions:
17
18 1. The origin of this software must not be misrepresented; you must not
19 claim that you wrote the original software. If you use this software
20 in a product, an acknowledgment in the product documentation would be
21 appreciated but is not required.
22 2. Altered source versions must be plainly marked as such, and must not be
23 misrepresented as being the original software.
24 3. This notice may not be removed or altered from any source distribution.
25
26 *****/
27
28 #ifndef SYMBOL_H
29 #define SYMBOL_H
30
31 #include "array.h"
32 #include "charsink.h"
33 #include "strdict.h"
34
35 struct action_pointer {
36 unsigned char *pointer;
37 int line, column;
38 };
39
40 enum symbol_type {
41 undefined_type,
42 dos_type,
43 action_type,
44 value_type,
45 internal_type,
46 integer_type,
47 string_type,
48 formula_type,
49 built_in_function_type
50 };
51
52 struct action_descriptor {
53 int n_args;
54 unsigned *args;
55 action_pointer ap;
56 };
57
58 struct symbol_table_entry {
59 symbol_type type;
60 union {
61 char *text;
62 int (*proc)(int, char *[]);
63 long (*func)(void);
64 action_descriptor *action;
65 long integer;
66 } data;
67 };
68
69 struct internal_commands_descriptor {
70 const char *name;
71 int (*proc)(int n_args, char *args[]);
72 };
73
74 struct built_ins_descriptor {
75 const char *name;
76 long (*proc) (void);
77 };
78
79 extern string_accumulator sa;
80 extern string_dictionary sd;
81 extern array<symbol_table_entry> st;
82
83 void define_action(int n);
84 void define_integer(const char *name, long value);
85 void define_string(void);
86 void expand_formula(const int *s);
87 void init_dos_internals(void);
88 void release(action_descriptor *d);
89 void release(symbol_table_entry &s);
90 void set_arg(int, char *);
91
92 #endif