Skip to content

Commit

Permalink
[GR-57159] Parse underscores inside .toml identifiers
Browse files Browse the repository at this point in the history
PullRequest: mx/1825
  • Loading branch information
Andrija Kolic committed Aug 8, 2024
2 parents aada5ef + 8a42825 commit d11f31f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mx/_impl/mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18198,7 +18198,7 @@ def alarm_handler(signum, frame):
_CACHE_DIR = get_env('MX_CACHE_DIR', join(dot_mx_dir(), 'cache'))

# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
version = VersionSpec("7.29.0") # GR-56858: Run ListModules without compilation.
version = VersionSpec("7.29.1") # GR-57159: Parse underscores inside .toml identifiers.

_mx_start_datetime = datetime.utcnow()

Expand Down
1 change: 1 addition & 0 deletions src/mx/_impl/mx_codeowners.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _load_toml_from_fd(fd):
'rule': tree,
}
except RuntimeError as e:
mx.log_error(f"Failed at parsing {fd.name} using the in-house parser. You can try again after installing the 'tomllib' or 'toml' package.")
raise _TomlParsingException(e)


Expand Down
7 changes: 5 additions & 2 deletions src/mx/_impl/mx_stoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def rule(self, streamer):
while True:
while streamer.peek().isspace():
streamer.pull()
if streamer.peek().isalpha():
if self.valid_identifier_character(streamer.peek()):
self.keyvalue(streamer, rule)
else:
return rule
Expand All @@ -132,9 +132,12 @@ def keyvalue(self, streamer, rule):
streamer.terminate("Expected either a string or a list of strings.")
rule[key] = value

def valid_identifier_character(self, c):
return c.isalpha() or c == "_"

def identifier(self, streamer):
ident = ""
while streamer.peek().isalpha():
while self.valid_identifier_character(streamer.peek()):
ident = ident + streamer.peek()
streamer.pull()
return ident
Expand Down

0 comments on commit d11f31f

Please sign in to comment.