HY.I'm trying to make a parser using JavaCC (an assembler) to transform from assembly code (Microcontroller 8051) to Machine COde.I have read about the javaCC grammar and the way it is structured but i have a dilemma.For example I have the ADD
instruction:
`ADD A,Rn` or `ADD A,@Ri`
and for each of them i have a Machine code (hexa code)ex: ADD A,R0
translates to 28H .
And also i can have the MOV
instruction :
MOV A,Rn
or MOV A,@Ri
but i aloso have MOV data_addr,Rn
and MOV R6,#data
and so on .
Now my problem is how do i make this difference between 2 instructions.Supose i define my tokens like this:
Token{
<IN_MOV :"mov">
|<IN_ADD:"add"
}
i couldn't define functions for each token a function to specify a specific behavior because i have many instructions.To say that token.image==.equals("mov"), then go on one direction to the specific behaviour
it is a little much , don't you think?....so i`m pretty much stuck.I don't know wich way to go .
Thx for the help.!