mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 03:23:35 +08:00
Fix param scoping to use cmake for parsing.
This commit is contained in:
committed by
Lorenz Meier
parent
44c8857354
commit
85f62f5da0
@@ -1 +1 @@
|
||||
__all__ = ["srcscanner", "srcparser", "xmlout", "dokuwikiout", "dokuwikirpc", "cmakeparser", "scope"]
|
||||
__all__ = ["srcscanner", "srcparser", "xmlout", "dokuwikiout", "dokuwikirpc", "scope"]
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import re
|
||||
import codecs
|
||||
import sys
|
||||
|
||||
class CMakeParser(object):
|
||||
"""
|
||||
Parses provided data and stores all found paths in scope.
|
||||
"""
|
||||
re_split_lines = re.compile(r'[\r\n]+')
|
||||
re_comment = re.compile(r'^\#')
|
||||
re_start = re.compile(r'set\s*\(\s*config_module_list')
|
||||
re_end = re.compile(r'\)\s*')
|
||||
|
||||
def Parse(self, scope, contents):
|
||||
"""
|
||||
Incrementally parse cmake file contents and append all found path scope
|
||||
to scope.
|
||||
"""
|
||||
# This code is essentially a comment-parsing grammar. "state"
|
||||
# represents parser state. It contains human-readable state
|
||||
# names.
|
||||
state = None
|
||||
for line in self.re_split_lines.split(contents):
|
||||
line = line.strip()
|
||||
# Ignore empty lines
|
||||
if line == "":
|
||||
continue
|
||||
if self.re_comment.match(line):
|
||||
continue
|
||||
elif self.re_start.match(line):
|
||||
state = "gather"
|
||||
continue
|
||||
elif state is not None and state == "gather":
|
||||
if self.re_end.match(line):
|
||||
return True
|
||||
scope.Add(line)
|
||||
return False
|
||||
Reference in New Issue
Block a user