What is Compiler?
{{complex|2=technical words not everyone can understand|date=December 2024}} [[Image:Compiler.svg|right|thumb|350px|alt=Word soup of the modules in a compiler|List of compiler pieces]] A '''compiler''' is a [[computer program]] that [[translation|translates]] computer code written in one [[programming language]] into another programming language. The first language is called the source language, and the code is called [[source code]]. The [[second language]] is called the target and can usually be understood by computers. In that case, the instructions become [[machine code]]. If a compiler can convert the same instruction text into machine code for different computers (like [[smartphone]]s or video game machines), it is a 'cross-compiler'. If the compiler can make instruction text that is easier for people to read, it is a 'de-compiler'. People who write these instructions are called [[programmers]]. Some even made programs that can translate the instructions that describe how a compiler should work, into a compiler. That kind of program is called a compiler-compiler. A compiler usually has three steps. It reads the text and makes notes about how the instructions go together. If the instructions don't make sense, it will try to tell the programmer. Then it will use what it knows about the target language to make the instructions fit better. It then writes down the instructions in the target language. If the source instructions are on different pages, it may have to compile several before it can write everything down. == Compiling the language == A compiler has six parts : The first piece, a [[lexical analyzer]], reads a page of instruction text and splits it into words and sentences. It also marks the type for each word. For example, a word may be number, a [[variable]], a verb, a math sign, or an adjective. The output of a lexical analyzer is a list of [[token|tokens]]. <code>int x = 5 + y;</code> <code>(type, int) (unknown word, x) (math sign, =) (number, 5) (math sign, +) (word already seen, y)</code>