summaryrefslogtreecommitdiff
path: root/docs/tools/dump_ast_matchers.py
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tools/dump_ast_matchers.py')
-rw-r--r--docs/tools/dump_ast_matchers.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/docs/tools/dump_ast_matchers.py b/docs/tools/dump_ast_matchers.py
index 9ecff049c9638..45540405de97c 100644
--- a/docs/tools/dump_ast_matchers.py
+++ b/docs/tools/dump_ast_matchers.py
@@ -47,7 +47,7 @@ def esc(text):
except:
doxygen_probes[url] = False
if doxygen_probes[url]:
- return r'Matcher&lt<a href="%s">%s</a>&gt;' % (url, name)
+ return r'Matcher&lt;<a href="%s">%s</a>&gt;' % (url, name)
else:
return m.group(0)
text = re.sub(
@@ -83,6 +83,11 @@ def strip_doxygen(comment):
"""Returns the given comment without \-escaped words."""
# If there is only a doxygen keyword in the line, delete the whole line.
comment = re.sub(r'^\\[^\s]+\n', r'', comment, flags=re.M)
+
+ # If there is a doxygen \see command, change the \see prefix into "See also:".
+ # FIXME: it would be better to turn this into a link to the target instead.
+ comment = re.sub(r'\\see', r'See also:', comment)
+
# Delete the doxygen command and the following whitespace.
comment = re.sub(r'\\[^\s]+\s+', r'', comment)
return comment
@@ -90,7 +95,7 @@ def strip_doxygen(comment):
def unify_arguments(args):
"""Gets rid of anything the user doesn't care about in the argument list."""
args = re.sub(r'internal::', r'', args)
- args = re.sub(r'const\s+', r'', args)
+ args = re.sub(r'const\s+(.*)&', r'\1 ', args)
args = re.sub(r'&', r' ', args)
args = re.sub(r'(^|\s)M\d?(\s)', r'\1Matcher<*>\2', args)
return args
@@ -226,7 +231,7 @@ def act_on_decl(declaration, comment, allowed_types):
m = re.match(r"""^\s*AST_MATCHER(_P)?(.?)(?:_OVERLOAD)?\(
(?:\s*([^\s,]+)\s*,)?
\s*([^\s,]+)\s*
- (?:,\s*([^\s,]+)\s*
+ (?:,\s*([^,]+)\s*
,\s*([^\s,]+)\s*)?
(?:,\s*([^\s,]+)\s*
,\s*([^\s,]+)\s*)?
@@ -259,6 +264,16 @@ def act_on_decl(declaration, comment, allowed_types):
add_matcher('*', name, 'Matcher<*>', comment)
return
+ # Parse Variadic functions.
+ m = re.match(
+ r"""^.*internal::VariadicFunction\s*<\s*([^,]+),\s*([^,]+),\s*[^>]+>\s*
+ ([a-zA-Z]*)\s*=\s*{.*};$""",
+ declaration, flags=re.X)
+ if m:
+ result, arg, name = m.groups()[:3]
+ add_matcher(result, name, '%s, ..., %s' % (arg, arg), comment)
+ return
+
# Parse Variadic operator matchers.
m = re.match(
r"""^.*VariadicOperatorMatcherFunc\s*<\s*([^,]+),\s*([^\s>]+)\s*>\s*
@@ -358,11 +373,11 @@ traversal_matcher_table = sort_table('TRAVERSAL', traversal_matchers)
reference = open('../LibASTMatchersReference.html').read()
reference = re.sub(r'<!-- START_DECL_MATCHERS.*END_DECL_MATCHERS -->',
- '%s', reference, flags=re.S) % node_matcher_table
+ node_matcher_table, reference, flags=re.S)
reference = re.sub(r'<!-- START_NARROWING_MATCHERS.*END_NARROWING_MATCHERS -->',
- '%s', reference, flags=re.S) % narrowing_matcher_table
+ narrowing_matcher_table, reference, flags=re.S)
reference = re.sub(r'<!-- START_TRAVERSAL_MATCHERS.*END_TRAVERSAL_MATCHERS -->',
- '%s', reference, flags=re.S) % traversal_matcher_table
+ traversal_matcher_table, reference, flags=re.S)
with open('../LibASTMatchersReference.html', 'wb') as output:
output.write(reference)