Skip to content

Commit

Permalink
fix: improve player name regex
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Feb 2, 2024
1 parent a3bdd3c commit b652194
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mecha/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ class AstPlayerName(AstLiteral):
"""Ast player name node."""

parser = "player_name"
regex = re.compile(r"(?!@)[^*\[\]\(\)\{\}\s]+")
regex = re.compile(r"(?![@*[({])\S+")


@dataclass(frozen=True, slots=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/argument_examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
},
{
"properties": { "type": "players", "amount": "single" },
"examples": ["#foo", "$foo", "%foo"]
"examples": ["#foo", "$foo", "%foo", "#exp(-0.1)*65536"]
}
],
"minecraft:entity_anchor": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
minecraft:entity 5 3
---
{'type': 'players', 'amount': 'single'}
---
#exp(-0.1)*65536
---
#exp(-0.1)*65536
---
<class 'mecha.ast.AstPlayerName'>
location: SourceLocation(pos=0, lineno=1, colno=1)
end_location: SourceLocation(pos=16, lineno=1, colno=17)
value: '#exp(-0.1)*65536'

0 comments on commit b652194

Please sign in to comment.