At which phase of the compilation are keywords of a programming language recognized?
I am sort of confused between
I once wrote a lexer in C using regular expressions but it recognised the main()
in int main(void)
also as a keyword.
On these lines I think that we have to build a parse tree to recognize keywords.
I had to build a simple compiler this year as a project for which i used Java . The recognition of keywords was made on lexical analysis. During that phase i would read input language and create a token with a type(for keywords type was variable_declaration ) and its value.I also had different types for each case like identifier , constant,multiply operation ,adding operation etc.Then passed these tokens to a queue and next into a parser which would check grammar and create a binary tree which was then used to create the output language .