2003-11-28 18:07:29 +03:00
|
|
|
%{
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2006-06-11 22:03:45 +04:00
|
|
|
// $Id: lexer.l,v 1.18 2006-06-11 18:03:45 sshwarts Exp $
|
2003-11-28 18:07:29 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "debug.h"
|
|
|
|
#if BX_DEBUGGER
|
|
|
|
|
|
|
|
#include "parser.h"
|
|
|
|
|
|
|
|
int bx_yyinput(char *buf, int max_size);
|
|
|
|
#undef YY_INPUT
|
|
|
|
#define YY_INPUT(buf, ret, max_size) (ret = bx_yyinput(buf, max_size))
|
|
|
|
|
|
|
|
static char *lex_input_ptr = NULL;
|
|
|
|
static unsigned lex_input_size = 0;
|
2006-02-13 21:28:14 +03:00
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
#define LONG_MODE_8BL_REG(reg) \
|
|
|
|
{ bxlval.uval = reg; return(BX_TOKEN_8BL_REG); }
|
|
|
|
#define LONG_MODE_16B_REG(reg) \
|
|
|
|
{ bxlval.uval = reg; return(BX_TOKEN_16B_REG); }
|
|
|
|
#define LONG_MODE_32B_REG(reg) \
|
|
|
|
{ bxlval.uval = reg; return(BX_TOKEN_32B_REG); }
|
|
|
|
#define LONG_MODE_64B_REG(reg) \
|
|
|
|
{ bxlval.uval = reg; return(BX_TOKEN_64B_REG); }
|
|
|
|
#else
|
|
|
|
#define LONG_MODE_8BL_REG(reg) \
|
2006-02-27 09:14:42 +03:00
|
|
|
{ bxlval.sval = strdup(bxtext); return(BX_TOKEN_GENERIC); }
|
2006-02-13 21:28:14 +03:00
|
|
|
#define LONG_MODE_16B_REG(reg) \
|
2006-02-27 09:14:42 +03:00
|
|
|
{ bxlval.sval = strdup(bxtext); return(BX_TOKEN_GENERIC); }
|
2006-02-13 21:28:14 +03:00
|
|
|
#define LONG_MODE_32B_REG(reg) \
|
2006-02-27 09:14:42 +03:00
|
|
|
{ bxlval.sval = strdup(bxtext); return(BX_TOKEN_GENERIC); }
|
2006-02-13 21:28:14 +03:00
|
|
|
#define LONG_MODE_64B_REG(reg) \
|
2006-02-27 09:14:42 +03:00
|
|
|
{ bxlval.sval = strdup(bxtext); return(BX_TOKEN_GENERIC); }
|
2006-02-13 21:28:14 +03:00
|
|
|
#endif
|
|
|
|
|
2003-11-28 18:07:29 +03:00
|
|
|
%}
|
|
|
|
|
|
|
|
%x EXAMINE
|
|
|
|
%x DISASM
|
|
|
|
|
|
|
|
%%
|
|
|
|
<*>[ \t]+ ; // eat up whitespace
|
|
|
|
set { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SET); }
|
2006-01-25 21:13:44 +03:00
|
|
|
on { bxlval.bval = 1; return(BX_TOKEN_ON); }
|
|
|
|
off { bxlval.bval = 0; return(BX_TOKEN_OFF); }
|
2003-11-28 18:07:29 +03:00
|
|
|
crc { bxlval.sval = strdup(bxtext); return(BX_TOKEN_CRC); }
|
|
|
|
c |
|
2006-01-24 22:03:55 +03:00
|
|
|
cont |
|
|
|
|
continue { bxlval.sval = strdup(bxtext); return(BX_TOKEN_CONTINUE); }
|
2003-11-28 18:07:29 +03:00
|
|
|
stepi |
|
|
|
|
step |
|
|
|
|
s { bxlval.sval = strdup(bxtext); return(BX_TOKEN_STEPN); }
|
|
|
|
next |
|
|
|
|
n |
|
|
|
|
p { bxlval.sval = strdup(bxtext); return(BX_TOKEN_STEP_OVER); }
|
|
|
|
blist { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LIST_BREAK); }
|
2006-02-13 21:28:14 +03:00
|
|
|
vb|vbreak { bxlval.sval = strdup(bxtext); return(BX_TOKEN_VBREAKPOINT); }
|
|
|
|
lb|lbreak { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LBREAKPOINT); }
|
2003-11-28 18:07:29 +03:00
|
|
|
break |
|
|
|
|
b |
|
|
|
|
pb |
|
|
|
|
pbreak { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PBREAKPOINT); }
|
|
|
|
info { bxlval.sval = strdup(bxtext); return(BX_TOKEN_INFO); }
|
|
|
|
cr |
|
|
|
|
creg |
|
|
|
|
cregs { bxlval.sval = strdup(bxtext); return(BX_TOKEN_CONTROL_REGS); }
|
|
|
|
r |
|
|
|
|
reg |
|
2006-01-24 00:44:44 +03:00
|
|
|
regs |
|
2003-11-28 18:07:29 +03:00
|
|
|
registers { bxlval.sval = strdup(bxtext); return(BX_TOKEN_REGISTERS); }
|
|
|
|
fpu { bxlval.sval = strdup(bxtext); return(BX_TOKEN_FPU); }
|
2006-01-24 22:03:55 +03:00
|
|
|
sse { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SSE); }
|
2003-11-28 18:07:29 +03:00
|
|
|
cpu { bxlval.sval = strdup(bxtext); return(BX_TOKEN_CPU); }
|
|
|
|
all { bxlval.sval = strdup(bxtext); return(BX_TOKEN_ALL); }
|
|
|
|
idt { bxlval.sval = strdup(bxtext); return(BX_TOKEN_IDT); }
|
|
|
|
ivt { bxlval.sval = strdup(bxtext); return(BX_TOKEN_IVT); }
|
|
|
|
gdt { bxlval.sval = strdup(bxtext); return(BX_TOKEN_GDT); }
|
|
|
|
ldt { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LDT); }
|
|
|
|
tss { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TSS); }
|
2006-02-11 23:47:22 +03:00
|
|
|
tab { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TAB); }
|
2003-11-28 18:07:29 +03:00
|
|
|
dirty { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DIRTY); }
|
|
|
|
linux { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LINUX); }
|
|
|
|
dump_cpu { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DUMP_CPU); }
|
|
|
|
delete |
|
|
|
|
del |
|
|
|
|
d { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DEL_BREAKPOINT); }
|
|
|
|
bpe { bxlval.sval = strdup(bxtext); return(BX_TOKEN_ENABLE_BREAKPOINT); }
|
|
|
|
bpd { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DISABLE_BREAKPOINT); }
|
|
|
|
quit |
|
|
|
|
exit |
|
|
|
|
q { bxlval.sval = strdup(bxtext); return(BX_TOKEN_QUIT); }
|
|
|
|
x |
|
|
|
|
xp { BEGIN(EXAMINE); bxlval.sval = strdup(bxtext); return(BX_TOKEN_EXAMINE); }
|
|
|
|
setpmem { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SETPMEM); }
|
|
|
|
query { bxlval.sval = strdup(bxtext); return(BX_TOKEN_QUERY); }
|
|
|
|
pending { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PENDING); }
|
|
|
|
take { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TAKE); }
|
|
|
|
dma { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DMA); }
|
|
|
|
irq { bxlval.sval = strdup(bxtext); return(BX_TOKEN_IRQ); }
|
|
|
|
pic { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PIC); }
|
|
|
|
set_cpu { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SET_CPU); }
|
|
|
|
u |
|
2006-01-24 22:03:55 +03:00
|
|
|
disasm |
|
2003-11-28 18:07:29 +03:00
|
|
|
disassemble { BEGIN(DISASM); bxlval.sval = strdup(bxtext); return(BX_TOKEN_DISASSEMBLE); }
|
|
|
|
instrument { bxlval.sval = strdup(bxtext); return(BX_TOKEN_INSTRUMENT); }
|
|
|
|
stop { bxlval.sval = strdup(bxtext); return(BX_TOKEN_STOP); }
|
|
|
|
doit { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DOIT); }
|
2006-01-31 22:45:34 +03:00
|
|
|
trace { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TRACE); }
|
|
|
|
trace-reg { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TRACEREG); }
|
2006-01-25 00:37:37 +03:00
|
|
|
switch-mode { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SWITCH_MODE); }
|
|
|
|
size { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SIZE); }
|
2003-11-28 18:07:29 +03:00
|
|
|
ptime { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PTIME); }
|
|
|
|
sb { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TIMEBP); }
|
|
|
|
sba { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TIMEBP_ABSOLUTE); }
|
|
|
|
record { bxlval.sval = strdup(bxtext); return(BX_TOKEN_RECORD); }
|
|
|
|
playback { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PLAYBACK); }
|
|
|
|
modebp { bxlval.sval = strdup(bxtext); return(BX_TOKEN_MODEBP); }
|
|
|
|
print-stack { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PRINT_STACK); }
|
|
|
|
watch { bxlval.sval = strdup(bxtext); return(BX_TOKEN_WATCH); }
|
|
|
|
unwatch { bxlval.sval = strdup(bxtext); return(BX_TOKEN_UNWATCH); }
|
|
|
|
read { bxlval.sval = strdup(bxtext); return(BX_TOKEN_READ); }
|
|
|
|
write { bxlval.sval = strdup(bxtext); return(BX_TOKEN_WRITE); }
|
|
|
|
show { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SHOW); }
|
2006-01-24 22:03:55 +03:00
|
|
|
load-symbols { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LOAD_SYMBOLS); }
|
2003-11-28 18:07:29 +03:00
|
|
|
symbols { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SYMBOLS); }
|
|
|
|
slist { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LIST_SYMBOLS); }
|
|
|
|
global { bxlval.sval = strdup(bxtext); return(BX_TOKEN_GLOBAL); }
|
|
|
|
where { bxlval.sval = strdup(bxtext); return(BX_TOKEN_WHERE); }
|
|
|
|
print-string { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PRINT_STRING); }
|
2006-01-27 22:50:00 +03:00
|
|
|
ne2k|ne2000 { bxlval.sval = strdup(bxtext); return(BX_TOKEN_NE2000); }
|
2003-11-28 18:07:29 +03:00
|
|
|
page { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PAGE); }
|
2004-08-24 14:15:56 +04:00
|
|
|
vga { bxlval.sval = strdup(bxtext); return(BX_TOKEN_VGA); }
|
2006-02-13 21:28:14 +03:00
|
|
|
al { bxlval.uval = BX_DBG_REG8L_AL; return(BX_TOKEN_8BL_REG);}
|
|
|
|
bl { bxlval.uval = BX_DBG_REG8L_BL; return(BX_TOKEN_8BL_REG);}
|
|
|
|
cl { bxlval.uval = BX_DBG_REG8L_CL; return(BX_TOKEN_8BL_REG);}
|
|
|
|
dl { bxlval.uval = BX_DBG_REG8L_DL; return(BX_TOKEN_8BL_REG);}
|
|
|
|
sil { LONG_MODE_8BL_REG(BX_DBG_REG8L_SIL); }
|
|
|
|
dil { LONG_MODE_8BL_REG(BX_DBG_REG8L_DIL); }
|
|
|
|
spl { LONG_MODE_8BL_REG(BX_DBG_REG8L_SPL); }
|
|
|
|
bpl { LONG_MODE_8BL_REG(BX_DBG_REG8L_BPL); }
|
|
|
|
r8b { LONG_MODE_8BL_REG(BX_DBG_REG8L_R8); }
|
|
|
|
r9b { LONG_MODE_8BL_REG(BX_DBG_REG8L_R9); }
|
|
|
|
r10b { LONG_MODE_8BL_REG(BX_DBG_REG8L_R10); }
|
|
|
|
r11b { LONG_MODE_8BL_REG(BX_DBG_REG8L_R11); }
|
|
|
|
r12b { LONG_MODE_8BL_REG(BX_DBG_REG8L_R12); }
|
|
|
|
r13b { LONG_MODE_8BL_REG(BX_DBG_REG8L_R13); }
|
|
|
|
r14b { LONG_MODE_8BL_REG(BX_DBG_REG8L_R14); }
|
|
|
|
r15b { LONG_MODE_8BL_REG(BX_DBG_REG8L_R15); }
|
|
|
|
ah { bxlval.uval = BX_DBG_REG8H_AH; return(BX_TOKEN_8BH_REG);}
|
|
|
|
bh { bxlval.uval = BX_DBG_REG8H_BH; return(BX_TOKEN_8BH_REG);}
|
|
|
|
ch { bxlval.uval = BX_DBG_REG8H_CH; return(BX_TOKEN_8BH_REG);}
|
|
|
|
dh { bxlval.uval = BX_DBG_REG8H_DH; return(BX_TOKEN_8BH_REG);}
|
|
|
|
ax { bxlval.uval = BX_DBG_REG16_AX; return(BX_TOKEN_16B_REG);}
|
|
|
|
bx { bxlval.uval = BX_DBG_REG16_BX; return(BX_TOKEN_16B_REG);}
|
|
|
|
cx { bxlval.uval = BX_DBG_REG16_CX; return(BX_TOKEN_16B_REG);}
|
|
|
|
dx { bxlval.uval = BX_DBG_REG16_DX; return(BX_TOKEN_16B_REG);}
|
|
|
|
si { bxlval.uval = BX_DBG_REG16_SI; return(BX_TOKEN_16B_REG);}
|
|
|
|
di { bxlval.uval = BX_DBG_REG16_DI; return(BX_TOKEN_16B_REG);}
|
|
|
|
bp { bxlval.uval = BX_DBG_REG16_BP; return(BX_TOKEN_16B_REG);}
|
|
|
|
sp { bxlval.uval = BX_DBG_REG16_SP; return(BX_TOKEN_16B_REG);}
|
|
|
|
r8w { LONG_MODE_16B_REG(BX_DBG_REG16_R8); }
|
|
|
|
r9w { LONG_MODE_16B_REG(BX_DBG_REG16_R9); }
|
|
|
|
r10w { LONG_MODE_16B_REG(BX_DBG_REG16_R10); }
|
|
|
|
r11w { LONG_MODE_16B_REG(BX_DBG_REG16_R11); }
|
|
|
|
r12w { LONG_MODE_16B_REG(BX_DBG_REG16_R12); }
|
|
|
|
r13w { LONG_MODE_16B_REG(BX_DBG_REG16_R13); }
|
|
|
|
r14w { LONG_MODE_16B_REG(BX_DBG_REG16_R14); }
|
|
|
|
r15w { LONG_MODE_16B_REG(BX_DBG_REG16_R15); }
|
|
|
|
eax { bxlval.uval = BX_DBG_REG32_EAX; return(BX_TOKEN_32B_REG);}
|
|
|
|
ebx { bxlval.uval = BX_DBG_REG32_EBX; return(BX_TOKEN_32B_REG);}
|
|
|
|
ecx { bxlval.uval = BX_DBG_REG32_ECX; return(BX_TOKEN_32B_REG);}
|
|
|
|
edx { bxlval.uval = BX_DBG_REG32_EDX; return(BX_TOKEN_32B_REG);}
|
|
|
|
esi { bxlval.uval = BX_DBG_REG32_ESI; return(BX_TOKEN_32B_REG);}
|
2006-06-11 22:03:45 +04:00
|
|
|
edi { bxlval.uval = BX_DBG_REG32_EDI; return(BX_TOKEN_32B_REG);}
|
2006-02-13 21:28:14 +03:00
|
|
|
ebp { bxlval.uval = BX_DBG_REG32_EBP; return(BX_TOKEN_32B_REG);}
|
|
|
|
esp { bxlval.uval = BX_DBG_REG32_ESP; return(BX_TOKEN_32B_REG);}
|
|
|
|
r8d { LONG_MODE_32B_REG(BX_DBG_REG32_R8); }
|
|
|
|
r9d { LONG_MODE_32B_REG(BX_DBG_REG32_R9); }
|
|
|
|
r10d { LONG_MODE_32B_REG(BX_DBG_REG32_R10); }
|
|
|
|
r11d { LONG_MODE_32B_REG(BX_DBG_REG32_R11); }
|
|
|
|
r12d { LONG_MODE_32B_REG(BX_DBG_REG32_R12); }
|
|
|
|
r13d { LONG_MODE_32B_REG(BX_DBG_REG32_R13); }
|
|
|
|
r14d { LONG_MODE_32B_REG(BX_DBG_REG32_R14); }
|
|
|
|
r15d { LONG_MODE_32B_REG(BX_DBG_REG32_R15); }
|
|
|
|
rax { LONG_MODE_64B_REG(BX_DBG_REG64_RAX); }
|
|
|
|
rbx { LONG_MODE_64B_REG(BX_DBG_REG64_RBX); }
|
|
|
|
rcx { LONG_MODE_64B_REG(BX_DBG_REG64_RCX); }
|
|
|
|
rdx { LONG_MODE_64B_REG(BX_DBG_REG64_RDX); }
|
|
|
|
rsi { LONG_MODE_64B_REG(BX_DBG_REG64_RSI); }
|
|
|
|
rdi { LONG_MODE_64B_REG(BX_DBG_REG64_RDI); }
|
|
|
|
rsp { LONG_MODE_64B_REG(BX_DBG_REG64_RSP); }
|
|
|
|
rbp { LONG_MODE_64B_REG(BX_DBG_REG64_RBP); }
|
|
|
|
r8 { LONG_MODE_64B_REG(BX_DBG_REG64_R8); }
|
|
|
|
r9 { LONG_MODE_64B_REG(BX_DBG_REG64_R9); }
|
|
|
|
r10 { LONG_MODE_64B_REG(BX_DBG_REG64_R10); }
|
|
|
|
r11 { LONG_MODE_64B_REG(BX_DBG_REG64_R11); }
|
|
|
|
r12 { LONG_MODE_64B_REG(BX_DBG_REG64_R12); }
|
|
|
|
r13 { LONG_MODE_64B_REG(BX_DBG_REG64_R13); }
|
|
|
|
r14 { LONG_MODE_64B_REG(BX_DBG_REG64_R14); }
|
|
|
|
r15 { LONG_MODE_64B_REG(BX_DBG_REG64_R15); }
|
|
|
|
ip { return(BX_TOKEN_REG_IP); }
|
|
|
|
eip { return(BX_TOKEN_REG_EIP);}
|
|
|
|
rip { return(BX_TOKEN_REG_RIP);}
|
2006-01-25 21:13:44 +03:00
|
|
|
cs { bxlval.uval = BX_DBG_SREG_CS; return(BX_TOKEN_CS); }
|
|
|
|
es { bxlval.uval = BX_DBG_SREG_ES; return(BX_TOKEN_ES); }
|
|
|
|
ss { bxlval.uval = BX_DBG_SREG_SS; return(BX_TOKEN_SS); }
|
|
|
|
ds { bxlval.uval = BX_DBG_SREG_DS; return(BX_TOKEN_DS); }
|
|
|
|
fs { bxlval.uval = BX_DBG_SREG_FS; return(BX_TOKEN_FS); }
|
|
|
|
gs { bxlval.uval = BX_DBG_SREG_GS; return(BX_TOKEN_GS); }
|
|
|
|
flags|eflags { bxlval.uval = 0; return (BX_TOKEN_FLAGS); }
|
2006-01-25 00:37:37 +03:00
|
|
|
h|help { bxlval.sval = strdup(bxtext); return(BX_TOKEN_HELP); }
|
2003-11-28 18:07:29 +03:00
|
|
|
\? |
|
|
|
|
calc { bxlval.sval = strdup(bxtext); return(BX_TOKEN_CALC); }
|
|
|
|
<EXAMINE>\/[0-9]+ { BEGIN(INITIAL); bxlval.sval = strdup(bxtext); return(BX_TOKEN_XFORMAT); }
|
|
|
|
<EXAMINE>\/[0-9]*[mxduotcsibhwg]+ { BEGIN(INITIAL); bxlval.sval = strdup(bxtext); return(BX_TOKEN_XFORMAT); }
|
|
|
|
<DISASM>\/[0-9]+ { BEGIN(INITIAL); bxlval.sval = strdup(bxtext); return(BX_TOKEN_DISFORMAT); }
|
|
|
|
"+" { return ('+'); }
|
|
|
|
"-" { return ('-'); }
|
|
|
|
"*" { return ('*'); }
|
|
|
|
"/" { return ('/'); }
|
|
|
|
">>" { return (BX_TOKEN_RSHIFT); }
|
|
|
|
"<<" { return (BX_TOKEN_LSHIFT); }
|
|
|
|
"&" { return ('&'); }
|
|
|
|
"|" { return ('|'); }
|
|
|
|
"^" { return ('^'); }
|
|
|
|
"!" { return ('!'); }
|
|
|
|
"(" { return ('('); }
|
|
|
|
")" { return (')'); }
|
2004-06-21 14:45:38 +04:00
|
|
|
\'([^\\\'\n]|(\\.))*\' |
|
|
|
|
\"([^\\\"\n]|(\\.))*\" { bxlval.sval = strdup(bxtext); return(BX_TOKEN_STRING); }
|
2006-05-29 23:56:29 +04:00
|
|
|
0x[0-9a-fA-F]+ { bxlval.uval = strtoull(bxtext+2, NULL, 16); return(BX_TOKEN_NUMERIC); }
|
|
|
|
0[0-7]+ { bxlval.uval = strtoull(bxtext+1, NULL, 8); return(BX_TOKEN_NUMERIC); }
|
|
|
|
[0-9]+ { bxlval.uval = strtoull(bxtext, NULL, 10); return(BX_TOKEN_NUMERIC); }
|
2006-02-12 00:19:22 +03:00
|
|
|
[a-z]+ { bxlval.sval = strdup(bxtext); return(BX_TOKEN_COMMAND); }
|
2003-11-28 18:07:29 +03:00
|
|
|
$[a-zA-Z_][a-zA-Z0-9_]* { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SYMBOLNAME); }
|
2006-02-13 21:28:14 +03:00
|
|
|
[A-Za-z_][A-Za-z0-9_]* { bxlval.sval = strdup(bxtext); return(BX_TOKEN_GENERIC); }
|
2004-06-21 14:45:38 +04:00
|
|
|
<*>";" { return ('\n'); }
|
2006-02-12 00:19:22 +03:00
|
|
|
<*>\n { return ('\n'); }
|
2003-11-28 18:07:29 +03:00
|
|
|
[#][^\n]* ; // eat up comments '//'
|
|
|
|
. { return(bxtext[0]); }
|
|
|
|
<EXAMINE,DISASM>. { BEGIN(INITIAL); unput(*bxtext); }
|
|
|
|
%%
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_yyinput(char *buf, int max_size)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (lex_input_size == 0) {
|
|
|
|
fprintf(stderr, "lex: no characters in string input buffer.\n");
|
|
|
|
exit(1);
|
2005-04-17 01:43:06 +04:00
|
|
|
}
|
2003-11-28 18:07:29 +03:00
|
|
|
|
2005-04-17 01:43:06 +04:00
|
|
|
len = strlen(lex_input_ptr) + 1;
|
|
|
|
if (len > max_size)
|
|
|
|
len = max_size;
|
2003-11-28 18:07:29 +03:00
|
|
|
|
2005-04-17 01:43:06 +04:00
|
|
|
memcpy(buf, lex_input_ptr, len);
|
2003-11-28 18:07:29 +03:00
|
|
|
|
2005-04-17 01:43:06 +04:00
|
|
|
return(len);
|
2003-11-28 18:07:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_add_lex_input(char *buf)
|
|
|
|
{
|
|
|
|
lex_input_ptr = buf;
|
|
|
|
lex_input_size = strlen(buf);
|
|
|
|
|
|
|
|
// Since we're parsing from strings, flush out
|
|
|
|
// all current buffer state, so the next read
|
|
|
|
// requests from yyinput
|
|
|
|
|
|
|
|
bx_flush_buffer( YY_CURRENT_BUFFER );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* if BX_DEBUGGER */
|