Skip to content

Commit 52d4e16

Browse files
Marc-Oliver GewaltigMarc-Oliver Gewaltig
authored andcommitted
Most of the tries ported
1 parent e15919f commit 52d4e16

12 files changed

+834
-536
lines changed

base.mk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
#CXX=g++-mp-4.6
2121
CC=clang
2222
CXX=clang
23+
2324
GDB=-g
2425
CCFLAGS= -O2 $(GDB) -Wall
25-
#CXXFLAGS= -O3 $(GDB) -I/opt/local/include -Wall -pedantic
26-
27-
CXXFLAGS= -O3 -Wall -pedantic
26+
CXXFLAGS= -O3 $(GDB) -Wall -pedantic
2827

2928
## Linker flags
3029
LDLIBS= -lstdc++

makefile

Lines changed: 315 additions & 52 deletions
Large diffs are not rendered by default.

sli_array.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ class TokenArray
4242
unsigned int alloc_block_size;
4343
unsigned int refs_;
4444

45-
// bool homogeneous;
46-
4745
void allocate(size_t, size_t, size_t, const Token & = Token());
4846

49-
5047
public:
5148
static size_t allocations;
5249

sli_interpreter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ namespace sli3
181181
order in which the lables in the enum typeid (sli_type.h) are
182182
defined.
183183
*/
184+
types_[sli3::nulltype]=(new OperatorType<sli3::nulltype>(this,"nulltype"));
185+
types_[sli3::anytype]=(new OperatorType<sli3::anytype>(this,"anytype"));
184186
types_[sli3::integertype]=(new IntegerType(this,"integertype",sli3::integertype));
185187
types_[sli3::doubletype]=(new DoubleType(this,"doubletype",sli3::doubletype));
186188
types_[sli3::booltype]=(new BoolType(this,"booltype",sli3::booltype));

sli_token.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ namespace sli3
2626
class SLIString;
2727
class SLIistream;
2828
class SLIostream;
29-
29+
class TypeNode;
30+
3031
class Token
3132
{
3233
public:
@@ -56,7 +57,8 @@ namespace sli3
5657
* Exchange the contents of t and this token.
5758
*/
5859
Token & swap(Token &t);
59-
60+
61+
6062
/**
6163
* Clear contents of token.
6264
*
@@ -113,17 +115,18 @@ namespace sli3
113115
SLIType *type_; //!< If NULL, the datum is unused.
114116
union value
115117
{
116-
double double_val;
117-
long long_val;
118-
bool bool_val;
119-
size_t name_val;
120-
TokenArray *array_val;
121-
SLIFunction *func_val;
122-
Dictionary *dict_val;
123-
SLIString *string_val;
124-
SLIistream *istream_val;
125-
SLIostream *ostream_val;
126-
TypeNode *trie_val;
118+
double double_val;
119+
long long_val;
120+
bool bool_val;
121+
size_t name_val;
122+
TokenArray *array_val;
123+
SLIFunction *func_val;
124+
Dictionary *dict_val;
125+
SLIString *string_val;
126+
SLIistream *istream_val;
127+
SLIostream *ostream_val;
128+
TypeNode *trie_val;
129+
SLIType *type_val;
127130
} data_;
128131
};
129132

sli_trie.h

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,54 +14,58 @@
1414
*
1515
*/
1616

17-
#ifndef SLITYPECHECK_H
18-
#define SLITYPECHECK_H
19-
#include <typeinfo>
20-
#include "slifunction.h"
17+
#ifndef SLI_TYPECHECK_H
18+
#define SLI_TYPECHECK_H
2119

22-
class TrieFunction: public SLIFunction
23-
{
24-
public:
25-
TrieFunction() {}
26-
void execute(SLIInterpreter *) const;
27-
};
20+
#include "sli_function.h"
2821

29-
class TrieInfoFunction: public SLIFunction
22+
namespace sli3
3023
{
31-
public:
32-
TrieInfoFunction() {}
33-
void execute(SLIInterpreter *) const;
34-
};
24+
void init_slitypecheck(SLIInterpreter *);
3525

36-
class AddtotrieFunction: public SLIFunction
37-
{
38-
public:
39-
AddtotrieFunction() {}
26+
class TrieFunction: public SLIFunction
27+
{
28+
public:
29+
TrieFunction() {}
4030
void execute(SLIInterpreter *) const;
41-
};
42-
43-
class Cva_tFunction: public SLIFunction
44-
{
45-
public:
46-
Cva_tFunction() {}
31+
};
32+
33+
class TrieInfoFunction: public SLIFunction
34+
{
35+
public:
36+
TrieInfoFunction() {}
4737
void execute(SLIInterpreter *) const;
48-
};
49-
50-
class Cvt_aFunction: public SLIFunction
51-
{
52-
public:
53-
Cvt_aFunction() {}
38+
};
39+
40+
class AddtotrieFunction: public SLIFunction
41+
{
42+
public:
43+
AddtotrieFunction() {}
5444
void execute(SLIInterpreter *) const;
55-
};
56-
57-
class TypeFunction: public SLIFunction
58-
{
59-
public:
60-
TypeFunction() {}
45+
};
46+
47+
class Cva_tFunction: public SLIFunction
48+
{
49+
public:
50+
Cva_tFunction() {}
6151
void execute(SLIInterpreter *) const;
62-
};
63-
64-
65-
void init_slitypecheck(SLIInterpreter *);
66-
52+
};
53+
54+
class Cvt_aFunction: public SLIFunction
55+
{
56+
public:
57+
Cvt_aFunction() {}
58+
void execute(SLIInterpreter *) const;
59+
};
60+
61+
class TypeFunction: public SLIFunction
62+
{
63+
public:
64+
TypeFunction() {}
65+
void execute(SLIInterpreter *) const;
66+
};
67+
68+
69+
}
6770
#endif
71+

