+
+ # Collect loose tokens (not in the AST) and attach them to token in the AST
+ var cursor = token
+ if n != cursor then
+ var lt = last_token
+ # In order, we have the tokens:
+ # * `lt` the previous visited token in the AST (if any)
+ # * then `cursor` the loose tokens to attach
+ # * then `n` the current visited token in the AST
+
+ # In the following, we advance `cursor` to add them to `lt.next_looses` or to `n.prev_looses`.
+ if lt != null then
+ var ltl = lt.location.line_end
+ # floating tokens on the same line of a AST-token follows it
+ while cursor != null and cursor != n and ltl == cursor.location.line_start do
+ cursor.is_loose = true
+ lt.next_looses.add cursor
+ cursor = cursor.next_token
+ end
+ end
+ # other loose tokens precede the next AST-token
+ while cursor != null and cursor != n do
+ cursor.is_loose = true
+ n.prev_looses.add cursor
+ cursor = cursor.next_token
+ end
+ end
+ token = n.next_token
+