| 1 | %{ |
|---|
| 2 | #include <stdio.h> |
|---|
| 3 | #include <locale.h> |
|---|
| 4 | #include "tok_cmdline.h" |
|---|
| 5 | |
|---|
| 6 | int filepos=0; |
|---|
| 7 | |
|---|
| 8 | struct gengetopt_args_info args; |
|---|
| 9 | |
|---|
| 10 | %} |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | %% |
|---|
| 14 | |
|---|
| 15 | [a-zA-Z±æê³ñó¶¿Œ¡ÆÊ£ÑÓŠ¯¬]{1,64} { |
|---|
| 16 | printf("%04d %02d W %s\n", filepos, yyleng, yytext); |
|---|
| 17 | filepos+=yyleng; |
|---|
| 18 | if(args.interactive_flag) fflush(stdout); |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | [[:digit:]]{1,64} { |
|---|
| 22 | printf("%04d %02d N %s\n", filepos, yyleng, yytext); |
|---|
| 23 | filepos+=yyleng; |
|---|
| 24 | if(args.interactive_flag) fflush(stdout); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | [[:space:]\n]{1,64} { |
|---|
| 28 | int i; |
|---|
| 29 | printf("%04d %02d S ", filepos, yyleng); |
|---|
| 30 | for(i=0; i<yyleng; ++i) |
|---|
| 31 | switch(yytext[i]) |
|---|
| 32 | { |
|---|
| 33 | case ' ' : putchar('_'); break; |
|---|
| 34 | case '\t': printf("\\t"); break; |
|---|
| 35 | case '\n': printf("\\n"); break; |
|---|
| 36 | case '\r': printf("\\t"); break; |
|---|
| 37 | case '\f': printf("\\n"); break; |
|---|
| 38 | } |
|---|
| 39 | putchar('\n'); |
|---|
| 40 | filepos+=yyleng; |
|---|
| 41 | if(args.interactive_flag) fflush(stdout); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | [[:punct:]] { |
|---|
| 45 | printf("%04d %02d P %c\n", filepos, yyleng, *yytext); |
|---|
| 46 | filepos+=yyleng; |
|---|
| 47 | if(args.interactive_flag) fflush(stdout); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | . { |
|---|
| 51 | printf("%04d %02d B \\x%02X\n", filepos, yyleng, (unsigned char)*yytext); |
|---|
| 52 | filepos+=yyleng; |
|---|
| 53 | if(args.interactive_flag) fflush(stdout); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | %% |
|---|
| 57 | |
|---|
| 58 | int main(int argc, char** argv) |
|---|
| 59 | { |
|---|
| 60 | if (cmdline_parser(argc, argv, &args) != 0) return 1; |
|---|
| 61 | setlocale(LC_CTYPE,""); |
|---|
| 62 | setlocale(LC_COLLATE,""); |
|---|
| 63 | yylex(); |
|---|
| 64 | return 0; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | int yywrap() |
|---|
| 68 | { |
|---|
| 69 | return 1; |
|---|
| 70 | } |
|---|
| 71 | |
|---|