Use `re.fullmatch` instead of `re.match`.
diff --git a/compiler/back_end/cpp/header_generator.py b/compiler/back_end/cpp/header_generator.py
index 320b15f..e599585 100644
--- a/compiler/back_end/cpp/header_generator.py
+++ b/compiler/back_end/cpp/header_generator.py
@@ -1739,8 +1739,8 @@
if attr.name.text != attributes.Attribute.NAMESPACE:
return
namespace_value = ir_data_utils.reader(attr).value.string_constant
- if not re.match(_NS_RE, namespace_value.text):
- if re.match(_NS_EMPTY_RE, namespace_value.text):
+ if not re.fullmatch(_NS_RE, namespace_value.text):
+ if re.fullmatch(_NS_EMPTY_RE, namespace_value.text):
errors.append(
[
error.error(
@@ -1750,7 +1750,7 @@
)
]
)
- elif re.match(_NS_GLOBAL_RE, namespace_value.text):
+ elif re.fullmatch(_NS_GLOBAL_RE, namespace_value.text):
errors.append(
[
error.error(
diff --git a/compiler/front_end/attribute_checker.py b/compiler/front_end/attribute_checker.py
index 9e7fec2..78a2a1e 100644
--- a/compiler/front_end/attribute_checker.py
+++ b/compiler/front_end/attribute_checker.py
@@ -44,8 +44,8 @@
def _valid_back_ends(attr, module_source_file):
- if not re.match(
- r"^(?:\s*[a-z][a-z0-9_]*\s*(?:,\s*[a-z][a-z0-9_]*\s*)*,?)?\s*$",
+ if not re.fullmatch(
+ r"(?:\s*[a-z][a-z0-9_]*\s*(?:,\s*[a-z][a-z0-9_]*\s*)*,?)?\s*",
attr.value.string_constant.text,
):
return [