SlideShare a Scribd company logo
Compiler
Construction
Rahila Farooq
Muhammad Bilal
BCS19-217
Presentation Topic
Tokens
Keywords
Identifier
Token:
Keywords Identifier
Constants Punctuators
Operators
A token is language elements that used to form a statement may consist
of different types of tokens.
Different types of token:
Keywords:
Keywords is a word in language that has a predefined meaning and purpose.
Examples:
digit decimal text final
fixed pass fail self
catch key nil again
test then free loop
typeof auto lambda import
Identifier:
Identifier is the name of a variable or function-name etc. this is also called
user-defined words.
Rules of Identifier declerations:
I. Identifier may include letters, numbers and $ (the Dollar symbol)
II. A variable starts with the $ sign, followed by the name of the variable.
III. Both upper and lowers cases allowed
IV. Keywords cannot be used as identifier name.
V. Variable names are case-sensitive ($age and $AGE are two different
variables)
Constants
integers floating characters Boolean
Constant is a quantity that cannot be changed during execution of a
program.
Operators
Operator is a symbol that perform some operation. It acts on different
openrands .There are types of operators like arithmetic, logical, conditional,
relational, bitwise, assignment operators etc.
Arithmetic Operators
+ - * / %
Logical Operators
&&(AND) ||(OR) !(NOT)
Relational Operators
< <= > >= == !=
Bitwise Operators
& | << >> ~ ^
Assignment Operators
= += /= %=
White Spaces:
Punctuators is a symbol that is used to seperate two tokens.
{ } [ ] ( ) , ; . :
Punctuators (Seperators)
The white spaces used in programs to increase readability. Dieffernt type of
White spaces used .Compiler ignore extra white spaces.
● Space
● Tab
Data Types:
Defines a set of values. Basic data types such as int, float, char etc
In C Alternate Purpose
int digit An digit variable is used to
store an integer
float decimal Decimal is used to store
decimal numbers
char text Text is used to store
characters and letters
Data Types:
Defines a set of values. Basic data types such as int, float, char etc
In C Alternate Purpose
int digit An digit variable is used to
store an integer
float decimal Decimal is used to store
decimal numbers
char text Text is used to store
characters and letters
Variable declaration &
initialization:
Basic Structure :
Variable declaration: data_type $variable_name(statement
terminator)
Variable initialization: data_type $variable_name = value(statement
terminator)
Example:
The forward slash (or
simply slash) character (/)
is used as a statement
terminator.
Variable declaration: digit $num/
Variable initialization: digit $num = 10/
Romail Bhatti
BCS19-226
Presentation Topic
Comments
Loop
Comments:
In programming, comments are hints that a programmer can add to make
their code easier to read and understand. For example,
In C
// - Single Line Comment.
/*... */ - Multi-line Comment.
Alternate
# - Single Line Comment.
#* *# - Multi-line Comment.
Loop:
loop Executes a sequence of statements multiple times that manage by loop
variable.
In C
for(initialisation ; Condition ; inc/dec )
{
// for loop body
}
Alternate
loop(initialisation / Condition / inc/dec
)
{
# for loop body
/}
Examples
➔
loop ( digit $counter=0 / $counter < 9 / $counter++ )
{
# Statement
/}
Lexeme Token Lexeme Token
loop keyword $counter Identifier
( Punctuator < Relational Operator
$counter Identifier 9 constant
digit Keyword(for Integer) / Punctuator
= Assignment Operator $counter Identifier
0 Constant ++ Uniary Operator
/ Punctuator ( Punctuator
$counter Identifier /} Punctuator
Musa Khan
BCS19-247
Presentation Topic
Input / Output
Output:
When we say Output, it means to display some data on screen programming
provides a set of built-in functions to output the data on the computer
screen.
In C
printf(“OUTPUT”);
Alternate
echo “ OUTPUT”/
Lexeme Token
echo keyword
“OUTPUT” text
/ Punctuator
echo “OUTPUT”/
Input:
When we say Input, it means to feed some data into a program. An input can
be given in the from the command line. Programming provides a set of built-
in functions to read the given input and feed it to the program.
In C
scanf(“%d”, &counter);
Alternate
read($counter)/
Lexeme Token
read keyword
( Punctuator
$counter identifier
) Punctuator
/ Punctuator(terminator)
read($counter)/
Muhammad Ali
BCS19-244
Presentation Topic
Main Body
Main Body:
An operating system always calls the main() function when a programmers or
users execute their programming code. It is responsible for starting and ends
of the program. It is a universally accepted keyword in programming
language and cannot change its meaning and name.
In C
return _type main()
{
// main body
}
Alternate
return _type main()
{
# main body
/}
Thanks!
“if you lie to the Compiler;
It will get its revenge”
#Henry Spencer

More Related Content

Similar to Compiler Construction.pptx

C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
Mithun DSouza
 
C programming
C programming C programming
C programming
DipjualGiri1
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
Muthuselvam RS
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
K Durga Prasad
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
KrishanPalSingh39
 
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit DubeyMCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
kiranrajat
 
Introduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdfIntroduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdf
AbrehamKassa
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
sajjad ali khan
 
(Lect. 2 & 3) Introduction to C.ppt
(Lect. 2 & 3) Introduction to C.ppt(Lect. 2 & 3) Introduction to C.ppt
(Lect. 2 & 3) Introduction to C.ppt
atulchaudhary821
 
C programming
C programmingC programming
C programming
PralhadKhanal1
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
20EUEE018DEEPAKM
 
C language ppt
C language pptC language ppt
C language ppt
Ğäùråv Júñêjå
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to cHattori Sidek
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
arpanabharani
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
SURBHI SAROHA
 

Similar to Compiler Construction.pptx (20)

C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
 
Unit 2 introduction to c programming
Unit 2   introduction to c programmingUnit 2   introduction to c programming
Unit 2 introduction to c programming
 
C programming
C programming C programming
C programming
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
C notes
C notesC notes
C notes
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
 
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit DubeyMCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
 
Ch02
Ch02Ch02
Ch02
 
Introduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdfIntroduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdf
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
 
(Lect. 2 & 3) Introduction to C.ppt
(Lect. 2 & 3) Introduction to C.ppt(Lect. 2 & 3) Introduction to C.ppt
(Lect. 2 & 3) Introduction to C.ppt
 
C programming
C programmingC programming
C programming
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
C language ppt
C language pptC language ppt
C language ppt
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
 
C LANGUAGE NOTES
C LANGUAGE NOTESC LANGUAGE NOTES
C LANGUAGE NOTES
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
 

Recently uploaded

NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 

Recently uploaded (20)

NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 

Compiler Construction.pptx

  • 3. Token: Keywords Identifier Constants Punctuators Operators A token is language elements that used to form a statement may consist of different types of tokens. Different types of token:
  • 4. Keywords: Keywords is a word in language that has a predefined meaning and purpose. Examples: digit decimal text final fixed pass fail self catch key nil again test then free loop typeof auto lambda import
  • 5. Identifier: Identifier is the name of a variable or function-name etc. this is also called user-defined words. Rules of Identifier declerations: I. Identifier may include letters, numbers and $ (the Dollar symbol) II. A variable starts with the $ sign, followed by the name of the variable. III. Both upper and lowers cases allowed IV. Keywords cannot be used as identifier name. V. Variable names are case-sensitive ($age and $AGE are two different variables)
  • 6. Constants integers floating characters Boolean Constant is a quantity that cannot be changed during execution of a program. Operators Operator is a symbol that perform some operation. It acts on different openrands .There are types of operators like arithmetic, logical, conditional, relational, bitwise, assignment operators etc. Arithmetic Operators + - * / %
  • 7. Logical Operators &&(AND) ||(OR) !(NOT) Relational Operators < <= > >= == != Bitwise Operators & | << >> ~ ^ Assignment Operators = += /= %=
  • 8. White Spaces: Punctuators is a symbol that is used to seperate two tokens. { } [ ] ( ) , ; . : Punctuators (Seperators) The white spaces used in programs to increase readability. Dieffernt type of White spaces used .Compiler ignore extra white spaces. ● Space ● Tab
  • 9. Data Types: Defines a set of values. Basic data types such as int, float, char etc In C Alternate Purpose int digit An digit variable is used to store an integer float decimal Decimal is used to store decimal numbers char text Text is used to store characters and letters
  • 10. Data Types: Defines a set of values. Basic data types such as int, float, char etc In C Alternate Purpose int digit An digit variable is used to store an integer float decimal Decimal is used to store decimal numbers char text Text is used to store characters and letters
  • 11. Variable declaration & initialization: Basic Structure : Variable declaration: data_type $variable_name(statement terminator) Variable initialization: data_type $variable_name = value(statement terminator) Example: The forward slash (or simply slash) character (/) is used as a statement terminator. Variable declaration: digit $num/ Variable initialization: digit $num = 10/
  • 13. Comments: In programming, comments are hints that a programmer can add to make their code easier to read and understand. For example, In C // - Single Line Comment. /*... */ - Multi-line Comment. Alternate # - Single Line Comment. #* *# - Multi-line Comment.
  • 14. Loop: loop Executes a sequence of statements multiple times that manage by loop variable. In C for(initialisation ; Condition ; inc/dec ) { // for loop body } Alternate loop(initialisation / Condition / inc/dec ) { # for loop body /}
  • 15. Examples ➔ loop ( digit $counter=0 / $counter < 9 / $counter++ ) { # Statement /}
  • 16. Lexeme Token Lexeme Token loop keyword $counter Identifier ( Punctuator < Relational Operator $counter Identifier 9 constant digit Keyword(for Integer) / Punctuator = Assignment Operator $counter Identifier 0 Constant ++ Uniary Operator / Punctuator ( Punctuator $counter Identifier /} Punctuator
  • 18. Output: When we say Output, it means to display some data on screen programming provides a set of built-in functions to output the data on the computer screen. In C printf(“OUTPUT”); Alternate echo “ OUTPUT”/
  • 19. Lexeme Token echo keyword “OUTPUT” text / Punctuator echo “OUTPUT”/
  • 20. Input: When we say Input, it means to feed some data into a program. An input can be given in the from the command line. Programming provides a set of built- in functions to read the given input and feed it to the program. In C scanf(“%d”, &counter); Alternate read($counter)/
  • 21. Lexeme Token read keyword ( Punctuator $counter identifier ) Punctuator / Punctuator(terminator) read($counter)/
  • 23. Main Body: An operating system always calls the main() function when a programmers or users execute their programming code. It is responsible for starting and ends of the program. It is a universally accepted keyword in programming language and cannot change its meaning and name. In C return _type main() { // main body } Alternate return _type main() { # main body /}
  • 24. Thanks! “if you lie to the Compiler; It will get its revenge” #Henry Spencer