syntax analyzer presentation

15
7/26/2019 Syntax Analyzer Presentation http://slidepdf.com/reader/full/syntax-analyzer-presentation 1/15  A PROJECT PRESENTATION ON BY

Upload: yogie-luthfie-adinegara

Post on 02-Mar-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 1/15

 

A

PROJECT PRESENTATION

ON

BY

Page 2: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 2/15

 

WHAT IS A

COMPILER? A Compiler is a SYSTEM Software to

convert Higher level code to Machine level

code without changing the purpose of theHLL code

Page 3: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 3/15

 

!EE" #$ A

COMPILER A Compiler allows a %rogrammer to write a

program in HLL irrespective of the underl&ing

Hardware configuration

Page 4: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 4/15

 

#'(ECTI)E #$ THE

PROJECT A Compiler allows a %rogrammer to write a

program in HLL irrespective of the underl&ing

Hardware configuration

Page 5: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 5/15

 

Page 6: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 6/15

 

Lexical Analysis or Linear Analysis or

Scanning, in which the stream

of characters making up the source program

is read from left-to-right andgrouped in to tokens, sequence of characters

having a collective meaning. The

lanks separating the characters of the

tokens and the comments statementsappearing within the program would e

eliminated during lexical analysis.

Page 7: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 7/15

 

Syntax Analysis or !ierarchical Analysis, in

which characters or tokens are grouped

hierarchically into nested collections with

collective meaning. !ierarchical analysis alsotermed as "arsing, involves grouping the

tokens of the source program into

grammatical phrases that are used y the

compiler to synthesi#e output. $sually, thegrammatical phrases of the source program

are represented y a "arse tree.

Page 8: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 8/15

 

Semantic Analysis, in which certain checks

are performed to ensure that the components

of a program fit together meaningfully. The

semantic analysis phase checks the sourceprogram for semantic errors and gathers type

information for the susequent code-

generation phase. %t uses hierarchical

structure determined y the syntax-analysisphase to identify the operators and operands

of expressions and statements.

Page 9: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 9/15

 

After the syntax and semantic analysis, some

compilers generate as explicit intermediate

representation of the source program. &e can

think of this intermediate representation as aprogram for an astract machine. This

intermediate representation should have two

important properties' it should e easy to

produce and easy to translate into the target

program.

Page 10: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 10/15

 

The code optimi#ation phase attempts to

improve intermediate code, so that faster-

running machine code will result. There is a

great variation in the amount of code

optimi#ation different compilers perform. %nthose that do the most, called (optimi#ing

compilers,) a significant amount of the time

of the compiler is spent on this phase.

!owever, there are simple optimi#ations thatsignificantly improve the running time of the

target program without slowing down

compilation too much.

Page 11: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 11/15

 

The final phase of the compiler is the

generation of target code, consisting

normally relocatale machine code or

assemly code. *emory locations areselected for each of the variales used y the

program. Then, intermediate instructions are

each translated into a sequence of machine

instructions that perform the same task. Acrucial aspect is the assignment of variales

to registers.

Page 12: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 12/15

 

A symol tale is a data structure containing arecord for each identifier, with fields for the

attriutes of the identifier. The data structure allows

us to find the record for each identifier quickly and to

store or retrieve data from that record quickly.The attriutes may provide information aout the

storage allocated for an identifier +if applicale, its

type, its scope and in the case of procedure names,

such things as the numer and types of arguments,

the method of passing each argument and the type of

return value if the functions returns any value.

Page 13: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 13/15

 

ach phase can encounter errors. !owever, after

detecting an error, a phase must somehow deal with thaterror, so that compilation can proceed, allowing further

errors in the source program to e detected. A compiler

that stops when it finds error is not as helpful as it could

e.

The syntax and semantic analysis phases usuallyhandle a large fraction of the errors detectale y the

compiler. The lexical phase can detect errors where the

characters remaining in the input do not form any token of

the language. rrors where the token stream violates the

structure rules +syntax of the language are determinedy the syntax analysis phase. uring semantic analysis

the compiler tries to detect constructs then have the right

syntactic structure ut no meaning to the operation

involved.

Page 14: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 14/15

 

The compiler designed y us has the

following limitations

/loating point, arrays, structures,

pointers,enumerators and function definition are

not supported.

The auto, constant, volatile andregister keywords are ignored.

Strong type checking is not supported.

Page 15: Syntax Analyzer Presentation

7/26/2019 Syntax Analyzer Presentation

http://slidepdf.com/reader/full/syntax-analyzer-presentation 15/15