Why Split Lexing and Parsing Into Two Separate Phases?

from blog Laurence Tratt: Blog, | ↗ original
“lex and yacc” are two terms that are used together so often that they can seem indivisible. “lex and yacc” are two terms that are used together so often that they can seem indivisible. lexlex takes a string as input and divides it up into lexemes (roughly speaking “words”) and takes a string as input and divides it up into lexemes (roughly speaking “words”) and yaccyacc takes a sequence of lexemes and parses them. Since some parsing approaches such as recursive descent parsing unify these phases, why do takes a sequence of lexemes and parses them. Since some parsing approaches such as recursive descent parsing unify these phases, why do lexlex and and yaccyacc split them apart? split them apart? Running exampleRunning example Let’s start with a simple language, which...Let’s start with a simple language, which...