Sei sulla pagina 1di 1

SAMUEL KING @ DESIGN 2020

Parsing in C
<HOW YOUR COMPUTER READS YOUR CODE>

source code 1.) SENT THROUGHT THE


COMPILER

compiler The first stage of your source code


being read by the computer is for it
to be sent through the compiler. The
compiler will divide and analysis
binary code
your text into machine code.

2.) LEXICAL ANALYSIS

First the compiler divides your text up


into individual tokens, through a
process called tokenization. These
tokens are comprised of key words and
numbers in your source code.

translation_unit
function_definition

declaration_specifier declarator compound_statement


3.) SYNTACTICAL
type_specifier direct_declarator { declaration_list statement_list } ANALYSIS 
direct_declarator declaration statement
INT
identifier
{}

main
declaration specifier init_declaration_list ; expression_statememt
Then these tokens are formed into a
Type_specifier identifier expersion ;
hierarchical structure known as a
assignment_expression
INT x
parse tree. This is how the computer
assignment_expression

assignment_operator identifies the structure of your


constant

unary_expression =
2
source code.
identifier

4.) SEMANTIC ANALYSIS Name type Scope

The compiler then records context about main func int global
the program, including variable and x int local main
fuction names.

5.) GENERATES
01010101000101
00101010110101
Contextualizes your code - converts
01011101000000 to assembly and is read in binary.

<COMPILED BY SAMUEL KING>


Sjking07.github.io

Potrebbero piacerti anche