Difference between revisions of "Compiler"

esse quam videri
Jump to: navigation, search
(Created page with "=Definition= =Relevance= =Explanation= Class Diagram =Resources= == See also == ==Notes== ==External Links== Category:Programming Language Concepts Category:...")
 
Line 1: Line 1:
 
=Definition=
 
=Definition=
 +
A program that converts instructions into a machine-code or lower-level form so that they can be read and executed by a computer.
  
 
=Relevance=
 
=Relevance=
 +
Let’s say you’re coding in a piece of software (which often times have compilers built in), such as Microsoft Visual Studio. You want your computer to run your code when you click the “run” button. When you click that button, your computer reads the code you’ve written to make sure it can be converted into a language readable by your computer!
  
 
=Explanation=
 
=Explanation=
 +
There are four major steps a compiler might run through to be sure your code is executable:
 +
 +
'''Scanning''': reading one character at a time from the source code and keeps track of characters and their locations,
 +
 +
'''Lexical Analysis''': The compiler converts the sequence of characters in the source code into a series of strings (known as tokens) which then matches those characters to symbols the computer can identify,
 +
 +
'''Syntactic Analysis''': When you run your code, the compiler has to be sure that your code is readable - if it can’t understand what’s being written, then it won’t run, and that’s no good for anyone!
 +
 +
'''Semantic Analysis''': Here, the compiler checks the tokens stored in relation to the language you’re coding in (ex. Python, C#) and parses your code to an intermediate language, called object code. This has instructions that tells a  processor what to do when it encounters those tokens.
 +
 +
Finally, the compilers looks for optimization and generates final object code that the computer reads.
 +
 +
=Example=
 +
Compilers are what a computer uses to change the written code into what the computer uses.
  
 
Class Diagram
 
Class Diagram

Revision as of 21:31, 19 June 2019

Definition

A program that converts instructions into a machine-code or lower-level form so that they can be read and executed by a computer.

Relevance

Let’s say you’re coding in a piece of software (which often times have compilers built in), such as Microsoft Visual Studio. You want your computer to run your code when you click the “run” button. When you click that button, your computer reads the code you’ve written to make sure it can be converted into a language readable by your computer!

Explanation

There are four major steps a compiler might run through to be sure your code is executable:

Scanning: reading one character at a time from the source code and keeps track of characters and their locations,

Lexical Analysis: The compiler converts the sequence of characters in the source code into a series of strings (known as tokens) which then matches those characters to symbols the computer can identify,

Syntactic Analysis: When you run your code, the compiler has to be sure that your code is readable - if it can’t understand what’s being written, then it won’t run, and that’s no good for anyone!

Semantic Analysis: Here, the compiler checks the tokens stored in relation to the language you’re coding in (ex. Python, C#) and parses your code to an intermediate language, called object code. This has instructions that tells a processor what to do when it encounters those tokens.

Finally, the compilers looks for optimization and generates final object code that the computer reads.

Example

Compilers are what a computer uses to change the written code into what the computer uses.

Class Diagram

Resources

See also

Notes

External Links