Difference between lexical and syntax analysis
Answers
Answered by
10
Lexical analyser divides the input into valid tokens i.e smaller entities which make sense and are well defined in the language:
For example - "beautiful" is a valid token as it is a valid word in English.
Whereas "dsefuewfiu" is not a valid token as it does not make any sense.
Whereas Parser checks for the grammar i.e the sentence adheres to the laws of sentence formation in English:
For example- "My name is Rahul" is a valid English sentence.
Whereas "name my is Rahul" makes no sense.
This is the basic difference between a lexical analyzer and parser
For example - "beautiful" is a valid token as it is a valid word in English.
Whereas "dsefuewfiu" is not a valid token as it does not make any sense.
Whereas Parser checks for the grammar i.e the sentence adheres to the laws of sentence formation in English:
For example- "My name is Rahul" is a valid English sentence.
Whereas "name my is Rahul" makes no sense.
This is the basic difference between a lexical analyzer and parser
Answered by
2
Lexical analysis is the first phase of a compiler. It takes the modified source code from language pre processors that are written in the form of sentences.
A syntax analyzer or parser takes the input from a lexical analyzer in the form of token streams.
A syntax analyzer or parser takes the input from a lexical analyzer in the form of token streams.
Similar questions
Social Sciences,
8 months ago
Physics,
8 months ago
Biology,
8 months ago
Physics,
1 year ago
English,
1 year ago