3. Compiler Construction Tools
• Compiler construction tools were introduced after
widespread of computers.
• Also known as compiler-compilers, compiler-
generators or translator writing systems.
• These tools may use sophisticated algo or
specified languages for specifying & implementing
the component.
4. Compiler Construction Tools
• Scanner Generators: These generate lexical
analyzers.
• The basic lexical analyzer is produced by Finite
Automata, which takes input in form of regular
expressions.
• Ex: LEX for Unix O.S.
5. Compiler Construction Tools
• The meta-language to a scanner generator
consists of regular expressions.
• These regular expressions describe tokens that
the generated scanner will then be able to find
when a source program is input.
• Ex: gr[ae]y does not match graay, greey or any
such thing.
6. Compiler Construction Tools
• Here, identifiers consist of letters
and digits and begin with a letter;
• Literals are sequences of digits;
• Arithmetic operators are addition,
subtraction, multiplication, division
and assignment operators;
• Punctuation symbols are ";" and left
and right parentheses.
7. Compiler Construction Tools
• Two Important Aspects of Scanner are:
– what are the tokens of the language?
– recognition of tokens
• Finite-state acceptors are devices that are well
suited to this recognition task primarily because
they can be specified pictorially by using
transition diagrams.
8. Compiler Construction Tools
• Parser interacts with Scanner in any of 2 ways:
– The scanner may process the source program in a
separate pass before parsing begins. Thus the tokens are
stored in a file or large table.
– The scanner is called by the parser whenever the next
token in the source program is required.
• The 2nd approach is preferred as internal form of the
complete source program does not need to be constructed
and stored in memory before parsing can begin.
9. Compiler Construction Tools
• Parser Generators: These
software produce syntax analyzers
which takes input based on
context-free grammar.
• Earlier, used to be most difficult to
develop but now, easier to develop
& implement.
• Ex: YACC, AXE, Bison, etc.
10. Compiler Construction Tools
• A parser generator is an application which
generates a parser.
• The usual input is a formal specification of the
grammar the parser has to recognize.
• Plus code implementing the actions the parser has
to take when recognizing the various parts of its
input.
• The result is an implementation of the parser in
some language, often C.
12. Compiler Construction Tools
• Syntax-directed Translation Engines: These s/w
products produce intermediate code with the help
of parse tree.
• Main idea is associating 1 or more translations
with each node of parse tree.
• Each node is defined in terms of translations at its
neighboring nodes in the tree.
13. Compiler Construction Tools
• Every non-terminal can get one or more than one
attribute or sometimes 0 attribute depending on the
type of the attribute.
• The value of these attributes is evaluated by the
semantic rules associated with the production rule.
• In the semantic rule, attribute is VAL and an
attribute may hold anything like a string, a number,
a memory location and a complex record
14. Compiler Construction Tools
Whenever a construct
encounters in the
programming language,
then it is translated
according to the semantic
rules define in that
particular programming
language.
17. Compiler Construction Tools
• Data Flow Engines: It is a tool used for code
optimization.
• Info is supplied by user & intermediate code is
compared to analyze the relation.
• It also does data-flow analysis i.e. finding out how
values are transmitted from one part to another
part of the program.
19. Compiler Construction Tools
• Automatic Code Generator: This software
basically take intermediate code as input &
produce machine language as output.
• It is capable of fetching data from various storage
locations like registers, static memory, stack, etc.
• Basic technique here is ‘template matching’.
20. Compiler Construction Tools
• Automatic code generation has certain
advantages over traditional coding.
– High Quality
– Consistent
– Productive
– Coding Abstractly
21. Compiler Construction Tools
It is of two types:
• Passive- Passive code generators creates code,
then has nothing more to do with the project.
• Active- Active code generators create code then
keep track of that code during its lifecycle.
22. CONTACT ME AT:
Akhil Kaushik
akhilkaushik05@gmail.com
9416910303
CONTACT ME AT:
Akhil Kaushik
akhilkaushik05@gmail.com
9416910303
Thank You !!!