I am planning to design a Lexical Analyzer for C language for a project.
how difficult is it?
how difficult is it to design it 'in' C itself?
what are the things that I need to know?
I am planning to design a Lexical Analyzer for C language for a project.
how difficult is it?
how difficult is it to design it 'in' C itself?
what are the things that I need to know?
A complete lexical analyzer for C is a fair sized project. You'd get a lot of it done in the first few weeks, but then you'd be spending a lot of time covering strange corner cases and weird things.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Are there any libraries in C for building lexical analyzers/scanners?
There is Yacc and Flex, which are programs to generate C code for lexical analysis. I'm sure there are open source projects that understand C as well, but I'm not aware of any [I have never written a lexical analyzer for C, I did work with a company that had a "data structure analyzer" and even that was quite a beast].
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I wrote a scanner for Pascal in literally less than an hour. Then it took about 2-3 more hours the next day to work out minor bugs and misinterpreted specifications. Now I'm not sure how much more complex C is than Pascal (it doesn't seem too much more complex), but I'd be surprised if it took you over a week. Scanners really aren't too complicated.
It's the parsing / code generation that's going to take a while (if that's where you're headed). The Pascal parser I worked on took well over a month to finish (compared to the couple hours for the scanner). Code generation added another couple weeks. And I'm not talking casually working weeks, some weeks I spent almost 10 hours a day on this project.