| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | #ifndef GUARD_TLATE_TLATE_HH |
|---|
| 21 | #define GUARD_TLATE_TLATE_HH |
|---|
| 22 | |
|---|
| 23 | #include "scanner.hh" |
|---|
| 24 | #include "string_value.hh" |
|---|
| 25 | #include "overriding_structured_value.hh" |
|---|
| 26 | |
|---|
| 27 | #include <boost/shared_ptr.hpp> |
|---|
| 28 | #include <iostream> |
|---|
| 29 | #include <set> |
|---|
| 30 | |
|---|
| 31 | namespace tlate |
|---|
| 32 | { |
|---|
| 33 | class tlate |
|---|
| 34 | { |
|---|
| 35 | protected: |
|---|
| 36 | const std::string fname; |
|---|
| 37 | const int line; |
|---|
| 38 | |
|---|
| 39 | tlate(std::string fname, int line) |
|---|
| 40 | : fname(fname) |
|---|
| 41 | , line(line) |
|---|
| 42 | {} |
|---|
| 43 | |
|---|
| 44 | std::string pos() { |
|---|
| 45 | std::ostringstream os; |
|---|
| 46 | os << fname << ":" << line; |
|---|
| 47 | return os.str(); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | public: |
|---|
| 51 | typedef boost::shared_ptr<tlate> ptr; |
|---|
| 52 | |
|---|
| 53 | virtual ~tlate() {} |
|---|
| 54 | |
|---|
| 55 | static ptr parse(scanner); |
|---|
| 56 | static ptr parse(boost::shared_ptr<std::istream> is, |
|---|
| 57 | std::string fname); |
|---|
| 58 | static ptr parse(std::string fname); |
|---|
| 59 | static ptr parse_string(std::string); |
|---|
| 60 | |
|---|
| 61 | virtual value::const_ptr eval_(overriding_structured_value::ptr) = 0; |
|---|
| 62 | value::const_ptr eval(structured_value::ptr env_) { |
|---|
| 63 | overriding_structured_value::ptr env |
|---|
| 64 | (new overriding_structured_value(env_)); |
|---|
| 65 | return eval_(env); |
|---|
| 66 | } |
|---|
| 67 | virtual std::set<std::string> fvs() const = 0; |
|---|
| 68 | }; |
|---|
| 69 | }; |
|---|
| 70 | |
|---|
| 71 | #endif |
|---|