## some test code for dercuano/notes/immediate-mode-parsers.html ## just to make sure it's syntactically valid and compiles to ## something reasonable mov $'h, %al call letter mov $'i, %al call letter letter: mov (%esi), %bl cmp %al, %bl jne explode inc %esi clc ret jc 1f mov $'h, %al call letter mov $'i, %al call letter 1: call backtrack jc 1f mov $'j, %al call letter 1: ret call choice jc 1f mov $'h, %al call letter mov $'i, %al call letter 1: call nextchoice jc 1f mov $'j, %al call letter 1: call endchoice ret call choice jc 1f call parse_keyword 1: call negatechoice jc 1f call parse_identifier 1: ret call choice jc 1f 2: mov $'a, %al call letter call repetition jc 1f jmp 2b 1: call endchoice mov $'b, %al call letter mov $('a | 'z << 8), %ax call range .data t: .ascii "const" t_end: .text mov $t, %eax mov $(t_end - t), %ecx call literal savecontext: pop %eax # pc push %ebp # backtracking stack pointer push %esi # input pointer push %edi # allocation arena pointer push %ebx # variable bindings pointer push %eax # pc mov %esp, %ebp # point backtrack stack to newly allocated state push %eax clc ret