allow location to be parsed from an exact string#8773
Conversation
| } | ||
|
|
||
| private static class LocationParser extends Parser<Location> { | ||
| private static final String NUMBER = "[-+]?\\d+(?:\\.\\d+)?"; |
There was a problem hiding this comment.
Don't use a regex matcher, split based on keywords and use the same parsers that are used for toString in the first place.
There was a problem hiding this comment.
Don't use a regex matcher, split based on keywords and use the same parsers that are used for toString in the first place.
which approach would you recommend?
substring at each
x:
y:
z:
...
manually handle world as a part of pitch
or, do the same thing but split at commas?
the issue is there's still some requirement to run different code to get the world since the format is
x: 0, y: 0, z: 0, yaw: 0, pitch: 0 in world 'world'
since in world is basically apart of pitch if I split at by commas
this is why I thought using regex instead was a no brainer
There was a problem hiding this comment.
Split at x: , , y: , , z: , , yaw: , , pitch: and in ' (the exact strings from toString); if the last of which is missing, then the world was null. Not using regex helps avoid bugs here, for example your current NUMBER regex is incorrect because it does not match NaN or Infinity (which are valid outputs from toString!)
There was a problem hiding this comment.
Pushed my most recent changes. is this what you meant?
Problem
Location strings cannot be parsed as a location, users would need to manually split the string themself then form the location that way.
Solution
Allow string to be parsed back into location if it matches the required format.
x: number, y: number, z: number, yaw: number, pitch: number [in 'world']Testing Completed
Supporting Information
Just a proposal. Not sure if this has been discussed or why/why not it would be allowed or disallowed.
Completes: 8772
Related: none
AI assistance: CoPilot