Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

C Language

Tokens

Saurabh Shukla (MySirG)


-
Agenda
-

① What are tokens ?

② Constants
③ variables
⑥ keywords
⑤ comments
tokens
also known lexical elements
tokens are as

211%-95
-

The text of c / C++ program


consists of
tokens and white space .

The token is the smallest element of


a C / C++ program
that is meaningful
to the compiler .

Parser is a
program
whose job is to

separate these tokens .


tokens
-

Parser these kinds of tokens :


recognizes
-

Constants ( Literals )
-

Identifiers ( variables ,
functions . . . .
)
-

Keywords
-

operators
Punctuations
space
-

operator
✓ ← ← constant
int 9=5 I
↑ ↑
← punctuates
keyword variable )
C
identities
Whitespace
-

Tokens are
usually separated by white
space ,
which can be one or more

Blanks
-

Tabs
-
New lines
-
Form feed
- Comments
Cornmeal
-
Comments are text ignored by compiler

Comments are useful for documentation
of your code and useful for programmers .

There are two types of cemments


line comment 11 text here
① Single
Multi line
comment /*
② text line I

text line 2
' '
- n

*
/
Sample
-
Program in C

operators
Punctuators
inn# main C) Constants
{ Identifiers
iinntt b. c ; / / variables
keywords
a

* numbers 11$ ;
"

print f- Enter two


" comments
scant # %d%d Afa , &b☆
"


;

C=za*- b :
CD :
"

prin.tt #
"
sum is %d •
*
ends here /
/
*
main function body
}
utinsata
Inform
-
-

primary secondary
3 Pointers
Integer 25
,
-417,0 ,
.

• array
" "

-0.05 63.1.3.0 Bhopal


4. 15 string
-

Real , ,
-
structure
' ' ' ' ' ' '

character a A 5 't .
union
enumerator
#É7
-

I 1

1.*
' ' '

yn
Variables

G-]
-60
Di
RAM
program
,memf¥É
CPU or

men

Variables

Variables
Variable is name of location
a memory

where we store
program
's data .
during
execution of
program .

variable name is combination of


any

alphabets ( atoz or Ato 2) , digits (01-09)


and underscore C- )

No other symbol is allowed .

a valid variable name cannot start from


a
digit

variable
.

name cannot be a keyword .


a- 2 ✓ a- b- 2-3 ~

✗ -
I ✗ b$ ✗

s.li ✗ 52 ✗
x y ✗
if ✗ ( keyword)
IF ✓
-
A ✓

2x ✗
sensitive
c
language is a case

language
cisu keywords
p_ք#Reserved words
case sensitive

language

?¥¥m?!
auto double int struct _
Bool
break else switch Complex
long -
_

Align of
register typedef
enum
case -
Imaginary
char extern return union
inline Generic
const float short unsigned
-

continue for signed void restrict _


Noreturn

default goto size of volatile a Static assert

i.FI /
_
_

do static _
Thread local _

-689 Cgg
1-
32
Keywords +5
Cll
+7

You might also like