- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello friends
I want to know what is the diference between Lexical Analyzer And Syntax Analyzer.
I know that these are the different components of a compiler. But i dont know their functions and difference.Please help.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
http://en.wikipedia.org/wiki/Lexicon
In the statement
int x = p->value();
"int", "x", "=" and "p", "->", "value", "()" and ";" are lexical symbols (discrete atoms of the language that have specific meanings).
The lexical analyzer determines the meaning of each component of the expression:
int :- typename (base type);
x :- user variable name;
= :- operator (assignment);
p :- pointer;
-> : operator (dereference);
value : member name;
() : operator (call)
The syntactical analyzer tries to make sense from that as to what you are doing, in the abstract:
declare user variable;
dereference pointer;
dereference member function;
call resulting address;
assign return value to user variable
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
http://en.wikipedia.org/wiki/Lexicon
In the statement
int x = p->value();
"int", "x", "=" and "p", "->", "value", "()" and ";" are lexical symbols (discrete atoms of the language that have specific meanings).
The lexical analyzer determines the meaning of each component of the expression:
int :- typename (base type);
x :- user variable name;
= :- operator (assignment);
p :- pointer;
-> : operator (dereference);
value : member name;
() : operator (call)
The syntactical analyzer tries to make sense from that as to what you are doing, in the abstract:
declare user variable;
dereference pointer;
dereference member function;
call resulting address;
assign return value to user variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The lexical analyzer breaks the incoming charater stream into tokes (languages keywords and idetifiers).
The Syntax analyzer recognizes the incommingtokens and attaches the meaning. If the tokens do not follow language syntax then it emits the error massage.
You may learn more on this topic from any compiler design text book.
There is popular lexical analyser called lex and populartool yacc used for building sytax analysers.
The Syntax analyzer recognizes the incommingtokens and attaches the meaning. If the tokens do not follow language syntax then it emits the error massage.
You may learn more on this topic from any compiler design text book.
There is popular lexical analyser called lex and populartool yacc used for building sytax analysers.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page