compiler construction - When does the lexical analyzer returns the token to the parser? -


i have studied parser calls lexical analyzer , lexical analyzer returns token happen @ once or concurrently lexical analyzer reads lexemes , returns token parser.

we lexer returns parser token lexer stores in symbol table parser gets token symbol table ,but how refer it?

you seem misunderstanding symbol table is. lexer transfers stream of bytes stream of lexemes , not handle symbol table @ (except when parsing c language, information symbol table handled parser fed lexer in lexer hack: http://en.wikipedia.org/wiki/the_lexer_hack). handling symbol table job of parser.

in practice, lexer may consist of function returns lexical token. so, if lexer implemented in way, token passed parser return value lexer function.

you should try using lex/yacc (or flex/bison). implementing parser of own , seeing kind of code tools generate make understand how lexer , parser working together. i'm sure there plenty of tutorials lex/yacc on internet.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -