13. Program Construction Flashcards
What happens in lexical analysis
When a compiler receives source code, it parses it and decides whether each line contains keywords, variables, constants or anything else accepted by the language. It converts the source code into a token stream and comments/whitespaces are removed.
What happens in syntax analysis?
Once tokens have been assigned to the code elements, the compiler checks that the tokens are in correct order and they follow the rules of the programming language, if they don’t a syntax error appears.
What is semantic analysis?
Semantic analysis tries to imply meaning to the code that has been read in during syntax analysis. One of the most important elements of semantic analysis to determine type checks and any inconsistencies that may occur.