Code some more syntax validation logic

Now it needs some tests and probably a second pass to make it less intricate.

And it needs documentation. As always.

Signed-off-by: Francis Galiegue <fgaliegue@gmail.com>