From: Andrea Righi Date: Mon, 5 Dec 2022 08:06:53 +0000 (+0100) Subject: annotations: catch syntax errors in annotations X-Git-Tag: v0.1~50 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=82e74d16edc4b331d67ca867c6666626ac320842;p=annotations.git annotations: catch syntax errors in annotations Trigger a syntax error when a policy or note rule is not properly closed. Signed-off-by: Andrea Righi --- diff --git a/kconfig/annotations.py b/kconfig/annotations.py index 90e58a9..92167f8 100644 --- a/kconfig/annotations.py +++ b/kconfig/annotations.py @@ -68,6 +68,7 @@ class Annotation(Config): # Skip empty, non-policy and non-note lines if re.match('.* policy<', line) or re.match('.* note<', line): try: + # Parse single policy or note rule conf = line.split(' ')[0] if conf in self.config: entry = self.config[conf] @@ -76,11 +77,13 @@ class Annotation(Config): m = re.match(r'.*policy<(.*)>', line) if m: entry['policy'] |= literal_eval(m.group(1)) - m = re.match(r'.*note<(.*?)>', line) - if m: - entry['note'] = "'" + m.group(1).replace("'", '') + "'" - if entry: - self.config[conf] = entry + else: + m = re.match(r'.*note<(.*?)>', line) + if m: + entry['note'] = "'" + m.group(1).replace("'", '') + "'" + else: + raise Exception('syntax error') + self.config[conf] = entry except Exception as e: raise Exception(str(e) + f', line = {line}')