You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current beatmap parser is pretty intricate, because the parsing process is not as simple as it sounds.
I'd consider splitting it into two phases:
The first phase reads the beatmap as a character stream, and generates a raw AST, faithful to the original contents.
The second phase interprets the raw AST and builds a high-level beatmap object. In particular, it implements inheritance, slider path normalization, unit conversion.
Pros:
Makes the code and the concepts easier to understand by splitting the task into 2 clear units.
SAX is a way to parse XML by reacting to events like “opened ”, “found a text node”.
For a beatmap, those events would be “got a metadata key-value”, “got a hit object”. These would be defined in an abstract class as pure virtual methods. The beatmap parser then calls these methods as it reads the beatmap.
This approach effectively split the raw decoding logic, and the interpreation logic. I gets most of the pros above, without the cons. It won't support unordered objects naively though.
The two ways aren't incompatible, as the AST builder could be easily implemented using that abstract interface.
The text was updated successfully, but these errors were encountered:
The current beatmap parser is pretty intricate, because the parsing process is not as simple as it sounds.
I'd consider splitting it into two phases:
Pros:
Cons:
Alternative: SAX-like parser
SAX is a way to parse XML by reacting to events like “opened ”, “found a text node”.
For a beatmap, those events would be “got a metadata key-value”, “got a hit object”. These would be defined in an abstract class as pure virtual methods. The beatmap parser then calls these methods as it reads the beatmap.
This approach effectively split the raw decoding logic, and the interpreation logic. I gets most of the pros above, without the cons. It won't support unordered objects naively though.
The two ways aren't incompatible, as the AST builder could be easily implemented using that abstract interface.
The text was updated successfully, but these errors were encountered: