diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-10 18:40:20 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-10 18:40:20 +0100 |
commit | 7dd82c1674132e0c6ea9f81bed9b142f8d4fbd7e (patch) | |
tree | c53c988a40486f4758f34fa76e011d21894cdcab /asm/asmpars.mly | |
parent | 7a2e8c69cb4a4407261f11dd36374273d1fc5a28 (diff) | |
parent | cc00abd9e33a00d3c7acfe310bf8d6522e9a1888 (diff) | |
download | SystDigit-Projet-7dd82c1674132e0c6ea9f81bed9b142f8d4fbd7e.tar.gz SystDigit-Projet-7dd82c1674132e0c6ea9f81bed9b142f8d4fbd7e.zip |
Merge branch 'emile'
Conflicts:
asm/asmpars.mly
Diffstat (limited to 'asm/asmpars.mly')
-rw-r--r-- | asm/asmpars.mly | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/asm/asmpars.mly b/asm/asmpars.mly index 258396e..c48c9ce 100644 --- a/asm/asmpars.mly +++ b/asm/asmpars.mly @@ -40,7 +40,7 @@ %} -%token EOF,COLON,TEXT,DATA,BYTE,WORD,MINUS,MOVE,JZ,JNZ,LP,RP,HLT,ASCII,SEMIC +%token EOF,COLON,TEXT,DATA,BYTE,WORD,MINUS,MOVE,JZ,JNZ,LP,RP,HLT,ASCII,NLB %token POP,PUSH,INCRI,SHI,JJ,JAL,JR,JALR,LW,SW,LB,SB,NOT,LIL,LILZ,LIU,LIUZ,LRA,LI %token<Asm.reg> REG %token<Asm.fmt_r> ROP,RIOP @@ -53,17 +53,17 @@ %% program: - TEXT is=instr* data? EOF + NLB* TEXT NLB* is=instr* data? EOF { { text = List.flatten is; lbls = !lbls2 } } data: - DATA d=datas* { d } - + DATA NLB* d=datas* { d } + datas: - | labeld datas { () } - | BYTE n=INT { add ram n } - | WORD n=INT { add ram (2*n) } + | labeld NLB* datas { () } + | BYTE n=INT NLB+ { add ram n } + | WORD n=INT NLB+ { add ram (2*n) } labeli: id=ID COLON { lbls2 := Imap.add id (!pc,true) !lbls2 } @@ -72,9 +72,9 @@ labeld: id=ID COLON { lbls2 := Imap.add id (!ram,false) !lbls2 } instr: - | labeli i=instr { i } - | i=_instr { i } - + | labeli NLB* i=instr { i } + | i=_instr NLB+ { i } + _instr: | o=ROP r1=REG r2=REG r3=REG { add pc 2; [R (o,r1,r2,r3)] } | o=RIOP r1=REG r2=REG imm=imm @@ -134,11 +134,11 @@ _instr: add pc 2; l @ [R (Jner,5,r,0)] } | POP r=REG { add pc 4; [Lw (r,7,0); Incri (7,2)] } | PUSH r=REG { add pc 4; [Incri (7,-2); Sw (r,7,0)] } - | BYTE bs=int+ SEMIC { List.map (fun b -> add pc 1; Byte b) bs } - | WORD ws=imm+ SEMIC { List.map (fun w -> add pc 2; itw w) ws } + | BYTE bs=int+ { List.map (fun b -> add pc 1; Byte b) bs } + | WORD ws=imm+ { List.map (fun w -> add pc 2; itw w) ws } | HLT { add pc 2; [Hlt] } | ASCII s=STR { List.map (fun c -> add pc 1; Byte (Char.code c)) s } - + imm: | id=ID { Lab id } | n=int { Imm n } |