When compilers generate errors for a specific programming language, there's distinction between syntax & semantic errors. E.g.
) + f 3 has ill-formed syntax, but type checking is considered as part of semantic analysis.
My intuition tells me that, by setting more constraints on the language syntax, some semantic errors can become syntax errors. And my question is if there are any intrinsic differences between syntax and semantics? Or are they just checking performed on different levels, for example syntax checking is a rather local checking while semantic checking is global? Is there anything fundamental that makes semantics checking different from syntax checking? Is it possible to embed all semantic checking within syntax? Are there any theories related to these questions?
It may also be the case that my intuition is wrong - if that's the case, please also explain to me why that is wrong.