2003-11-28 18:07:29 +03:00
|
|
|
%{
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 23:16:02 +03:00
|
|
|
// $Id$
|
2003-11-28 18:07:29 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2009-04-03 21:36:24 +04:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
#include <io.h>
|
2009-04-07 20:12:19 +04:00
|
|
|
#define YY_NO_UNISTD_H
|
2009-04-03 21:36:24 +04:00
|
|
|
#endif
|
|
|
|
|
2003-11-28 18:07:29 +03:00
|
|
|
#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
|
|
|
|
|
2014-02-12 00:51:18 +04:00
|
|
|
#if BX_SUPPORT_EVEX
|
|
|
|
#define EVEX_OPMASK_REG(reg) \
|
|
|
|
{ bxlval.uval = reg; return(BX_TOKEN_OPMASK_REG); }
|
|
|
|
#else
|
|
|
|
#define EVEX_OPMASK_REG(reg) \
|
|
|
|
{ bxlval.sval = strdup(bxtext); return(BX_TOKEN_GENERIC); }
|
|
|
|
#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); }
|
2017-06-03 22:11:52 +03:00
|
|
|
if { bxlval.sval = strdup(bxtext); return(BX_TOKEN_IF); }
|
2003-11-28 18:07:29 +03:00
|
|
|
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 |
|
2008-04-26 22:50:32 +04:00
|
|
|
b|pb |
|
2003-11-28 18:07:29 +03:00
|
|
|
pbreak { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PBREAKPOINT); }
|
|
|
|
info { bxlval.sval = strdup(bxtext); return(BX_TOKEN_INFO); }
|
|
|
|
cr |
|
2009-08-07 12:26:41 +04:00
|
|
|
creg { bxlval.sval = strdup(bxtext); return(BX_TOKEN_CONTROL_REGS); }
|
|
|
|
dr |
|
|
|
|
dreg { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DEBUG_REGS); }
|
|
|
|
sreg { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SEGMENT_REGS); }
|
2009-04-03 21:36:24 +04:00
|
|
|
r { bxlval.sval = strdup(bxtext); return(BX_TOKEN_R); }
|
|
|
|
reg|regs |
|
|
|
|
registers { bxlval.sval = strdup(bxtext); return(BX_TOKEN_REGS); }
|
2008-04-26 22:50:32 +04:00
|
|
|
fp|fpu { bxlval.sval = strdup(bxtext); return(BX_TOKEN_FPU); }
|
2013-11-20 01:53:55 +04:00
|
|
|
sse|xmm { bxlval.sval = strdup(bxtext); return(BX_TOKEN_XMM); }
|
|
|
|
ymm { bxlval.sval = strdup(bxtext); return(BX_TOKEN_YMM); }
|
|
|
|
zmm { bxlval.sval = strdup(bxtext); return(BX_TOKEN_ZMM); }
|
|
|
|
avx { bxlval.sval = strdup(bxtext); return(BX_TOKEN_AVX); }
|
2007-10-11 22:12:00 +04:00
|
|
|
mmx { bxlval.sval = strdup(bxtext); return(BX_TOKEN_MMX); }
|
2003-11-28 18:07:29 +03:00
|
|
|
cpu { bxlval.sval = strdup(bxtext); return(BX_TOKEN_CPU); }
|
|
|
|
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
|
|
|
linux { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LINUX); }
|
|
|
|
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); }
|
2007-10-14 23:04:51 +04:00
|
|
|
restore { bxlval.sval = strdup(bxtext); return(BX_TOKEN_RESTORE); }
|
2012-04-24 15:01:59 +04:00
|
|
|
writemem { bxlval.sval = strdup(bxtext); return(BX_TOKEN_WRITEMEM); }
|
2022-08-22 08:17:57 +03:00
|
|
|
loadmem { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LOADMEM); }
|
2003-11-28 18:07:29 +03:00
|
|
|
setpmem { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SETPMEM); }
|
2022-08-23 23:37:30 +03:00
|
|
|
deref { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DEREF); }
|
2003-11-28 18:07:29 +03:00
|
|
|
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); }
|
2019-12-04 22:53:47 +03:00
|
|
|
smi { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SMI); }
|
|
|
|
nmi { bxlval.sval = strdup(bxtext); return(BX_TOKEN_NMI); }
|
2013-01-14 21:02:07 +04:00
|
|
|
tlb { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TLB); }
|
2003-11-28 18:07:29 +03:00
|
|
|
u |
|
2009-12-28 16:44:32 +03:00
|
|
|
disasm { BEGIN(DISASM); bxlval.sval = strdup(bxtext); return(BX_TOKEN_DISASM); }
|
2003-11-28 18:07:29 +03:00
|
|
|
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); }
|
2008-04-19 17:21:23 +04:00
|
|
|
trace-mem { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TRACEMEM); }
|
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); }
|
|
|
|
modebp { bxlval.sval = strdup(bxtext); return(BX_TOKEN_MODEBP); }
|
2011-05-06 12:30:44 +04:00
|
|
|
vmexitbp { bxlval.sval = strdup(bxtext); return(BX_TOKEN_VMEXITBP); }
|
2003-11-28 18:07:29 +03:00
|
|
|
print-stack { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PRINT_STACK); }
|
2017-08-23 00:03:58 +03:00
|
|
|
bt { bxlval.sval = strdup(bxtext); return(BX_TOKEN_BT); }
|
2003-11-28 18:07:29 +03:00
|
|
|
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); }
|
2009-04-03 21:36:24 +04:00
|
|
|
w|write { bxlval.sval = strdup(bxtext); return(BX_TOKEN_WRITE); }
|
2003-11-28 18:07:29 +03:00
|
|
|
show { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SHOW); }
|
2008-03-30 00:32:18 +03:00
|
|
|
ldsym { 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); }
|
|
|
|
page { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PAGE); }
|
2012-03-10 21:14:07 +04:00
|
|
|
device { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DEVICE); }
|
2009-10-29 18:49:50 +03:00
|
|
|
all { bxlval.sval = strdup(bxtext); return(BX_TOKEN_ALL); }
|
2016-04-30 00:01:28 +03:00
|
|
|
al { bxlval.uval = BX_8BIT_REG_AL; return(BX_TOKEN_8BL_REG);}
|
|
|
|
bl { bxlval.uval = BX_8BIT_REG_BL; return(BX_TOKEN_8BL_REG);}
|
|
|
|
cl { bxlval.uval = BX_8BIT_REG_CL; return(BX_TOKEN_8BL_REG);}
|
|
|
|
dl { bxlval.uval = BX_8BIT_REG_DL; return(BX_TOKEN_8BL_REG);}
|
|
|
|
sil { LONG_MODE_8BL_REG(BX_8BIT_REG_SIL); }
|
|
|
|
dil { LONG_MODE_8BL_REG(BX_8BIT_REG_DIL); }
|
|
|
|
spl { LONG_MODE_8BL_REG(BX_8BIT_REG_SPL); }
|
|
|
|
bpl { LONG_MODE_8BL_REG(BX_8BIT_REG_BPL); }
|
|
|
|
r8b { LONG_MODE_8BL_REG(BX_8BIT_REG_R8); }
|
|
|
|
r9b { LONG_MODE_8BL_REG(BX_8BIT_REG_R9); }
|
|
|
|
r10b { LONG_MODE_8BL_REG(BX_8BIT_REG_R10); }
|
|
|
|
r11b { LONG_MODE_8BL_REG(BX_8BIT_REG_R11); }
|
|
|
|
r12b { LONG_MODE_8BL_REG(BX_8BIT_REG_R12); }
|
|
|
|
r13b { LONG_MODE_8BL_REG(BX_8BIT_REG_R13); }
|
|
|
|
r14b { LONG_MODE_8BL_REG(BX_8BIT_REG_R14); }
|
|
|
|
r15b { LONG_MODE_8BL_REG(BX_8BIT_REG_R15); }
|
|
|
|
ah { bxlval.uval = BX_8BIT_REG_AH; return(BX_TOKEN_8BH_REG);}
|
|
|
|
bh { bxlval.uval = BX_8BIT_REG_BH; return(BX_TOKEN_8BH_REG);}
|
|
|
|
ch { bxlval.uval = BX_8BIT_REG_CH; return(BX_TOKEN_8BH_REG);}
|
|
|
|
dh { bxlval.uval = BX_8BIT_REG_DH; return(BX_TOKEN_8BH_REG);}
|
|
|
|
ax { bxlval.uval = BX_16BIT_REG_AX; return(BX_TOKEN_16B_REG);}
|
|
|
|
bx { bxlval.uval = BX_16BIT_REG_BX; return(BX_TOKEN_16B_REG);}
|
|
|
|
cx { bxlval.uval = BX_16BIT_REG_CX; return(BX_TOKEN_16B_REG);}
|
|
|
|
dx { bxlval.uval = BX_16BIT_REG_DX; return(BX_TOKEN_16B_REG);}
|
|
|
|
si { bxlval.uval = BX_16BIT_REG_SI; return(BX_TOKEN_16B_REG);}
|
|
|
|
di { bxlval.uval = BX_16BIT_REG_DI; return(BX_TOKEN_16B_REG);}
|
|
|
|
bp { bxlval.uval = BX_16BIT_REG_BP; return(BX_TOKEN_16B_REG);}
|
|
|
|
sp { bxlval.uval = BX_16BIT_REG_SP; return(BX_TOKEN_16B_REG);}
|
|
|
|
r8w { LONG_MODE_16B_REG(BX_16BIT_REG_R8); }
|
|
|
|
r9w { LONG_MODE_16B_REG(BX_16BIT_REG_R9); }
|
|
|
|
r10w { LONG_MODE_16B_REG(BX_16BIT_REG_R10); }
|
|
|
|
r11w { LONG_MODE_16B_REG(BX_16BIT_REG_R11); }
|
|
|
|
r12w { LONG_MODE_16B_REG(BX_16BIT_REG_R12); }
|
|
|
|
r13w { LONG_MODE_16B_REG(BX_16BIT_REG_R13); }
|
|
|
|
r14w { LONG_MODE_16B_REG(BX_16BIT_REG_R14); }
|
|
|
|
r15w { LONG_MODE_16B_REG(BX_16BIT_REG_R15); }
|
|
|
|
eax { bxlval.uval = BX_32BIT_REG_EAX; return(BX_TOKEN_32B_REG);}
|
|
|
|
ebx { bxlval.uval = BX_32BIT_REG_EBX; return(BX_TOKEN_32B_REG);}
|
|
|
|
ecx { bxlval.uval = BX_32BIT_REG_ECX; return(BX_TOKEN_32B_REG);}
|
|
|
|
edx { bxlval.uval = BX_32BIT_REG_EDX; return(BX_TOKEN_32B_REG);}
|
|
|
|
esi { bxlval.uval = BX_32BIT_REG_ESI; return(BX_TOKEN_32B_REG);}
|
|
|
|
edi { bxlval.uval = BX_32BIT_REG_EDI; return(BX_TOKEN_32B_REG);}
|
|
|
|
ebp { bxlval.uval = BX_32BIT_REG_EBP; return(BX_TOKEN_32B_REG);}
|
|
|
|
esp { bxlval.uval = BX_32BIT_REG_ESP; return(BX_TOKEN_32B_REG);}
|
|
|
|
r8d { LONG_MODE_32B_REG(BX_32BIT_REG_R8); }
|
|
|
|
r9d { LONG_MODE_32B_REG(BX_32BIT_REG_R9); }
|
|
|
|
r10d { LONG_MODE_32B_REG(BX_32BIT_REG_R10); }
|
|
|
|
r11d { LONG_MODE_32B_REG(BX_32BIT_REG_R11); }
|
|
|
|
r12d { LONG_MODE_32B_REG(BX_32BIT_REG_R12); }
|
|
|
|
r13d { LONG_MODE_32B_REG(BX_32BIT_REG_R13); }
|
|
|
|
r14d { LONG_MODE_32B_REG(BX_32BIT_REG_R14); }
|
|
|
|
r15d { LONG_MODE_32B_REG(BX_32BIT_REG_R15); }
|
|
|
|
rax { LONG_MODE_64B_REG(BX_64BIT_REG_RAX); }
|
|
|
|
rbx { LONG_MODE_64B_REG(BX_64BIT_REG_RBX); }
|
|
|
|
rcx { LONG_MODE_64B_REG(BX_64BIT_REG_RCX); }
|
|
|
|
rdx { LONG_MODE_64B_REG(BX_64BIT_REG_RDX); }
|
|
|
|
rsi { LONG_MODE_64B_REG(BX_64BIT_REG_RSI); }
|
|
|
|
rdi { LONG_MODE_64B_REG(BX_64BIT_REG_RDI); }
|
|
|
|
rsp { LONG_MODE_64B_REG(BX_64BIT_REG_RSP); }
|
|
|
|
rbp { LONG_MODE_64B_REG(BX_64BIT_REG_RBP); }
|
|
|
|
r8 { LONG_MODE_64B_REG(BX_64BIT_REG_R8); }
|
|
|
|
r9 { LONG_MODE_64B_REG(BX_64BIT_REG_R9); }
|
|
|
|
r10 { LONG_MODE_64B_REG(BX_64BIT_REG_R10); }
|
|
|
|
r11 { LONG_MODE_64B_REG(BX_64BIT_REG_R11); }
|
|
|
|
r12 { LONG_MODE_64B_REG(BX_64BIT_REG_R12); }
|
|
|
|
r13 { LONG_MODE_64B_REG(BX_64BIT_REG_R13); }
|
|
|
|
r14 { LONG_MODE_64B_REG(BX_64BIT_REG_R14); }
|
|
|
|
r15 { LONG_MODE_64B_REG(BX_64BIT_REG_R15); }
|
2006-02-13 21:28:14 +03:00
|
|
|
ip { return(BX_TOKEN_REG_IP); }
|
|
|
|
eip { return(BX_TOKEN_REG_EIP);}
|
|
|
|
rip { return(BX_TOKEN_REG_RIP);}
|
2019-12-20 10:42:07 +03:00
|
|
|
ssp { return(BX_TOKEN_REG_SSP);}
|
2016-04-30 00:01:28 +03:00
|
|
|
cs { bxlval.uval = BX_SEG_REG_CS; return(BX_TOKEN_CS); }
|
|
|
|
es { bxlval.uval = BX_SEG_REG_ES; return(BX_TOKEN_ES); }
|
|
|
|
ss { bxlval.uval = BX_SEG_REG_SS; return(BX_TOKEN_SS); }
|
|
|
|
ds { bxlval.uval = BX_SEG_REG_DS; return(BX_TOKEN_DS); }
|
|
|
|
fs { bxlval.uval = BX_SEG_REG_FS; return(BX_TOKEN_FS); }
|
|
|
|
gs { bxlval.uval = BX_SEG_REG_GS; return(BX_TOKEN_GS); }
|
2014-02-12 00:51:18 +04:00
|
|
|
k[0-7] { EVEX_OPMASK_REG(bxtext[1] - '0'); }
|
2006-01-25 21:13:44 +03:00
|
|
|
flags|eflags { bxlval.uval = 0; return (BX_TOKEN_FLAGS); }
|
2014-11-16 01:03:52 +03:00
|
|
|
xml { bxlval.sval = strdup(bxtext); return(BX_TOKEN_XML); }
|
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); }
|
2022-08-29 19:27:12 +03:00
|
|
|
addlyt { bxlval.sval = strdup(bxtext); return(BX_TOKEN_ADDLYT); }
|
|
|
|
remlyt { bxlval.sval = strdup(bxtext); return(BX_TOKEN_REMLYT); }
|
|
|
|
lyt { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LYT); }
|
2022-09-12 11:48:54 +03:00
|
|
|
source { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SOURCE); }
|
2003-11-28 18:07:29 +03:00
|
|
|
<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 ('-'); }
|
2022-08-23 23:37:30 +03:00
|
|
|
"$" { return (BX_TOKEN_DEREF_CHR); }
|
2003-11-28 18:07:29 +03:00
|
|
|
"*" { return ('*'); }
|
|
|
|
"/" { return ('/'); }
|
|
|
|
">>" { return (BX_TOKEN_RSHIFT); }
|
|
|
|
"<<" { return (BX_TOKEN_LSHIFT); }
|
2017-06-03 22:11:52 +03:00
|
|
|
"==" { return (BX_TOKEN_EQ); }
|
|
|
|
"!=" { return (BX_TOKEN_NE); }
|
|
|
|
"<=" { return (BX_TOKEN_LE); }
|
|
|
|
">=" { return (BX_TOKEN_GE); }
|
|
|
|
">" { return ('>'); }
|
|
|
|
"<" { return ('<'); }
|
2003-11-28 18:07:29 +03:00
|
|
|
"&" { return ('&'); }
|
|
|
|
"|" { return ('|'); }
|
|
|
|
"^" { return ('^'); }
|
|
|
|
"!" { return ('!'); }
|
2010-01-05 16:59:08 +03:00
|
|
|
"@" { return ('@'); }
|
2003-11-28 18:07:29 +03:00
|
|
|
"(" { return ('('); }
|
|
|
|
")" { return (')'); }
|
2007-10-14 23:04:51 +04:00
|
|
|
\'([^\\\'\n]|(\\.))*\' | /* throw away leading and trailing \" */
|
|
|
|
\"([^\\\"\n]|(\\.))*\" { bxlval.sval = strdup(bxtext+1); bxlval.sval[strlen(bxlval.sval)-1] = 0; return(BX_TOKEN_STRING); }
|
2006-10-19 21:51:58 +04:00
|
|
|
0x[0-9a-fA-F]+ { bxlval.uval = strtoull(bxtext, NULL, 16); return(BX_TOKEN_NUMERIC); }
|
|
|
|
0[0-7]+ { bxlval.uval = strtoull(bxtext, NULL, 8); return(BX_TOKEN_NUMERIC); }
|
2006-05-29 23:56:29 +04:00
|
|
|
[0-9]+ { bxlval.uval = strtoull(bxtext, NULL, 10); return(BX_TOKEN_NUMERIC); }
|
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 */
|