sli_trietype.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef SLI_TRIETYPE_H
22
#define SLI_TRIETYPE_H
33
#include "sli_type.h"
4-
#include "sli_trie.h"
4+
#include "sli_type_trie.h"
55
#include <cassert>
66
namespace sli3
77
{

sli_type.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef SLI_TYPE_H
33
#define SLI_TYPE_H
44
#include "sli_name.h"
5+
56
namespace sli3
67
{
78

@@ -19,7 +20,9 @@ namespace sli3
1920

2021
enum sli_typeid
2122
{
22-
integertype=0,
23+
nulltype=0, //!< used for unassigned type_id values
24+
anytype, //!< Used for typechecking only
25+
integertype,
2326
doubletype,
2427
booltype,
2528
literaltype,
@@ -29,19 +32,20 @@ namespace sli3
2932
dictionarytype,
3033
nametype,
3134
litproceduretype,
35+
trietype, //!< Type Trie
3236
functiontype,
3337
proceduretype,
3438
iiteratetype,
3539
irepeattype,
3640
ifortype,
3741
iforalltype,
42+
nooptype,
3843
quittype,
3944
symboltype,
40-
num_sli_types,
41-
trietype,
4245
istreamtype,
4346
xistreamtype,
4447
ostreamtype,
48+
num_sli_types, //!< Number of builtin types. User type ids start here
4549
intvectortype,
4650
doublevectortype,
4751
iteratortype
@@ -99,6 +103,7 @@ namespace sli3
99103
return name_;
100104
}
101105

106+
102107
bool is_type(unsigned int id) const
103108
{
104109
return id_ == id;
@@ -120,6 +125,11 @@ namespace sli3
120125
return executable_;
121126
}
122127

128+
SLIInterpreter *get_interpreter() const
129+
{
130+
return sli_;
131+
}
132+
123133
virtual bool compare(Token const &t1, Token const& t2) const=0;
124134

125135
virtual std::ostream& print(std::ostream &, const Token &) const;

0 commit comments

Comments
 (0)