blob: 706e95bf017ce03076dbb173de7238eba1d73a7d [file] [log] [blame]
reed@android.com289e4fc2009-08-31 18:04:51 +00001#ifndef ForthParser_DEFINED
2#define ForthParser_DEFINED
3
4#include "SkTDict.h"
reed@android.comde2e7fb2009-09-02 02:07:32 +00005//#include "SkString.h"
reed@android.com289e4fc2009-08-31 18:04:51 +00006
7class ForthWord;
8class FCode;
9
10class ForthParser {
11public:
12 ForthParser();
13 ~ForthParser();
14
15 const char* parse(const char text[], FCode*);
16
17 void addWord(const char name[], ForthWord* word) {
18 this->add(name, strlen(name), word);
19 }
20
21 void add(const char name[], size_t len, ForthWord* word) {
reed@android.comde2e7fb2009-09-02 02:07:32 +000022 // SkString str(name, len);
23 // SkDebugf("add %s %p\n", str.c_str(), word);
reed@google.com1d5aaa82011-05-31 15:35:54 +000024 SkDEBUGCODE(bool isNewWord = )fDict.set(name, len, word);
25 SkASSERT(isNewWord);
reed@android.com289e4fc2009-08-31 18:04:51 +000026 }
27
28 ForthWord* find(const char name[], size_t len) const {
29 ForthWord* word;
30 return fDict.find(name, len, &word) ? word : NULL;
31 }
32
33private:
34 void addStdWords();
35
36 SkTDict<ForthWord*> fDict;
37};
38
39#endif