@@ -186,19 +186,23 @@ local function kw (str)
186186 return token (P (str ) * - V " IdRest" )
187187end
188188
189+ local function dec (n )
190+ return n - 1
191+ end
192+
189193local function tagC (tag , patt )
190- return Ct (Cg (Cp (), " pos" ) * Cg (Cc (tag ), " tag" ) * patt )
194+ return Ct (Cg (Cp (), " pos" ) * Cg (Cc (tag ), " tag" ) * patt * Cg ( Cp () / dec , " end_pos " ) )
191195end
192196
193197local function unaryOp (op , e )
194- return { tag = " Op" , pos = e .pos , [1 ] = op , [2 ] = e }
198+ return { tag = " Op" , pos = e .pos , end_pos = e . end_pos , [1 ] = op , [2 ] = e }
195199end
196200
197201local function binaryOp (e1 , op , e2 )
198202 if not op then
199203 return e1
200204 else
201- return { tag = " Op" , pos = e1 .pos , [1 ] = op , [2 ] = e1 , [3 ] = e2 }
205+ return { tag = " Op" , pos = e1 .pos , end_pos = e2 . end_pos , [1 ] = op , [2 ] = e1 , [3 ] = e2 }
202206 end
203207end
204208
@@ -236,25 +240,25 @@ local function addDots (params, dots)
236240end
237241
238242local function insertIndex (t , index )
239- return { tag = " Index" , pos = t .pos , [1 ] = t , [2 ] = index }
243+ return { tag = " Index" , pos = t .pos , end_pos = index . end_pos , [1 ] = t , [2 ] = index }
240244end
241245
242246local function markMethod (t , method )
243247 if method then
244- return { tag = " Index" , pos = t .pos , is_method = true , [1 ] = t , [2 ] = method }
248+ return { tag = " Index" , pos = t .pos , end_pos = method . end_pos , is_method = true , [1 ] = t , [2 ] = method }
245249 end
246250 return t
247251end
248252
249253local function makeIndexOrCall (t1 , t2 )
250254 if t2 .tag == " Call" or t2 .tag == " Invoke" then
251- local t = { tag = t2 .tag , pos = t1 .pos , [1 ] = t1 }
255+ local t = { tag = t2 .tag , pos = t1 .pos , end_pos = t2 . end_pos , [1 ] = t1 }
252256 for k , v in ipairs (t2 ) do
253257 table.insert (t , v )
254258 end
255259 return t
256260 end
257- return { tag = " Index" , pos = t1 .pos , [1 ] = t1 , [2 ] = t2 [1 ] }
261+ return { tag = " Index" , pos = t1 .pos , end_pos = t2 . end_pos , [1 ] = t1 , [2 ] = t2 [1 ] }
258262end
259263
260264-- grammar
0 commit comments