<p>I am wondering if this piece of G-code is valid:</p>

<pre><code>G0 (Some comment (Its G0 command)) Y10 Z-5
</code></pre>

<p>I have tested this on my Chinese CNC machine and it strips out the comment and works flawlessly.</p>

<p>The machine processes this as <code>G0Y10Z-5</code> which seems like the correct approach to me.</p>

<p>I have however never seen such comment in real CNC practise.
It would be nice if anyone is able to test it out on their CNC/3D Printer.</p>

<p>Many G-code simulators on the internet fail to process such a line in their parser so it makes me confused. I haven't found anything about it on RepRap Wiki or even Google.</p>

This is not universally valid G-code, and how it is handled depends on the implementation. You can use this style of comment on
some
machines, but not all.
The way parsing used to be implemented in Marlin (a very common 3D printer firmware), it would work fine unless the comment string included a X, Y, Z, E or F character. The parser simply looks for the first occurrence of X/Y/Z/E/F and then tries to parse the bit of text appearing after that character into a number. If the string cannot be parsed as a number, it defaults to 0 instead. For example,
```
```
G0 (Some comment containing the character Y) Y10 Z-5
```
```
would be interpreted as
```
G0 Y0 Z-5
```
and not as
```
G0 Y10 Z-5
```
, because ") " (the string appearing after the first occurrence of "Y") does not parse to any valid number. Your example happens to work fine because the comment string doesn't contain any special characters.
Marlin does support end-of-line comments, which should start with a semicolon and continue until the end of the line.
This is how it used to work in older Marlin versions. Newer Marlin versions have a more advanced parser, but it still would not play well with these parentheses-style comments. It is best to avoid them, as compatibility is not guaranteed.