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\.~]*
32 FILE_IDENTIFIER [_a-zA-Z\.~/][_a-zA-Z\.~/]*
36 \n { syntax_error = 0; return '\n'; } /* Indicate end of command */
55 sscanf(yytext, "%x", &yylval);
60 sscanf(yytext, "%d", &yylval);
64 $pc { yylval = RN_EIP; return REG;}
65 $sp { yylval = RN_ESP_AT_SIGNAL; return REG;}
66 $eip { yylval = RN_EIP; return REG;}
67 $esp { yylval = RN_ESP_AT_SIGNAL; return REG;}
68 $ebp { yylval = RN_EBP; return REG;}
69 $eax { yylval = RN_EAX; return REG;}
70 $ebx { yylval = RN_EBX; return REG;}
71 $ecx { yylval = RN_ECX; return REG;}
72 $edx { yylval = RN_EDX; return REG;}
73 $esi { yylval = RN_ESI; return REG;}
74 $edi { yylval = RN_EDI; return REG;}
76 $es { yylval = RN_ES; return REG;}
77 $ds { yylval = RN_DS; return REG;}
78 $cs { yylval = RN_CS; return REG;}
79 $ss { yylval = RN_SS; return REG;}
81 info|inf|in { return INFO; }
82 segments|segm { return SEGMENTS; }
83 break|brea|bre { return BREAK; }
84 enable|enabl|enab|ena { return ENABLE;}
85 disable|disabl|disab|disa|dis { return DISABLE; }
87 quit|qui|qu { return QUIT; }
89 help|hel|he { return HELP; }
91 set|se { return SET; }
93 bt { return BACKTRACE; }
95 cont|con|co { return CONT; }
97 symbolfile|symbolfil|symbolfi|symbolf|symbol|symbo|symb { return SYMBOLFILE; }
99 define|defin|defi|def|de { return DEFINE; }
100 abort|abor|abo { return ABORT; }
101 print|prin|pri|pr { return PRINT; }
103 mode { return MODE; }
105 regs|reg|re { return REGS; }
107 stack|stac|sta|st { return STACK; }
119 {IDENTIFIER} {yylval = (int) make_symbol(yytext);
123 {FILE_IDENTIFIER} {yylval = (int) make_symbol(yytext);
124 return FILE_IDENTIFIER;
127 [ \t]+ /* Eat up whitespace */
129 . { if(syntax_error == 0) {
130 syntax_error ++; fprintf(stderr, "Syntax Error\n"); }
136 int yywrap(void) { return 1; }
141 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
145 /* Used only with GNU readline */
146 #include "readline/readline.h"
147 #include "readline/chardefs.h"
150 /* Strip whitespace from the start and end of STRING. */
151 static void stripwhite (char *string)
155 while (whitespace (string[i]))
159 strcpy (string, string + i);
161 i = strlen (string) - 1;
163 while (i > 0 && whitespace (string[i]))
169 dbg_read(char * buf, int size){
175 line = readline ("Wine-dbg>");
184 /* Remove leading and trailing whitespace from the line.
185 Then, if there is anything left, add it to the history list
193 fprintf(stderr,"Fatal readline goof.\n");
207 static char *local_symbols[10];
208 static int next_symbol;
210 char * make_symbol(char * symbol){
211 return local_symbols[next_symbol++] = strdup(symbol);
216 while(--next_symbol>= 0) free(local_symbols[next_symbol]);