]>
git.saurik.com Git - apple/icu.git/blob - icuSources/data/buildtool/comment_stripper.py
1 # Copyright (C) 2018 and later: Unicode, Inc. and others.
2 # License & terms of use: http://www.unicode.org/copyright.html
6 class CommentStripper(object):
7 """Removes lines starting with "//" from a file stream."""
13 def read(self
, size
=-1):
14 bytes = self
.f
.read(size
)
15 # TODO: Do we need to read more bytes if comments were stripped
16 # in order to obey the size request?
17 return "".join(self
._strip
_comments
(bytes))
19 def _strip_comments(self
, bytes):
22 # state 0: start of a line
32 # state 1: read a single '/'
37 yield "/" # the one that was skipped
41 yield "/" # the one that was skipped
44 # state 2: middle of a line, no comment
49 # state 3: inside a comment