From 9898d7f6254117a2eefecea11ad51a68a8558b8b Mon Sep 17 00:00:00 2001 From: zkronos73 Date: Mon, 12 Dec 2022 10:26:32 +0000 Subject: [PATCH 1/3] fix and update version --- build/zkasm_parser.js | 6 +++--- package.json | 2 +- src/zkasm_parser.jison | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build/zkasm_parser.js b/build/zkasm_parser.js index 1b970a9..5066a1f 100644 --- a/build/zkasm_parser.js +++ b/build/zkasm_parser.js @@ -441,17 +441,17 @@ case 97: break; case 98: - this.$ = {JMP: 0, JMPC: 0, JMPN: 0, offset: $$[$0-3], ind: 0, indRR: 1, call: 1} + this.$ = {JMP: 0, JMPC: 0, JMPN: 0, offset: $$[$0-3], ind: 0, indRR: 1, return: 0, call: 1} break; case 99: - this.$ = {JMP: 0, JMPC: 0, JMPN: 0, offset: $$[$0-3], ind: 1, indRR: 0, call: 1} + this.$ = {JMP: 0, JMPC: 0, JMPN: 0, offset: $$[$0-3], ind: 1, indRR: 0, return: 0, call: 1} break; case 100: - this.$ = {JMP: 0, JMPC: 0, JMPN: 0, ind: 0, indRR: 0, return: 1} + this.$ = {JMP: 0, JMPC: 0, JMPN: 0, call: 0, return: 1} break; case 101: diff --git a/package.json b/package.json index f606def..2ce3321 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@0xpolygonhermez/zkasmcom", - "version": "0.0.18", + "version": "0.0.19", "bin": { "zkasm": "src/zkasm.js" }, diff --git a/src/zkasm_parser.jison b/src/zkasm_parser.jison index 23ed8e6..92f6bfd 100644 --- a/src/zkasm_parser.jison +++ b/src/zkasm_parser.jison @@ -610,15 +610,15 @@ op } | CALL '(' REFERENCE '+' RR ')' { - $$ = {JMP: 0, JMPC: 0, JMPN: 0, offset: $3, ind: 0, indRR: 1, call: 1} + $$ = {JMP: 0, JMPC: 0, JMPN: 0, offset: $3, ind: 0, indRR: 1, return: 0, call: 1} } | CALL '(' REFERENCE '+' E ')' { - $$ = {JMP: 0, JMPC: 0, JMPN: 0, offset: $3, ind: 1, indRR: 0, call: 1} + $$ = {JMP: 0, JMPC: 0, JMPN: 0, offset: $3, ind: 1, indRR: 0, return: 0, call: 1} } | RETURN { - $$ = {JMP: 0, JMPC: 0, JMPN: 0, ind: 0, indRR: 0, return: 1} + $$ = {JMP: 0, JMPC: 0, JMPN: 0, call: 0, return: 1} } | ASSERT { From 1c0057951d13584a4855bf5e757aa0559165248d Mon Sep 17 00:00:00 2001 From: zkronos73 Date: Mon, 12 Dec 2022 10:52:59 +0000 Subject: [PATCH 2/3] add useElseAddr flag --- src/zkasm_parser.jison | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/zkasm_parser.jison b/src/zkasm_parser.jison index 92f6bfd..b89e1d6 100644 --- a/src/zkasm_parser.jison +++ b/src/zkasm_parser.jison @@ -538,71 +538,71 @@ op } | JMP '(' IDENTIFIER ')' { - $$ = { [$1]: 1, useJmpAddr: 1, jmpAddr: $3, elseAddr: 'next' } + $$ = { [$1]: 1, useJmpAddr: 1, jmpAddr: $3 } } | jmpCond '(' IDENTIFIER ')' { - $$ = { [$1]: 1, useJmpAddr: 1, jmpAddr: $3, elseAddr: 'next' } + $$ = { [$1]: 1, useJmpAddr: 1, jmpAddr: $3, useElseAddr: 1, elseAddr: 'next' } } | jmpCond '(' IDENTIFIER ',' IDENTIFIER ')' { - $$ = { [$1]: 1, useJmpAddr: 1, jmpAddr: $3, elseAddr: $5 } + $$ = { [$1]: 1, useJmpAddr: 1, jmpAddr: $3, useElseAddr: 1, elseAddr: $5 } } | jmpNotCond '(' IDENTIFIER ')' { - $$ = { [$1]: 1, useJmpAddr: 1, jmpAddr: 'next', elseAddr: $3 } + $$ = { [$1]: 1, useJmpAddr: 1, jmpAddr: 'next', useElseAddr: 1, elseAddr: $3 } } | jmpNotCond '(' IDENTIFIER ',' IDENTIFIER ')' { - $$ = { [$1]: 1, useJmpAddr: 1, jmpAddr: 'next', elseAddr: $3 } + $$ = { [$1]: 1, useJmpAddr: 1, jmpAddr: 'next', useElseAddr: 1, elseAddr: $3 } } | JMP '(' RR ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0, elseAddr: 0 } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0 } } | JMP '(' E ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0, elseAddr: 0 } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0 } } | JMP '(' REFERENCE '+' RR ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $3, elseAddr: 0 } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $3 } } | JMP '(' REFERENCE '+' E ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $3, elseAddr: 0 } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $3 } } | jmpCond '(' RR ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0, elseAddr: 'next' } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0, useElseAddr: 1, elseAddr: 'next' } } | jmpCond '(' E ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0, elseAddr: 'next' } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0, useElseAddr: 1, elseAddr: 'next' } } | jmpCond '(' REFERENCE '+' RR ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $3, elseAddr: 'next' } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $3, useElseAddr: 1, elseAddr: 'next' } } | jmpCond '(' REFERENCE '+' E ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $3, elseAddr: 'next' } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $3, useElseAddr: 1, elseAddr: 'next' } } | jmpCond '(' RR ',' IDENTIFIER ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0, elseAddr: $5 } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0, useElseAddr: 1, elseAddr: $5 } } | jmpCond '(' E ',' IDENTIFIER ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0, elseAddr: $5 } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0, useElseAddr: 1, elseAddr: $5 } } | jmpCond '(' REFERENCE '+' RR ',' IDENTIFIER ')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $3, elseAddr: $7 } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $3, useElseAddr: 1, elseAddr: $7 } } | jmpCond '(' REFERENCE '+' E ',' IDENTIFIER')' { - $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $3, elseAddr: $7 } + $$ = { [$1]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $3, useElseAddr: 1, elseAddr: $7 } } | CALL '(' IDENTIFIER ')' { From b0e3dcac934f62d4e5c8ece78580d1fbe586deef Mon Sep 17 00:00:00 2001 From: zkronos73 Date: Mon, 12 Dec 2022 10:53:56 +0000 Subject: [PATCH 3/3] update generate files --- build/zkasm_parser.js | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/build/zkasm_parser.js b/build/zkasm_parser.js index 5066a1f..6b78c4e 100644 --- a/build/zkasm_parser.js +++ b/build/zkasm_parser.js @@ -354,84 +354,89 @@ case 79: this.$.hashPDigest = 1; break; -case 80: case 81: +case 80: - this.$ = { [$$[$0-3]]: 1, useJmpAddr: 1, jmpAddr: $$[$0-1], elseAddr: 'next' } + this.$ = { [$$[$0-3]]: 1, useJmpAddr: 1, jmpAddr: $$[$0-1] } + +break; +case 81: + + this.$ = { [$$[$0-3]]: 1, useJmpAddr: 1, jmpAddr: $$[$0-1], useElseAddr: 1, elseAddr: 'next' } break; case 82: - this.$ = { [$$[$0-5]]: 1, useJmpAddr: 1, jmpAddr: $$[$0-3], elseAddr: $$[$0-1] } + this.$ = { [$$[$0-5]]: 1, useJmpAddr: 1, jmpAddr: $$[$0-3], useElseAddr: 1, elseAddr: $$[$0-1] } break; case 83: - this.$ = { [$$[$0-3]]: 1, useJmpAddr: 1, jmpAddr: 'next', elseAddr: $$[$0-1] } + this.$ = { [$$[$0-3]]: 1, useJmpAddr: 1, jmpAddr: 'next', useElseAddr: 1, elseAddr: $$[$0-1] } break; case 84: - this.$ = { [$$[$0-5]]: 1, useJmpAddr: 1, jmpAddr: 'next', elseAddr: $$[$0-3] } + this.$ = { [$$[$0-5]]: 1, useJmpAddr: 1, jmpAddr: 'next', useElseAddr: 1, elseAddr: $$[$0-3] } break; case 85: - this.$ = { [$$[$0-3]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0, elseAddr: 0 } + this.$ = { [$$[$0-3]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0 } break; case 86: - this.$ = { [$$[$0-3]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0, elseAddr: 0 } + this.$ = { [$$[$0-3]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0 } break; case 87: - this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $$[$0-3], elseAddr: 0 } + this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $$[$0-3] } break; case 88: - this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $$[$0-3], elseAddr: 0 } + this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $$[$0-3] } break; case 89: - this.$ = { [$$[$0-3]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0, elseAddr: 'next' } + this.$ = { [$$[$0-3]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0, useElseAddr: 1, elseAddr: 'next' } break; case 90: - this.$ = { [$$[$0-3]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0, elseAddr: 'next' } + this.$ = { [$$[$0-3]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0, useElseAddr: 1, elseAddr: 'next' } break; case 91: - this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $$[$0-3], elseAddr: 'next' } + this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $$[$0-3], useElseAddr: 1, elseAddr: 'next' } break; case 92: - this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $$[$0-3], elseAddr: 'next' } + this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $$[$0-3], useElseAddr: 1, elseAddr: 'next' } break; case 93: - this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0, elseAddr: $$[$0-1] } + this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: 0, useElseAddr: 1, elseAddr: $$[$0-1] } break; case 94: - this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0, elseAddr: $$[$0-1] } + this.$ = { [$$[$0-5]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: 0, useElseAddr: 1, elseAddr: $$[$0-1] } break; case 95: - this.$ = { [$$[$0-7]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $$[$0-5], elseAddr: $$[$0-1] } + this.$ = { [$$[$0-7]]: 1, useJmpAddr: 0, ind: 0, indRR: 1, offset: $$[$0-5], useElseAddr: 1, elseAddr: $$[$0-1] } break; case 96: - this.$ = { [$$[$0-7]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $$[$0-5], elseAddr: $$[$0-1] } + this.$ = { [$$[$0-7]]: 1, useJmpAddr: 0, ind: 1, indRR: 0, offset: $$[$0-5], useElseAddr: 1, elseAddr: $$[$0-1] } break; case 97: