fix a delle regex
This commit is contained in:
parent
adf7ca002d
commit
6cb8019f5f
@ -102,6 +102,7 @@ class VMAssembler:
|
|||||||
"""
|
"""
|
||||||
Intel syntax -> REG, IMM
|
Intel syntax -> REG, IMM
|
||||||
"""
|
"""
|
||||||
|
print(instruction.args)
|
||||||
opcode = instruction.opcode
|
opcode = instruction.opcode
|
||||||
reg = instruction.args[0]
|
reg = instruction.args[0]
|
||||||
imm = instruction.args[1]
|
imm = instruction.args[1]
|
||||||
@ -268,14 +269,18 @@ class VMFunction:
|
|||||||
line = code[i]
|
line = code[i]
|
||||||
ins = instruction_re.match(line)
|
ins = instruction_re.match(line)
|
||||||
label = label_re.match(line)
|
label = label_re.match(line)
|
||||||
|
print(line)
|
||||||
if label:
|
if label:
|
||||||
label_name = label.group(1)
|
label_name = label.group(1)
|
||||||
|
print("APPENDING {} TO {}".format(code[i], self.name))
|
||||||
self.instructions.append(VMInstruction(code[i+1], label_name))
|
self.instructions.append(VMInstruction(code[i+1], label_name))
|
||||||
i += 2
|
i += 2
|
||||||
elif ins:
|
elif ins:
|
||||||
|
print("APPENDING {} TO {}".format(code[i], self.name))
|
||||||
self.instructions.append(VMInstruction(line))
|
self.instructions.append(VMInstruction(line))
|
||||||
|
else:
|
||||||
|
raise InvalidOperation(line)
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
self.calc_size()
|
self.calc_size()
|
||||||
|
|
||||||
def calc_size(self):
|
def calc_size(self):
|
||||||
@ -319,7 +324,9 @@ class VMInstruction:
|
|||||||
raise InvalidOperation(opcode)
|
raise InvalidOperation(opcode)
|
||||||
|
|
||||||
args = [x for x in ins.groups()[1:] if x is not None]
|
args = [x for x in ins.groups()[1:] if x is not None]
|
||||||
|
print(args)
|
||||||
for a in args:
|
for a in args:
|
||||||
|
print(a)
|
||||||
if immediate_re.match(a) or symcall:
|
if immediate_re.match(a) or symcall:
|
||||||
# directly append the immediate
|
# directly append the immediate
|
||||||
self.args.append(VMComponent(a, a))
|
self.args.append(VMComponent(a, a))
|
||||||
@ -443,7 +450,7 @@ ops = [VMComponent(le[0], i, le[1]) for i, le in enumerate(op_names)]
|
|||||||
regs = [VMComponent(s.casefold(), i) for i, s in enumerate(reg_names)]
|
regs = [VMComponent(s.casefold(), i) for i, s in enumerate(reg_names)]
|
||||||
instruction_re = re.compile("^([\w]{4})(?:\ +(?:([\w]+)\ *(?:,[\ ]*([\w]+))*))?$") # 1: opcode 2+: args
|
instruction_re = re.compile("^([\w]{4})(?:\ +(?:([\w]+)\ *(?:,[\ ]*([\w]+))*))?$") # 1: opcode 2+: args
|
||||||
function_re = re.compile("(?:def\ )([a-zA-Z]*)\:")
|
function_re = re.compile("(?:def\ )([a-zA-Z]*)\:")
|
||||||
immediate_re = re.compile("(?:0x)?[0-9]*[0-9]$")
|
immediate_re = re.compile("(?:0x)?[0-9a-fA-F]+$")
|
||||||
alpha_re = re.compile("^[a-zA-Z]*$")
|
alpha_re = re.compile("^[a-zA-Z]*$")
|
||||||
register_re = re.compile("(^[rRsS][0-4]$)|([iIrRsS][pP]$)")
|
register_re = re.compile("(^[rRsS][0-4]$)|([iIrRsS][pP]$)")
|
||||||
label_re = re.compile("^([a-zA-Z]+)\:$")
|
label_re = re.compile("^([a-zA-Z]+)\:$")
|
||||||
|
Loading…
Reference in New Issue
Block a user