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;
32 IDENTIFIER [_a-zA-Z\.~][_a-zA-Z0-9\.~]*
36 \n { syntax_error = 0; return '\n'; } /* Indicate end of command */
55 sscanf(yytext, "%lx", &yylval);
60 sscanf(yytext, "%lx", &yylval);
64 $pc { yylval = RN_EIP; return REG;}
65 $sp { yylval = RN_ESP; return REG;}
66 $eip { yylval = RN_EIP; return REG;}
67 $esp { yylval = RN_ESP; 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 info|inf|in { return INFO; }
78 quit|qui|qu { return QUIT; }
80 help|hel|he { return HELP; }
82 set|se { return SET; }
84 cont|con|co { return CONT; }
86 symbolfile|symbolfil|symbolfi|symbolf|symbol|symbo|symb { return SYMBOLFILE; }
88 define|defin|defi|def|de { return DEFINE; }
89 print|prin|pri|pr { return PRINT; }
91 regs|reg|re { return REGS; }
93 stack|stac|sta|st { return STACK; }
103 {IDENTIFIER} {yylval = (int) make_symbol(yytext);
107 [ \t]+ /* Eat up whitespace */
109 . { if(syntax_error == 0) {
110 syntax_error ++; fprintf(stderr, "Syntax Error\n"); }
117 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
121 /* Used only with GNU readline */
122 #include "readline/readline.h"
123 #include "readline/chardefs.h"
126 dbg_read(char * buf, int size){
132 line = readline ("Wine-dbg>");
141 /* Remove leading and trailing whitespace from the line.
142 Then, if there is anything left, add it to the history list
150 fprintf(stderr,"Fatal readline goof.\n");
164 /* Strip whitespace from the start and end of STRING. */
170 while (whitespace (string[i]))
174 strcpy (string, string + i);
176 i = strlen (string) - 1;
178 while (i > 0 && whitespace (string[i]))
184 static char *local_symbols[10];
185 static int next_symbol;
187 char * make_symbol(char * symbol){
188 return local_symbols[next_symbol++] = strdup(symbol);
193 while(--next_symbol>= 0) free(local_symbols[next_symbol]);