The main difference between lexical analysis and syntax analysis is that lexical analysis reads the source code one character at a time and converts it into meaningful lexemes (tokens) whereas syntax analysis takes those tokens and produce a parse tree as an output.