summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2012-06-07 11:09:48 -0700
committerElliott Hughes <enh@google.com>2012-06-07 11:09:48 -0700
commita9719eb4167b544438268d46692389761652fc5d (patch)
treecb4399b94b8e61b41818969940babc4fb461b414 /tools
parent7bda15835732b2ce874a093c136ca406d4f20e00 (diff)
downloadart-a9719eb4167b544438268d46692389761652fc5d.zip
art-a9719eb4167b544438268d46692389761652fc5d.tar.gz
art-a9719eb4167b544438268d46692389761652fc5d.tar.bz2
Clean up the confusing comment-related logic a bit.
This still passes 034, but is a bit clearer because we get all comments out of the way early on. Change-Id: I580ebdca24a4a0738ee102536c8d5b076427264d
Diffstat (limited to 'tools')
-rwxr-xr-xtools/generate-operator-out.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/tools/generate-operator-out.py b/tools/generate-operator-out.py
index 88753b5..aa0c00e 100755
--- a/tools/generate-operator-out.py
+++ b/tools/generate-operator-out.py
@@ -103,8 +103,14 @@ def ProcessFile(filename):
in_enum = False
continue
- # Strip // comments.
- line = re.sub(r'^ *//.*', '', raw_line)
+ # The only useful thing in comments is the <<alternate text>> syntax for
+ # overriding the default enum value names. Pull that out...
+ enum_text = None
+ m_comment = re.compile(r'// <<(.*?)>>').search(raw_line)
+ if m_comment:
+ enum_text = m_comment.group(1)
+ # ...and then strip // comments.
+ line = re.sub(r'//.*', '', raw_line)
# Strip whitespace.
line = line.strip()
@@ -113,17 +119,18 @@ def ProcessFile(filename):
if len(line) == 0:
continue
- # Is this another enum value?
+ # Since we know we're in an enum type, and we're not looking at a comment
+ # or a blank line, this line should be the next enum value...
m = _ENUM_VALUE_RE.search(line)
if not m:
Confused(filename, line_number, raw_line)
-
enum_value = m.group(1)
# By default, we turn "kSomeValue" into "SomeValue".
- enum_text = enum_value
- if enum_text.startswith('k'):
- enum_text = enum_text[1:]
+ if enum_text == None:
+ enum_text = enum_value
+ if enum_text.startswith('k'):
+ enum_text = enum_text[1:]
# Lose literal values because we don't care; turn "= 123, // blah" into ", // blah".
rest = m.group(2).strip()
@@ -141,14 +148,10 @@ def ProcessFile(filename):
rest = rest[1:]
rest = rest.strip()
- # Anything left should be a comment.
- if len(rest) and not rest.startswith('// '):
+ # There shouldn't be anything left.
+ if len(rest):
Confused(filename, line_number, raw_line)
- m_comment = re.compile(r'<<(.*?)>>').search(rest)
- if m_comment:
- enum_text = m_comment.group(1)
-
if len(enclosing_classes) > 0:
enum_value = '::'.join(enclosing_classes) + '::' + enum_value