1 /* Lexical scanner for command line parsing in the Wine debugger
16 #define YY_INPUT(buf,result,max_size) \
17 if ( (result = dbg_read((char *) buf, max_size )) < 0 ) \
18 YY_FATAL_ERROR( "read() in flex scanner failed" );
21 extern char * readline(char *);
22 static char * make_symbol(char *);
24 static int syntax_error;
31 IDENTIFIER [_a-zA-Z\.~][_a-zA-Z0-9\.~]*
35 \n { syntax_error = 0; return '\n'; } /* Indicate end of command */
54 sscanf(yytext, "%x", &yylval);
59 sscanf(yytext, "%d", &yylval);
63 $pc { yylval = RN_EIP; return REG;}
64 $sp { yylval = RN_ESP_AT_SIGNAL; return REG;}
65 $eip { yylval = RN_EIP; return REG;}
66 $esp { yylval = RN_ESP_AT_SIGNAL; return REG;}
67 $ebp { yylval = RN_EBP; return REG;}
68 $eax { yylval = RN_EAX; return REG;}
69 $ebx { yylval = RN_EBX; return REG;}
70 $ecx { yylval = RN_ECX; return REG;}
71 $edx { yylval = RN_EDX; return REG;}
72 $esi { yylval = RN_ESI; return REG;}
73 $edi { yylval = RN_EDI; return REG;}
75 $es { yylval = RN_ES; return REG;}
76 $ds { yylval = RN_DS; return REG;}
77 $cs { yylval = RN_CS; return REG;}
78 $ss { yylval = RN_SS; return REG;}
80 info|inf|in { return INFO; }
81 segments|segm { return SEGMENTS; }
82 break|brea|bre { return BREAK; }
83 enable|enabl|enab|ena { return ENABLE;}
84 disable|disabl|disab|disa|dis { return DISABLE; }
86 quit|qui|qu { return QUIT; }
88 help|hel|he { return HELP; }
90 set|se { return SET; }
92 bt { return BACKTRACE; }
94 cont|con|co { return CONT; }
96 symbolfile|symbolfil|symbolfi|symbolf|symbol|symbo|symb { return SYMBOLFILE; }
98 define|defin|defi|def|de { return DEFINE; }
99 abort|abor|abo { return ABORT; }
100 print|prin|pri|pr { return PRINT; }
102 mode { return MODE; }
104 regs|reg|re { return REGS; }
106 stack|stac|sta|st { return STACK; }
118 {IDENTIFIER} {yylval = (int) make_symbol(yytext);
122 [ \t]+ /* Eat up whitespace */
124 . { if(syntax_error == 0) {
125 syntax_error ++; fprintf(stderr, "Syntax Error\n"); }
131 int yywrap(void) { return 1; }
136 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
140 /* Used only with GNU readline */
141 #include "readline/readline.h"
142 #include "readline/chardefs.h"
145 /* Strip whitespace from the start and end of STRING. */
146 static void stripwhite (char *string)
150 while (whitespace (string[i]))
154 strcpy (string, string + i);
156 i = strlen (string) - 1;
158 while (i > 0 && whitespace (string[i]))
164 dbg_read(char * buf, int size){
170 line = readline ("Wine-dbg>");
174 /* Remove leading and trailing whitespace from the line.
175 Then, if there is anything left, add it to the history list
183 fprintf(stderr,"Fatal readline goof.\n");
195 static char *local_symbols[10];
196 static int next_symbol;
198 char * make_symbol(char * symbol){
199 return local_symbols[next_symbol++] = strdup(symbol);
204 while(--next_symbol>= 0) free(local_symbols[next_symbol]);