3 /* Lexical scanner for command line parsing in the Wine debugger
18 #define YY_INPUT(buf,result,max_size) \
19 if ( (result = dbg_read((char *) buf, max_size )) < 0 ) \
20 YY_FATAL_ERROR( "read() in flex scanner failed" );
23 extern char * readline(char *);
24 static char * make_symbol(char *);
26 static int syntax_error;
33 IDENTIFIER [_a-zA-Z\.~][_a-zA-Z0-9\.~]*
37 \n { syntax_error = 0; return '\n'; } /* Indicate end of command */
56 sscanf(yytext, "%lx", &yylval);
61 sscanf(yytext, "%ld", &yylval);
65 $pc { yylval = RN_EIP; return REG;}
66 $sp { yylval = RN_ESP; return REG;}
67 $eip { yylval = RN_EIP; return REG;}
68 $esp { yylval = RN_ESP; return REG;}
69 $ebp { yylval = RN_EBP; return REG;}
70 $eax { yylval = RN_EAX; return REG;}
71 $ebx { yylval = RN_EBX; return REG;}
72 $ecx { yylval = RN_ECX; return REG;}
73 $edx { yylval = RN_EDX; return REG;}
74 $esi { yylval = RN_ESI; return REG;}
75 $edi { yylval = RN_EDI; return REG;}
77 $es { yylval = RN_ES; return REG;}
78 $ds { yylval = RN_DS; return REG;}
79 $cs { yylval = RN_CS; return REG;}
80 $ss { yylval = RN_SS; return REG;}
82 info|inf|in { return INFO; }
84 break|brea|bre { return BREAK; }
85 enable|enabl|enab|ena { return ENABLE;}
86 disable|disabl|disab|disa|dis { return DISABLE; }
88 quit|qui|qu { return QUIT; }
90 help|hel|he { return HELP; }
92 set|se { return SET; }
94 bt { return BACKTRACE; }
96 cont|con|co { return CONT; }
98 symbolfile|symbolfil|symbolfi|symbolf|symbol|symbo|symb { return SYMBOLFILE; }
100 define|defin|defi|def|de { return DEFINE; }
101 abort|abor|abo { return ABORT; }
102 print|prin|pri|pr { return PRINT; }
104 mode { return MODE; }
106 regs|reg|re { return REGS; }
108 stack|stac|sta|st { return STACK; }
120 {IDENTIFIER} {yylval = (int) make_symbol(yytext);
124 [ \t]+ /* Eat up whitespace */
126 . { if(syntax_error == 0) {
127 syntax_error ++; fprintf(stderr, "Syntax Error\n"); }
133 int yywrap(void) { return 1; }
138 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
142 /* Used only with GNU readline */
143 #include "readline/readline.h"
144 #include "readline/chardefs.h"
147 dbg_read(char * buf, int size){
153 line = readline ("Wine-dbg>");
162 /* Remove leading and trailing whitespace from the line.
163 Then, if there is anything left, add it to the history list
171 fprintf(stderr,"Fatal readline goof.\n");
185 /* Strip whitespace from the start and end of STRING. */
191 while (whitespace (string[i]))
195 strcpy (string, string + i);
197 i = strlen (string) - 1;
199 while (i > 0 && whitespace (string[i]))
205 static char *local_symbols[10];
206 static int next_symbol;
208 char * make_symbol(char * symbol){
209 return local_symbols[next_symbol++] = strdup(symbol);
214 while(--next_symbol>= 0) free(local_symbols[next_symbol]);