Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Term.h
Go to the documentation of this file.
1
/* Project STARS
2
John DiCamillo Software Consulting
3
Copyright © 1997-2000. All Rights Reserved.
4
5
SUBSYSTEM: Stars
6
FILE: term.h
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Declaration of the Abstract Syntax Tree classes
13
*/
14
15
16
#ifndef TERM_H
17
#define TERM_H
18
19
#include "
Text.h
"
20
#include "
List.h
"
21
22
// +-------------------------------------------------------------------+
23
24
class
Term
;
25
class
TermBool
;
26
class
TermNumber
;
27
class
TermText
;
28
class
TermArray
;
29
class
TermDef
;
30
class
TermStruct
;
31
32
// +-------------------------------------------------------------------+
33
34
class
Term
35
{
36
public
:
37
static
const
char
*
TYPENAME
() {
return
"Term"
; }
38
39
Term
() { }
40
virtual
~Term
() { }
41
42
virtual
int
operator==
(
const
Term
& rhs)
const
{
return
0; }
43
44
virtual
void
print
(
int
level=10) { }
45
46
// conversion tests
47
virtual
Term
*
touch
() {
return
this
; }
48
virtual
TermBool
*
isBool
() {
return
0; }
49
virtual
TermNumber
*
isNumber
() {
return
0; }
50
virtual
TermText
*
isText
() {
return
0; }
51
virtual
TermArray
*
isArray
() {
return
0; }
52
virtual
TermDef
*
isDef
() {
return
0; }
53
virtual
TermStruct
*
isStruct
() {
return
0; }
54
};
55
56
Term
*
error
(
char
*,
char
* = 0);
57
58
// +-------------------------------------------------------------------+
59
60
typedef
List<Term>
TermList
;
61
typedef
ListIter<Term>
TermListIter
;
62
63
// +-------------------------------------------------------------------+
64
65
class
TermBool
:
public
Term
66
{
67
public
:
68
static
const
char
*
TYPENAME
() {
return
"TermBool"
; }
69
70
TermBool
(
bool
v) : val(v) { }
71
72
virtual
void
print
(
int
level=10);
73
virtual
TermBool
*
isBool
() {
return
this
; }
74
bool
value
()
const
{
return
val; }
75
76
private
:
77
bool
val;
78
};
79
80
// +-------------------------------------------------------------------+
81
82
class
TermNumber
:
public
Term
83
{
84
public
:
85
static
const
char
*
TYPENAME
() {
return
"TermNumber"
; }
86
87
TermNumber
(
double
v) : val(v) { }
88
89
virtual
void
print
(
int
level=10);
90
virtual
TermNumber
*
isNumber
() {
return
this
; }
91
double
value
()
const
{
return
val; }
92
93
private
:
94
double
val;
95
};
96
97
// +-------------------------------------------------------------------+
98
99
class
TermText
:
public
Term
100
{
101
public
:
102
static
const
char
*
TYPENAME
() {
return
"TermText"
; }
103
104
TermText
(
const
Text
& v) : val(v) { }
105
106
virtual
void
print
(
int
level=10);
107
virtual
TermText
*
isText
() {
return
this
; }
108
Text
value
()
const
{
return
val; }
109
110
private
:
111
Text
val;
112
};
113
114
// +-------------------------------------------------------------------+
115
116
class
TermArray
:
public
Term
117
{
118
public
:
119
static
const
char
*
TYPENAME
() {
return
"TermArray"
; }
120
121
TermArray
(
TermList
* elist);
122
virtual
~TermArray
();
123
124
virtual
void
print
(
int
level=10);
125
virtual
TermArray
*
isArray
() {
return
this
; }
126
TermList
*
elements
() {
return
elems; }
127
128
private
:
129
TermList
* elems;
130
};
131
132
// +-------------------------------------------------------------------+
133
134
class
TermStruct
:
public
Term
135
{
136
public
:
137
static
const
char
*
TYPENAME
() {
return
"TermStruct"
; }
138
139
TermStruct
(
TermList
* elist);
140
virtual
~TermStruct
();
141
142
virtual
void
print
(
int
level=10);
143
144
virtual
TermStruct
*
isStruct
() {
return
this
; }
145
TermList
*
elements
() {
return
elems; }
146
147
private
:
148
TermList
* elems;
149
};
150
151
// +-------------------------------------------------------------------+
152
153
class
TermDef
:
public
Term
154
{
155
public
:
156
static
const
char
*
TYPENAME
() {
return
"TermDef"
; }
157
158
TermDef
(
TermText
* n,
Term
* v) : mname(n), mval(v) { }
159
virtual
~TermDef
();
160
161
virtual
void
print
(
int
level=10);
162
virtual
TermDef
*
isDef
() {
return
this
; }
163
164
virtual
TermText
*
name
() {
return
mname; }
165
virtual
Term
*
term
() {
return
mval; }
166
167
private
:
168
TermText
* mname;
169
Term
* mval;
170
};
171
172
#endif
Parser
Term.h
Generated on Tue Jun 5 2012 20:46:44 for Starshatter_Open by
1.8.1