So the definition of a compiler I got is that:
A compiler takes a string as input and checks if that string is syntactically correct, then outputs "Yes" or "No".
So does that mean all compilers are Turing Machines?
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.Sign up to join this community
No, a compiler takes as string as input and checks if that string is syntactically correct. If it is, it outputs another string (code in a different language, e.g., machine code) that is equivalent to the input; if it is not, it outputs "syntax error".
A Turing machine is an abstract machine (i.e., a description of a machine, rather than an actual physical thing) that performs computations. According to the Church–Turing thesis, anything that can be computed by any physical system can be computed by a Turing machine. Since compilers are implemented on physical systems, one could, in principle, design a Turing machine that computes the same mapping from strings to strings as any given compiler. But it's not true that a compiler is a Turing machine; rather, a compiler does something that a Turing machine can also do.