Ans:
1)
What is the Lexical Analysis?
Lexical Analysis is the notably initial phase in the compiler
conception. A Lexer uses the transformed source code which is
formulated in the structure of sentences. In other words, it
assists you to switch a series of letters into a series of tokens.
The lexical analyzer separates this syntax into a sequence of
tokens. It eliminates additional space or comments recorded in the
source code.
Applications that implement lexical analysis are termed as
lexical analyzers or lexers. A lexer holds a tokenizer or scanner.
If the lexical analyzer recognizes that the token is wrong, it
produces an error. It holds character streams from the source code,
analyses for proper tokens, and transfer the data to the syntax
analyzer when it requires.
Lexical Problems:
A character series that is not likely to scan into any actual
token is a lexical error. Significant points concerning the lexical
error:
- Lexical errors are not quite simple, however, it should do
controlled by a scanner
- Misspelling of identifiers, operators, keyword are recognized
as lexical errors
- Usually, a lexical error is produced by the presence of any
unauthorized character, essentially at the origin of a token.
Error Recovery in Lexical Analyzer
Here, are several traditional error improvement techniques:
- Removes one number from the unused input
- In the crash mode, the serial characters are continuously
neglected until we arrive a well-formed token
- By including the absent character into the unused input
- Return a character with a different character
- Transfer two successive characters
2)
compiler construction techniques used to solve the
problem
The compiler editor can use amazing functional gadgets that help
in performing different phases of a compiler. These techniques help
in the production of a whole compiler or its components. Some
usually used compiler construction techniques involve:
- Parser Generator –
It provides syntax analyzers (parsers) from the input that is based
on a grammatical representation of HL language or on a context-free
grammar. It is beneficial as the syntax analysis phase is extremely
complicated and uses more guidebooks and compilation time.
Example: PIC etc.
- Scanner Generator –
It creates lexical analyzers from the input that contains regular
expression information based on tokens of a language. It creates a
finite automaton to acknowledge the RE.
Example: Lex.
- Syntax directed translation engines –
It produces standard code with three address form from the input
that consists of a parse tree. These engines have routines to cross
the parse tree and then give the intermediate code. In this, each
node of the parse tree is affiliated with one or more
translations.
- Automatic code generators –
It makes the machine language for a target machine. Each
performance of the intermediate language is changed using a set of
commands and then is used as an input by the code generator. A
template matching process is used. An intermediate language
statement is displaced by its comparable machine language using
templates.
- Data-flow investigation engines –
It is practiced in code optimization. Data flow analysis is a
fundamental frame of the code optimization that collects the data,
that is the values that flow from one section of code to
different.
- Compiler construction toolkits –
It gives an integrated set of methods that aids in creating
compiler parts or in the development of different phases of a
compiler.
3)
How to solve the problem using the compiling
techniques-
- Assists to recognize token into the symbol table
- Eliminates white spaces and comments from the source code
- Correlates error messages with the source code
- Encourages you to increases the macros if it is located in the
source code
- Scan input characters from the source code
Benefits of Lexical analysis-
- The lexical analyzer process is used by programs like compilers
which can manage the parsed data from a developer's code to
generate a compiled binary executable code
- It is managed by web browsers to format and present a web page
with the guidance of parsed data from JavsScript, HTML, CSS
- An isolated lexical analyzer assists you to create a functional
and probably more effective processor for the task
please do not forget to give a thumbs
up!!
Have a nice
day.