MCPcopy Index your code
hub / github.com/cpplint/cpplint / ReplaceAlternateTokens

Function ReplaceAlternateTokens

cpplint.py:2077–2095  ·  view source on GitHub ↗

Replace any alternate token by its original counterpart. In order to comply with the google rule stating that unary operators should never be followed by a space, an exception is made for the 'not' and 'compl' alternate tokens. For these, any trailing space is removed during the con

(line)

Source from the content-addressed store, hash-verified

2075
2076
2077def ReplaceAlternateTokens(line):
2078 """Replace any alternate token by its original counterpart.
2079
2080 In order to comply with the google rule stating that unary operators should
2081 never be followed by a space, an exception is made for the 'not' and 'compl'
2082 alternate tokens. For these, any trailing space is removed during the
2083 conversion.
2084
2085 Args:
2086 line: The line being processed.
2087
2088 Returns:
2089 The line with alternate tokens replaced.
2090 """
2091 for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line):
2092 token = _ALT_TOKEN_REPLACEMENT[match.group(2)]
2093 tail = "" if match.group(2) in ["not", "compl"] and match.group(3) == " " else r"\3"
2094 line = re.sub(match.re, rf"\1{token}{tail}", line, count=1)
2095 return line
2096
2097
2098class CleansedLines:

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected