Dnia 19-08-2008 o 12:57:04 Davy <[EMAIL PROTECTED]> napisaƂ:
> I am learning to write a assembly language parser.
> The assembly format is like:
> MOV R1, 0 //R1 = 0
> ADD R2, R3, R4 // R2 = R3 + R3
>
> The question is, how to define the comma (,) between registers? Shall
> I define it as token or literals or something else?
>
> Any suggestion are welcome:)

I think that this is up to you.

I personally will do somethink like this:

t_COMMA = ","
t_MOV = "mov"
t_REGS = "R[0-4]+"
t_NUM = "[0-9]+"
...

def p_mov(t):
    '''mov : REGS COMMA NUM
           | REGS COMMA REGS'''
...

def p_add(t):
    '''add : REGS COMMA REGS COMMA REGS'''
...


But as far as I know ADD work in other way:
    mov eax, 123h
    mov ebx, 12h
    add eax         ; eax = eax+ebx

regards,
Marek


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ply-hack" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/ply-hack?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to