aboutsummaryrefslogtreecommitdiffhomepage
path: root/forth/ForthParser.h
blob: 65a39a1a0fa25a1b1eef1c23296a51e2a95ddc75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef ForthParser_DEFINED
#define ForthParser_DEFINED

#include "SkTDict.h"
//#include "SkString.h"

class ForthWord;
class FCode;

class ForthParser {
public:
    ForthParser();
    ~ForthParser();

    const char* parse(const char text[], FCode*);

    void addWord(const char name[], ForthWord* word) {
        this->add(name, strlen(name), word);
    }

    void add(const char name[], size_t len, ForthWord* word) {
    //    SkString str(name, len);
    //    SkDebugf("add %s %p\n", str.c_str(), word);
        (void)fDict.set(name, len, word);
    }

    ForthWord* find(const char name[], size_t len) const {
        ForthWord* word;
        return fDict.find(name, len, &word) ? word : NULL;
    }

private:
    void addStdWords();

    SkTDict<ForthWord*> fDict;
};

#endif