0 ratings 0% found this document useful (0 votes) 4 views 16 pages CC Mod1
In more advanced deep learning, architectures are designed to handle specific types of data. For example, Convolutional Neural Networks (CNNs) are widely used for image and video processing because they exploit spatial hierarchies through convolutional layers, while Recurrent Neural Networks (RNNs) and their variant LSTMs/GRUs are better suited for sequential data like text and speech due to their ability to retain temporal dependencies.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
19-01-2025
| INTRODUCTION :
+ Comelerp 15 a System software wiatcin_converts
high-tevel languages (HLL) into object pragram a
|The 1s calied as ___ Language translators /_!
___||_ processor - _ 7 oS =
tL _ INTERPRETER COMPILER
|| Lin Translate each inetructen ci) Wansiate whole oo
|__| before execusion: ____ program __once . _{|
(iy Easier te change: Ly Complicated to change:
(iy Less memory its Memory required |
required. —
i
ivy Slower execution. Gy) Faster execution.
Comps PRoe
| ‘Source PROGRAM
| ANALYSIS |
} INTERMEDIATE ~ CODE
eyntuesss |
eBsect PROGRAM
PHases OF _CoMmpzter SOyREE PROGR
J Lex tean ANALYZER
. ab
1 SYNTAX _ANALYZER
[ern z L ae
4
TaoLe SEMANTIC anaurzer] oo
[ Manages
INTERMEDIATE _cobe
apie
coor aa
T
Gone GENERATOR _|
OATECT PROGRAM.s
eS
|| cuitable__block diagram:
What are
Le Lensenl ANALYZER:
| sunctions
|(iyTt_seans__the _pfogram _staternent from
|
d
lett 45
fight it recognize GQ _ token
«Ik Separates the token.
stk 1s also called Scanner.
I cide Te deletes _COmment statement
[te ts done 40 avoid carrying
Unnecess avi
statements to neat Stages. a
ity _-3¢ the boken © Qn identifrer, ite details are
entered into symbol table
|
1
lw - Tf any macro exiers, Madero ‘proéeing_» macro expansion
jj .
I is performed -
stn © MAC implementation by _atoersNe-
| + Io Cre cero implementation py INLINE FurveTtore
Aopen subroutine: MAcRO 2 95 copying of codes:
teclosed Subroutine: FUNCIIONS =) OS control goes 12
Another place.
How to poss tokens from LA +o SA
ne:
+All fized quantities in the language like
Keywords, operations, punctuation _rnarks , éte-, will —
be Aired with a Numertcal value
Whereas, if the token fe an ‘denbifier/ ——~
Constant, it wil] be represented _Y_ USI
aclassmate,
oe pair—of valu
r
L =
——
— - y +
indicates Whether indicates _4he address where.
ik_16 an _identifier/constants Ane sdentifier 1s Stored In
cma the _sumlo\ table .
5 - constant
eg: if H- idencifiey Jed—by com designer -
my F
symbol Table -
(4,50) 3G constant stored
Ot address 50»
:
By vefernm (., -), we can easily ideniify «
(3- 01-2028
2. SYNTAX €3SEMANTIC ANALYZER
Check if it ie yntabicalie correct oy nob -
Th eyntar of th program 2intement _cnill_be whethev
the given programa stat i _aymtactically correct oF Ne.
ge Content Free- Grammnay iil) be used for th
same fow uyntactic _ verification -
Semantic- .Meaning -
The Semantic corvectness will be checked by using
Semantic analyzer -
Check 1f the plogram taiement _{6 meaningful oy not
éa: O=zbre is syntactically correct) lout nok
Semantically Always.
eg: “Type compatibility + Os bre
CIN —eTloany treaty
hesical analyzer, Syntax _analyzeY % Semantic analyzer
ore part of analysis stage.
Thus an __intetrmediate cade ig generated «Intermediaie Code ig trade related
to_obj
H Ss ci
| Tntermediat code can be o|
ker f the following op
(i) Parse TREE _-_o/P of syntax analyzer» ‘
(ill Posterx NOTATION -
SO
Operators after o, eran veer
(li) @uapaynes |
i
| auadweles
i sHave marimum 4 fields.
| = Operator, Operands, result -
| = eg: A= B+C4D
perp eee Tis cxD
en eS ee Ta=BeTi
| =, T2,A Azte
5: CODE OPTIMIZATION
Reducing execution time and memory.
To_rmake the core more efficient, 1.@., less
execution time @ memory requirements .
=| Tnorde fo attain thi: ‘orn fearrangernents
ov chang. in_the Code (operations) to.._naake ft
may, fFiovents . (Result mua be Same).
eq! Az BxC+D
X= BeCtE
bet =B*Cy 4then
A=Y+D
X=Nte ier
The _no-of multiplication ie reduced , which i cor (es
But assignment Operator is iniroduced »but ttCoster than _*- Chess no -of cycles). + -
Loop optimization. Reducing the time taken __foy ___
eRECULIO in___looping Statements» _____
ke
€9 26,1420; (t+) ————
= 5, eee eas
J
| __Th_can_be optimized by __taking a= 5 autside _the_loop:
_lecal optimization .
| 6: CODE GENERATION a ———
eg: A=B+C%D
We write mnemonic
LoAD
MUL
ADO
Store 5A
or_binary (05 f 1'5) -
(5-15 tre temp: feg)-
or 1s
Ollection OF records con. wit attributes
of an identifier
7 syme TABLE MANAGES
TMB! Sha Rata artes Ren Coma
Error HANDLER
Lexical analyzer checks if the tokens are valid oY NOt
{ eg: bSsum = not valid identifier Ctoken) - erroy_ is generated.
+] TE the token id ' not a valid, then that will be
jsplayed__Q an _erroy, by the levical analyze
Syntax__analyzer_ _4 semantic analyze finde most of
the error.
Syntax error: by —ayntaxr analyzer. eg: G2 b+.
amantic _enov: Mis type comeatibilitty redeclaration
of Ott Qio\s
2a: int a manitcaly -incorveck) ys es
Float a,y
15-01-2025
bh EX IcAL_ANALY:
F go _Coletlp cieMy Fal [o
LE : pe
| Keywords- for to th - blank ee)
L Identiiev- | \
L Corerants ~ 1, 10
Operators - = Cassignment operator).
Jrxed quantities - keywords, Opetators
— | eo: Tiel (rms) em) oro) Tao)
Keqwords- if, then, Goro
Operators tc)
Constants - 5, 100
Identifier - MAX.
2.28 _lidentifien integr value= max
2.96 nctants intege, Value= 5
312 | label, integer, value =100
The varying things are
iy constant- 5
Gi) idlentifier - Max
Gi)_labet_- 100
Rest ali have Siaed [Link] the language «
Ansteod of the varying valve deplace them with a
pai of wera
Chto rureneat
va areal) :
The fixed thinos are actually _reolaced by some fixed
Value.
Short note on lexical analyzer. Curie four {ne + €9)-
a
lnlaye how syntax analyzer camemunicate with Jexica\ aoalirer:
i The Separated tokens até stowed into 9 Separate: File, the
yntax Analysey ewill tne the necessary token from the.
file =
iiieaee oO
vi The syntax _analysey _“calistnthe lexical Analyser
foy the vequired token.
The 9° way is more optimal
Role Of Lexical Analugey in Compiler —
“Source texteal | oI
SYNTAK COemorsirate Lhe
Par anagee = yd anaer | and
) 24d neinod of
gener 7
boren coremunicote)
[samen |
[Teas [
Fiq- Interaction of Lereal analuzey ard suntgs. Analyzer
Parserhela
eS |
= 0)
|| Why we are gplitting the compiler into differen, phases ?
Y
A arate
he reasons why ue have _sep lexical Oh alyey
Symar analyzer > ~
1. Simpler design of complley . 4
Q- Compiler efPicrency |S improved -
= Lexical analyzer _Is
: ——
Quorking charactey- by —
; 2 WL chawetey
making it a slower process »
> Different
phases _facilite change _in each proces —~]
individually .
“Lexeme, TokeN _¢_ PATTERN
@:|| Distinguish bit lezeme, token & pattern: |
. || Leteme: Lowest unit of a program statement »
eo: for i= | to 10
Here for jt
Fy, i te 10 are lexemes
Token: Categories of the lexeme -
eg: Heve i ie Wdenttier -
Potten: Rules:
The __ lowest _eyntactic.
Unit Of a'language “!S called lente
The category to which the lexeme belongs is calied toe
The _yule ser)
to define a lexerme fe called patter:
2a.
Lexeme Token Pattern
sum identitier letter followed &4 fetter {dip
Sa
< (alata opm <, ee Sego-0'" 2025
, IMPLEMENTATION OF LEXICAL ANALYZER = —
5 1. By using Lex toot Ctool available in Linux wt_envitonmantlil
g 2 Py using Conventional System. Programming hanguages _—
2 » eg. C language . . . =
$3. By using Assembly Language. - as
|
=
of?
difficultly in implementation.
tare the,
1
gee | Se ‘tool,
BES | | Ba. conventional system _Reeqraenmaing.. Lanaget :
48 L 3| > y2_Assernoly Longuoge —
ee | ee oe —
PS tee eney to conve assembly_ fanouage: foot
3 | _mochine language
A =
+ Drawback_ of Lexical Analyzer
-4—-|_ “the scanning here _ (s—ehamcter = by- charactey junit
2 6. lowe - 7
The main _drawinek js ___ite__slow_epeed_.
Vl Burren PAIRS — a is
+|| The method _to _‘inereageg the peed of Lerical
Analyzer — = :
Th epee” ig separated into two _halver
- | veing ystem read .we tead N chavacters 40 €ach block
7 Vv 7 aa
Neharactets__N chatkers . : oe
toa or HOT 1024 oy 40% -
Carte OF eee — -_
Each bffer me _N characters each, N 6 the emur< _
lengua of soken eSetback spa} ——
7, ig __moved_character~ oy -ch
1 2 Crule) + Otakkey
until op fi k_Spaca is te,
| Rf ter first hale, then read the next Ni characte
__Then__both the “painters move _to
and continue
Nehoracers >
abom AD
t 7
11+
Both the pointers are moved
N characters
29h,
next characig” ‘Zed
rr
once a pattern Crue) ©
Identifred - Move forward Pointer alone until: we
find a fat
«
- After the buffer finishes, reload fitgk block ‘and
t Yepeot until we find the EOF
1
PSEUDOCOCE in ADVANCE ForWlARD Poster
rif Grusotd at the end of firat half then
HT aes
{ begin
I Teload the Serand halt -
| formord= forward + |
} | end
| Lege
| if fowuarl at Bd _of econd half, then
begun
Felons :
Move forward in the beginning of fick hat
end !
else
forward = forward |
try
«Here 9 checking ig requved
foy forward pointe
yt ONclassmate.
Date
Page
lo-___next character
2 Geetumies : —
To avoid _two_checking_,
| Here, we use _' eof" chatter foy first half, second
halt_¢ the nartural___e0€ -
+|| Cof .sentinel character.
eok| eof ok _ _
end of bieck | ent of beck Nd Of actual Ale.
actual file block 2
PseuDocone
foavard = forward + \
cif fonuad = eof then
begin
cif foqward at end ce fice hale then
begia -
Yetaad econd halt = =
forward = forwaret —
— end
el if forward at end of cecand hal€ ther
rhegin
reload first talf
move forward 40 beginning of fet hale
end =
else
terminate Vewical analysts.
: i Fig. Look - ahead code with sentinel.
| Here only 4 heckiing req uirect
|
|
t - os
I
Hta hss ‘
Date
Pe SS C
1 al i coe ta—o—pa— ob tet —inalandl og" a
HES ord painter doe not _Feccgnize i,
a ha it token and reached {he end OF the
~——~— buffer, then__the buffer _gete _teload Wit the
y New __N choraciere thus dhe previou Undone
a 7 characters get ie
7 {Whereas in lair of buffers, th. etka tema
phan —le —tlade—nne fist pats
dent
i nt
i dent - ety]
Les le
: i
E. ! Regulay expression /Requiay Grammar. —th
= Operations Definition
. -N-Kisena closure :of t- umitten Le, Me Gb
| Positive closure of Lb writen 1 +. eee
|
Regular_Eapreasion for_an identifioy :
Id —> fetter (Letter [diait)* ae
e Adenitier con be O .simle tether Oy grow of fetter ”
bu letter (diqrer» Recognition of Tokens : —
mg oe ay a
4 3 lagrams can, “he. Use _ fo reegnize
la token: a __s
+ || Wansition diagram ig a Spectatized flowchart to _
a { fecognize a token & lextcal analyzer - a
| Circle -states
_— | _ Batrour aris - edges. _ = =
|| eg: Transition diograrn fox” "igenvifier : _
oo [Link] =
) : oe
i stork letter delimiter
: WT © 7 :
|| Tokeng Ore separated bu _delirmtevs .
| eg: Sum @ i: _ ee
#4
trait
To__retract / backtrack one osition back to avoid the
|_delimiter from the token. Jor that _# is _used-
Explain the code for eram —
StareO. 40 get ine fice character fram the i/P string
C= GieTcuARC) : —
i€__etrercc) en goto state |
else EAL epee pork a oe
Store
C= GEICHAR() = oe
if _Letter(c) Ov Bimir(c) then gote State |
isa_1€ _peimiuter(¢) then gota etake 2
els FAILC) —
| Store 3 — : = _——
{| RETRACT C) [FEO LEEEE EE BORED TS UN aunt o
{| = yeu C id, WS I Tart ))
Gio ator, CHE
I Specifies that f 3 in
i na this well rete
1 5 an wernt eT the tcKEN in symbol c@ Kdnat ig a tex pool? Explain with an ercarnpte
+) Lewcal analyzer _¢0n be_easily !Mplementeg b -— >
ex tool Sing
+ Lex _pregtam marily _caneict of bree |
ROVE
declarations —
\. Fedeclaratiog
Declaraon: oF _identFlets Or constants dr regu
a
2: Translationle Rules:
Pr faction 13
Po faction 27
| Pi § action i}
Pir Par-----~; — are she regular ex pr&svons .
si they Specy *he action to be executed When the corespet
| requior escpresions Ave specified »
|The actions are written in C language,
S| Autiliany procedures:
Suppor procedures written in ce language. ——
sf Tuo stages of compilation are required OS
ome dre lex Code athe are C code. ci
Fist give to tex too then ¢_pBogram _% ove
dnen give it 40 Ccom@lley.
\ |Fea
- = hex rear | tesy-e
{ lexaye |, a
Out
COMPILER.
esters oo uk —}Seauesee of tokens
92-01-2025
EXAMPLE
Lf 1 ]
int couNt!, count2, count 3, Counth ; t. declararion of
Variables
aa cecara
Raa 7 trore
Op AT a"
“num fo-alt
said [a-z a-z] [a-za-z 0-4]*
= declaration OF
reauior _definiions
sitet Keg int” | “char"| rif” | “ese” | “while
Siceyh fecuntiss j }
= translation Coles
2
id, feount 2141 4
[
[
2
ya 1
|
[
F auent { count3++j 7
t t J
flop} fcountus+; 2S
a ae :
(tnt main)
Avia \an}
Cs
Procedu
pvint (“4d %d_ %d Zd \n", counts, count 2, counts, county)
Yeturn_O» Q
4
yylerd) = lex £9 bo eparate. tne jokens.
Recognize the 4oken- go to_reqular expresston part if ang match:| dake a6 _foken
|
| Coons the_nmof teken§
= | —
€q: a
: a ae =
. Counta: 3 >
: Count 320 i _
count = 2 - ]