mapres 3.dev9__tar.gz → 3.dev11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mapres-3.dev9/src/mapres.egg-info → mapres-3.dev11}/PKG-INFO +1 -1
- {mapres-3.dev9 → mapres-3.dev11}/pyproject.toml +1 -1
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/evaluator.py +6 -18
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/tokenizer.py +17 -19
- {mapres-3.dev9 → mapres-3.dev11/src/mapres.egg-info}/PKG-INFO +1 -1
- {mapres-3.dev9 → mapres-3.dev11}/LICENSE +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/README.md +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/setup.cfg +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/__init__.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/ast.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/cache.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/datamap.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/exceptions.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/layers.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/maps/__init__.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/maps/color.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/maps/time.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/parser.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres/resolver.py +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres.egg-info/SOURCES.txt +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres.egg-info/dependency_links.txt +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres.egg-info/requires.txt +0 -0
- {mapres-3.dev9 → mapres-3.dev11}/src/mapres.egg-info/top_level.txt +0 -0
|
@@ -11,15 +11,11 @@ class Evaluator:
|
|
|
11
11
|
self.ctx = ctx or {}
|
|
12
12
|
self._seen = set() # cycle detection
|
|
13
13
|
|
|
14
|
-
#
|
|
15
|
-
# PUBLIC API
|
|
16
|
-
# -----------------------------
|
|
14
|
+
# public api
|
|
17
15
|
def evaluate(self, node):
|
|
18
16
|
return self._eval(node)
|
|
19
17
|
|
|
20
|
-
#
|
|
21
|
-
# INTERNAL DISPATCH
|
|
22
|
-
# -----------------------------
|
|
18
|
+
# internal dispatch
|
|
23
19
|
def _eval(self, node):
|
|
24
20
|
if isinstance(node, TemplateNode):
|
|
25
21
|
return self._eval_template(node)
|
|
@@ -35,18 +31,14 @@ class Evaluator:
|
|
|
35
31
|
|
|
36
32
|
raise EvaluationError(f"Unknown AST node: {node}")
|
|
37
33
|
|
|
38
|
-
#
|
|
39
|
-
# TEMPLATE
|
|
40
|
-
# -----------------------------
|
|
34
|
+
# template
|
|
41
35
|
def _eval_template(self, node: TemplateNode):
|
|
42
36
|
parts = []
|
|
43
37
|
for child in node.children:
|
|
44
38
|
parts.append(self._eval(child))
|
|
45
39
|
return "".join(parts)
|
|
46
40
|
|
|
47
|
-
#
|
|
48
|
-
# IDENTIFIER
|
|
49
|
-
# -----------------------------
|
|
41
|
+
# identifier
|
|
50
42
|
def _eval_ident(self, node: IdentNode):
|
|
51
43
|
name = node.name
|
|
52
44
|
|
|
@@ -77,9 +69,7 @@ class Evaluator:
|
|
|
77
69
|
self._seen.remove(name)
|
|
78
70
|
raise EvaluationError(f"Missing key '{name}'")
|
|
79
71
|
|
|
80
|
-
#
|
|
81
|
-
# CALL (nested token)
|
|
82
|
-
# -----------------------------
|
|
72
|
+
# call (nested token)
|
|
83
73
|
def _eval_call(self, node: CallNode):
|
|
84
74
|
outer = node.name
|
|
85
75
|
|
|
@@ -110,9 +100,7 @@ class Evaluator:
|
|
|
110
100
|
self._seen.remove(outer)
|
|
111
101
|
raise EvaluationError(f"Missing nested key '{outer}({arg_value})'")
|
|
112
102
|
|
|
113
|
-
#
|
|
114
|
-
# HELPERS
|
|
115
|
-
# -----------------------------
|
|
103
|
+
# helpers
|
|
116
104
|
def _map_to_dict(self, m):
|
|
117
105
|
if hasattr(m, "as_map"):
|
|
118
106
|
return m.as_map()
|
|
@@ -50,6 +50,7 @@ class Tokenizer:
|
|
|
50
50
|
self.in_pipe = False
|
|
51
51
|
self.in_percent = False
|
|
52
52
|
self.in_colon = False
|
|
53
|
+
self.escaped = False
|
|
53
54
|
|
|
54
55
|
def peek(self, k=0):
|
|
55
56
|
idx = self.i + k
|
|
@@ -79,27 +80,32 @@ class Tokenizer:
|
|
|
79
80
|
|
|
80
81
|
# ESCAPES
|
|
81
82
|
if self.match(r'\:'):
|
|
82
|
-
buf.append(':'); self.advance(2); continue
|
|
83
|
+
buf.append(':'); self.advance(2); self.escaped = True; continue
|
|
83
84
|
if self.match(r'\<'):
|
|
84
|
-
buf.append('<'); self.advance(2); continue
|
|
85
|
+
buf.append('<'); self.advance(2); self.escaped = True; continue
|
|
85
86
|
if self.match(r'\>'):
|
|
86
|
-
buf.append('>'); self.advance(2); continue
|
|
87
|
+
buf.append('>'); self.advance(2); self.escaped = True; continue
|
|
87
88
|
if self.match(r'\%'):
|
|
88
|
-
buf.append('%'); self.advance(2); continue
|
|
89
|
+
buf.append('%'); self.advance(2); self.escaped = True; continue
|
|
89
90
|
if self.match(r'\$'):
|
|
90
|
-
buf.append('$'); self.advance(2); continue
|
|
91
|
+
buf.append('$'); self.advance(2); self.escaped = True; continue
|
|
91
92
|
if self.match(r'\{'):
|
|
92
|
-
buf.append('{'); self.advance(2); continue
|
|
93
|
+
buf.append('{'); self.advance(2); self.escaped = True; continue
|
|
93
94
|
if self.match(r'\}'):
|
|
94
|
-
buf.append('}'); self.advance(2); continue
|
|
95
|
+
buf.append('}'); self.advance(2); self.escaped = True; continue
|
|
95
96
|
if self.match(r'\|'):
|
|
96
|
-
buf.append('|'); self.advance(2); continue
|
|
97
|
+
buf.append('|'); self.advance(2); self.escaped = True; continue
|
|
97
98
|
if self.match(r'\('):
|
|
98
|
-
buf.append('('); self.advance(2); continue
|
|
99
|
+
buf.append('('); self.advance(2); self.escaped = True; continue
|
|
99
100
|
if self.match(r'\)'):
|
|
100
|
-
buf.append(')'); self.advance(2); continue
|
|
101
|
+
buf.append(')'); self.advance(2); self.escaped = True; continue
|
|
102
|
+
|
|
103
|
+
if self.escaped:
|
|
104
|
+
buf.append(ch)
|
|
105
|
+
self.escaped = False
|
|
106
|
+
self.advance()
|
|
107
|
+
continue
|
|
101
108
|
|
|
102
|
-
# DOUBLE BRACES {{value}}
|
|
103
109
|
if self.match("{{"):
|
|
104
110
|
flush_text()
|
|
105
111
|
self.emit(TokenType.BRACE_OPEN)
|
|
@@ -112,7 +118,6 @@ class Tokenizer:
|
|
|
112
118
|
self.advance(2)
|
|
113
119
|
continue
|
|
114
120
|
|
|
115
|
-
# DOLLARS ${value}
|
|
116
121
|
if self.match("${"):
|
|
117
122
|
flush_text()
|
|
118
123
|
self.emit(TokenType.DOLLAR_OPEN)
|
|
@@ -125,7 +130,6 @@ class Tokenizer:
|
|
|
125
130
|
self.advance()
|
|
126
131
|
continue
|
|
127
132
|
|
|
128
|
-
# ANGLES <value>
|
|
129
133
|
if self.match("<"):
|
|
130
134
|
flush_text()
|
|
131
135
|
self.emit(TokenType.ANGLE_OPEN)
|
|
@@ -138,7 +142,6 @@ class Tokenizer:
|
|
|
138
142
|
self.advance()
|
|
139
143
|
continue
|
|
140
144
|
|
|
141
|
-
# PIPES |value|
|
|
142
145
|
if self.match("|"):
|
|
143
146
|
flush_text()
|
|
144
147
|
if not self.in_pipe:
|
|
@@ -150,7 +153,6 @@ class Tokenizer:
|
|
|
150
153
|
self.advance()
|
|
151
154
|
continue
|
|
152
155
|
|
|
153
|
-
# PERCENTS %value%
|
|
154
156
|
if self.match("%"):
|
|
155
157
|
flush_text()
|
|
156
158
|
if not self.in_percent:
|
|
@@ -162,7 +164,6 @@ class Tokenizer:
|
|
|
162
164
|
self.advance()
|
|
163
165
|
continue
|
|
164
166
|
|
|
165
|
-
# COLONS :value:
|
|
166
167
|
if self.match(":"):
|
|
167
168
|
flush_text()
|
|
168
169
|
if not self.in_colon:
|
|
@@ -174,7 +175,6 @@ class Tokenizer:
|
|
|
174
175
|
self.advance()
|
|
175
176
|
continue
|
|
176
177
|
|
|
177
|
-
# PARENTHESES
|
|
178
178
|
if ch == "(":
|
|
179
179
|
flush_text()
|
|
180
180
|
self.emit(TokenType.LPAREN)
|
|
@@ -187,7 +187,6 @@ class Tokenizer:
|
|
|
187
187
|
self.advance()
|
|
188
188
|
continue
|
|
189
189
|
|
|
190
|
-
# IDENTIFIERS (with dots)
|
|
191
190
|
if ch.isalpha():
|
|
192
191
|
flush_text()
|
|
193
192
|
start = self.i
|
|
@@ -197,7 +196,6 @@ class Tokenizer:
|
|
|
197
196
|
self.emit(TokenType.IDENT, ident)
|
|
198
197
|
continue
|
|
199
198
|
|
|
200
|
-
# DEFAULT: TEXT
|
|
201
199
|
buf.append(ch)
|
|
202
200
|
self.advance()
|
|
203
201
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|