This repository was archived by the owner on Sep 20, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed
Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -325,8 +325,11 @@ protected function _parse(Rule $zeRule, $next)
325325 }
326326
327327 $ namespace = $ this ->_tokenSequence ->current ()['namespace ' ];
328+ $ offset = $ this ->_tokenSequence ->current ()['offset ' ];
329+
328330 $ zzeRule = clone $ zeRule ;
329331 $ zzeRule ->setValue ($ value );
332+ $ zzeRule ->setOffset ($ offset );
330333 $ zzeRule ->setNamespace ($ namespace );
331334
332335 if (isset ($ this ->_tokens [$ namespace ][$ name ])) {
@@ -595,7 +598,9 @@ protected function _buildTree($i = 0, &$children = [])
595598 'token ' => $ trace ->getTokenName (),
596599 'value ' => $ trace ->getValue (),
597600 'namespace ' => $ trace ->getNamespace (),
601+ 'offset ' => $ trace ->getOffset ()
598602 ]);
603+
599604 $ children [] = $ child ;
600605 ++$ i ;
601606 }
Original file line number Diff line number Diff line change @@ -105,7 +105,12 @@ class Token extends Rule
105105 */
106106 protected $ _unification = -1 ;
107107
108-
108+ /**
109+ * Token offset.
110+ *
111+ * @var int
112+ */
113+ protected $ _offset = 0 ;
109114
110115 /**
111116 * Constructor.
@@ -237,6 +242,27 @@ public function getValue()
237242 return $ this ->_value ;
238243 }
239244
245+ /**
246+ * Set token offset.
247+ *
248+ * @param int $offset
249+ * @return void
250+ */
251+ public function setOffset ($ offset )
252+ {
253+ $ this ->_offset = $ offset ;
254+ }
255+
256+ /**
257+ * Get token offset.
258+ *
259+ * @return int
260+ */
261+ public function getOffset ()
262+ {
263+ return $ this ->_offset ;
264+ }
265+
240266 /**
241267 * Set whether the token is kept or not in the AST.
242268 *
Original file line number Diff line number Diff line change @@ -175,6 +175,19 @@ public function getValueToken()
175175 : null ;
176176 }
177177
178+ /**
179+ * Get token offset.
180+ *
181+ * @return int
182+ */
183+ public function getOffset ()
184+ {
185+ return
186+ isset ($ this ->_value ['offset ' ])
187+ ? $ this ->_value ['offset ' ]
188+ : 0 ;
189+ }
190+
178191 /**
179192 * Get value value.
180193 *
You can’t perform that action at this time.
0 commit comments