orga-comp/info

53 lines
1.2 KiB
Plaintext

lenguaje orga-straight-line
prgm -> stms
stms -> stm; stm (s = s1;s2) -> compound
stms -> stms; stm -> compound
stm -> id = exp (asignacion) -> assign
exp -> numero (literal) -> number
exp -> id (idExp) -> id
exp -> exp op exp (operacion) -> opexp
op -> + (suma) -> plus
op -> - (resta) -> minus
The formal sintax represented above will no longer be
used. Conditional jumps will be added.
For this we need the notion of "blocks" Im still thinking
on how to best approach this.
prgm -> stms
compound -> block, cjump;
cjump -> if opexp do block end
block -> stm; stm..
op -> = (cmp)
lex -> parse -> semantic -> codgen
a = b + 2
=>
stmAssign('a', opexp(exp('b'), '+', exp('2')))
=>
assign('a' binop('b' + 2, scope))
=>
MOV r1, [b]
ADD r1, 0x0002
MOV a, r1
=>
MOV r1, [0xf000]
ADD r1, 0x0002
MOV 0xf001, r1
equiv representation
=>
MOV TMP, 0x0002 exp('2')
ADD TMP, [b] exp('b') '+'
MOV a, TMP
para la orga small
a = b + 2
=>
SET R1, 0x02
LOAD R2, [b]
ADD R1, R2
STR [a], R1