mapres 3.dev6__tar.gz → 3.dev7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapres
3
- Version: 3.dev6
3
+ Version: 3.dev7
4
4
  Summary: A powerfull mapping utility
5
5
  Author: iFamished
6
6
  License: MIT
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "mapres"
10
- version = "3-dev.6"
10
+ version = "3-dev.7"
11
11
  description = "A powerfull mapping utility"
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.9"
@@ -46,6 +46,11 @@ class Tokenizer:
46
46
  self.n = len(text)
47
47
  self.tokens = []
48
48
 
49
+ # state for single-char paired delimiters
50
+ self.in_pipe = False
51
+ self.in_percent = False
52
+ self.in_colon = False
53
+
49
54
  def peek(self, k=0):
50
55
  idx = self.i + k
51
56
  if idx >= self.n:
@@ -72,9 +77,7 @@ class Tokenizer:
72
77
  while self.i < self.n:
73
78
  ch = self.peek()
74
79
 
75
- # ------------------------------------
76
- # ESCAPING: \X → literal X
77
- # ------------------------------------
80
+ # ESCAPES
78
81
  if self.match(r'\:'):
79
82
  buf.append(':'); self.advance(2); continue
80
83
  if self.match(r'\<'):
@@ -96,9 +99,7 @@ class Tokenizer:
96
99
  if self.match(r'\)'):
97
100
  buf.append(')'); self.advance(2); continue
98
101
 
99
- # ------------------------------------
100
102
  # DOUBLE BRACES {{value}}
101
- # ------------------------------------
102
103
  if self.match("{{"):
103
104
  flush_text()
104
105
  self.emit(TokenType.BRACE_OPEN)
@@ -111,9 +112,7 @@ class Tokenizer:
111
112
  self.advance(2)
112
113
  continue
113
114
 
114
- # ------------------------------------
115
115
  # DOLLARS ${value}
116
- # ------------------------------------
117
116
  if self.match("${"):
118
117
  flush_text()
119
118
  self.emit(TokenType.DOLLAR_OPEN)
@@ -126,9 +125,7 @@ class Tokenizer:
126
125
  self.advance()
127
126
  continue
128
127
 
129
- # ------------------------------------
130
128
  # ANGLES <value>
131
- # ------------------------------------
132
129
  if self.match("<"):
133
130
  flush_text()
134
131
  self.emit(TokenType.ANGLE_OPEN)
@@ -141,48 +138,43 @@ class Tokenizer:
141
138
  self.advance()
142
139
  continue
143
140
 
144
- # ------------------------------------
145
141
  # PIPES |value|
146
- # ------------------------------------
147
142
  if self.match("|"):
148
143
  flush_text()
149
- # explicit open/close detection:
150
- # |IDENT| → PIPE_OPEN IDENT PIPE_CLOSE
151
- # parser enforces structure
152
- if self.tokens and self.tokens[-1].type == TokenType.PIPE_OPEN:
153
- self.emit(TokenType.PIPE_CLOSE)
154
- else:
144
+ if not self.in_pipe:
155
145
  self.emit(TokenType.PIPE_OPEN)
146
+ self.in_pipe = True
147
+ else:
148
+ self.emit(TokenType.PIPE_CLOSE)
149
+ self.in_pipe = False
156
150
  self.advance()
157
151
  continue
158
152
 
159
- # ------------------------------------
160
153
  # PERCENTS %value%
161
- # ------------------------------------
162
154
  if self.match("%"):
163
155
  flush_text()
164
- if self.tokens and self.tokens[-1].type == TokenType.PERCENT_OPEN:
165
- self.emit(TokenType.PERCENT_CLOSE)
166
- else:
156
+ if not self.in_percent:
167
157
  self.emit(TokenType.PERCENT_OPEN)
158
+ self.in_percent = True
159
+ else:
160
+ self.emit(TokenType.PERCENT_CLOSE)
161
+ self.in_percent = False
168
162
  self.advance()
169
163
  continue
170
164
 
171
- # ------------------------------------
172
165
  # COLONS :value:
173
- # ------------------------------------
174
166
  if self.match(":"):
175
167
  flush_text()
176
- if self.tokens and self.tokens[-1].type == TokenType.COLON_OPEN:
177
- self.emit(TokenType.COLON_CLOSE)
178
- else:
168
+ if not self.in_colon:
179
169
  self.emit(TokenType.COLON_OPEN)
170
+ self.in_colon = True
171
+ else:
172
+ self.emit(TokenType.COLON_CLOSE)
173
+ self.in_colon = False
180
174
  self.advance()
181
175
  continue
182
176
 
183
- # ------------------------------------
184
177
  # PARENTHESES
185
- # ------------------------------------
186
178
  if ch == "(":
187
179
  flush_text()
188
180
  self.emit(TokenType.LPAREN)
@@ -195,9 +187,7 @@ class Tokenizer:
195
187
  self.advance()
196
188
  continue
197
189
 
198
- # ------------------------------------
199
190
  # IDENTIFIERS (with dots)
200
- # ------------------------------------
201
191
  if ch.isalpha():
202
192
  flush_text()
203
193
  start = self.i
@@ -207,9 +197,7 @@ class Tokenizer:
207
197
  self.emit(TokenType.IDENT, ident)
208
198
  continue
209
199
 
210
- # ------------------------------------
211
200
  # DEFAULT: TEXT
212
- # ------------------------------------
213
201
  buf.append(ch)
214
202
  self.advance()
215
203
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapres
3
- Version: 3.dev6
3
+ Version: 3.dev7
4
4
  Summary: A powerfull mapping utility
5
5
  Author: iFamished
6
6
  License: MIT
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