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, "%lx", &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 info|inf|in { return INFO; }
79 quit|qui|qu { return QUIT; }
81 help|hel|he { return HELP; }
83 set|se { return SET; }
85 cont|con|co { return CONT; }
87 symbolfile|symbolfil|symbolfi|symbolf|symbol|symbo|symb { return SYMBOLFILE; }
89 define|defin|defi|def|de { return DEFINE; }
90 print|prin|pri|pr { return PRINT; }
92 regs|reg|re { return REGS; }
94 stack|stac|sta|st { return STACK; }
104 {IDENTIFIER} {yylval = (int) make_symbol(yytext);
108 [ \t]+ /* Eat up whitespace */
110 . { if(syntax_error == 0) {
111 syntax_error ++; fprintf(stderr, "Syntax Error\n"); }
117 int yywrap(void) { return 1; }
122 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
126 /* Used only with GNU readline */
127 #include "readline/readline.h"
128 #include "readline/chardefs.h"
131 dbg_read(char * buf, int size){
137 line = readline ("Wine-dbg>");
146 /* Remove leading and trailing whitespace from the line.
147 Then, if there is anything left, add it to the history list
155 fprintf(stderr,"Fatal readline goof.\n");
169 /* Strip whitespace from the start and end of STRING. */
175 while (whitespace (string[i]))
179 strcpy (string, string + i);
181 i = strlen (string) - 1;
183 while (i > 0 && whitespace (string[i]))
189 static char *local_symbols[10];
190 static int next_symbol;
192 char * make_symbol(char * symbol){
193 return local_symbols[next_symbol++] = strdup(symbol);
198 while(--next_symbol>= 0) free(local_symbols[next_symbol]);