Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Various parts of speech in C language are described by regular expressions, and the lexical analyzer in C language is realized by LEX tools. Please answer the relevant thinking questions in detail: th
Various parts of speech in C language are described by regular expressions, and the lexical analyzer in C language is realized by LEX tools. Please answer the relevant thinking questions in detail: th
Various parts of speech in C language are described by regular expressions, and the lexical analyzer in C language is realized by LEX tools. Please answer the relevant thinking questions in detail: the more detailed the better. 1. The input is a code file and the output is a token. These outputs are then used by grammars (yacc, bison, etc.). ).

2. To prepare, you can look at the third chapter of "C Expert Programming": Analysis of C language statements. This example is the simplest lexical+parser, which is enough to give you some hints. Of course, this is not enough. You may want to find a standard C language.

3. Classification is nothing more than modifiers, types, keywords, identifiers, operators and so on.

4. On the basis of 2. It is not difficult to solve.

5. This is very simple. Even the direct file processing has been solved. I vaguely remember that Lex might be easier to do.

Generally speaking, it may be difficult to do it yourself, so using lex should save a lot of trouble.

=========================================================================

The above is just an impression, I hope it will help you. Wait and see if Daniel can help you finish it. Or we can study it together when I'm free.