Why yacc and lex are separated from each other?
I mean that why c programers do not design them together?
for example , can we make lex-yacc tool together?
Why yacc and lex are separated from each other?
I mean that why c programers do not design them together?
for example , can we make lex-yacc tool together?
Copyright © 2021 Jogjafile Inc.
They are separated because they can be also useful when used separately. Their maintainers don't want to limit them by merging it into one tool.
For example, I have once used Lex to write a function that un-escapes a string. It didn't deal with any kind of structured data and didn't require a parser to go with it.
When it comes to Yacc, it doesn't really need Lex. It can take any function that returns
int. There are languages where it is very easy to find the tokens and you don't need the whole complicated state machine the Lex creates. Or you may want to parse some data source that isn't a text in the first place. (For example the tokens are generated by some algorithm.)Another reason is that the two programs were developed independently, by different authors, at different time. I think that Lex based its syntax on Yacc which was already more or less finished at that point. Later it became an establish industry standard that they are used together, and their developers are trying to keep their syntax somewhat similar. However, creating one unified tool would bring a whole mess of copyright and ownership issues.
And there is of course the question of backward compatibility problems if someone would try to change anything at this point.