There can be spaces in the original CGX content almost everywhere : before and after parenthesis, semicolons, and equal signs.
Everywhere a space can be, you can also encounter TABULATION (’\t’) ! I had a hard time figuring this, as you can pass all the test cases without handling tabulations, but not final tests.
Java
There are certainly many ways to solve this puzzle, so my solution is only an exemple. I never studied parsers or lexers, so my approche is probably quite “naive”, and lacks efficiency. But it gives a cool example of inheritance / polymorphism, very important concepts of OOP.
Validator Empty string of characters with spaces (number 5) seems to have 3 lines. The line number 2 should have 2 spaces, then 2 quotes. Two other lines (line number 1 and line number 3) sould have between 1 and 3 spaces.
For those getting 95% only failing the test Block with spaces containing a value, it is needed to ignore whitespaces and tab characters as well.
So for example for this block:
Thanks for the proposal @5DN1L, indeed I had not seen that it was different.
I discovered that the last test did not pass. Unfortunately, after debugging, I realized that it was from the copy and paste. There are 3 characters that have a negative value (how is this possible!?).
Échec
Trouvé : )
Attendu : \-30\-128\-117)
So I adapted my code to ignore the negative characters but I get the same result in the validators.
So I’m still at the same point…
Combining all the input lines into one to work with did it for me, I already had a working program but I didn’t consider this admittedly somewhat cruel case, thank you so much
Test cases not covered case with semicolon inside string. Would be nice also have some name conditions for KEY_VALUE type, so I have not searched ‘=’ in key for example. Maybe it is obviously that key cant have ‘=’ but in such tasks I think must be name conditions…
In case some people have an issue with Validator 17 (Sequences of blocks and strings) or Validator 19 (CGX using every formatting rules), they may find the case below useful for debugging: