compiler construction - What is the purpose of a lexer? -
i reading answer this question. can't seem find answer why need lexer separately
is 1 of steps program goes through during compilation? can please explain in simple terms why need lexer, , purpose serve?
a lexer take input character stream , convert tokens.
this can used variety of purposes. apply transformations lexemes simple text processing , manipulation.
or stream of lexemes can fed parser convert parser tree.
if goal compilation, lexical analysis first step. think of lower level step takes characters , converts them tokens. parser higher level mechanism alphabet consists of tokens (created lexer), parses , creates parse tree.
if goal text manipulation, manipulation rules can applied lexemes themselves.
Comments
Post a Comment