diff --git a/grammar/tezos/Michelson.ne b/grammar/tezos/Michelson.ne index b4e4a8dc..15d63807 100644 --- a/grammar/tezos/Michelson.ne +++ b/grammar/tezos/Michelson.ne @@ -33,9 +33,9 @@ const lexer = moo.compile({ parameter: [ 'parameter' , 'Parameter'], storage: ['Storage', 'storage'], code: ['Code', 'code'], - comparableType: ['int', 'nat', 'string', 'bytes', 'mutez', 'bool', 'key_hash', 'timestamp', 'chain_id'], - constantType: ['key', 'unit', 'signature', 'operation', 'address'], - singleArgType: ['option', 'list', 'set', 'contract'], + comparableType: ['int', 'nat', 'string', 'bytes', 'mutez', 'bool', 'key_hash', 'timestamp', 'chain_id', /* Edo types*/ 'never'], + constantType: ['key', 'unit', 'signature', 'operation', 'address', /* Edo types */ 'bls12_381_fr', 'bls12_381_g1', 'bls12_381_g2'], + singleArgType: ['option', 'list', 'set', 'contract', 'ticket'], doubleArgType: ['pair', 'or', 'lambda', 'map', 'big_map'], baseInstruction: ['ABS', 'ADD', 'ADDRESS', 'AMOUNT', 'AND', 'BALANCE', 'BLAKE2B', 'CAR', 'CAST', 'CDR', 'CHECK_SIGNATURE', 'COMPARE', 'CONCAT', 'CONS', 'CONTRACT', /*'CREATE_CONTRACT',*/ 'DIP', /*'DROP',*/ /*'DUP',*/ 'EDIV', /*'EMPTY_MAP',*/ @@ -48,7 +48,9 @@ const lexer = moo.compile({ 'IF_SOME', // TODO: macro 'IFCMPEQ', 'IFCMPNEQ', 'IFCMPLT', 'IFCMPGT', 'IFCMPLE', 'IFCMPGE', 'CMPEQ', 'CMPNEQ', 'CMPLT', 'CMPGT', 'CMPLE', 'CMPGE', 'IFEQ', 'NEQ', 'IFLT', 'IFGT', 'IFLE', 'IFGE', // TODO: should be separate - /*'DIG',*/ /*'DUG',*/ 'EMPTY_BIG_MAP', 'APPLY', 'CHAIN_ID' + /*'DIG',*/ /*'DUG',*/ 'EMPTY_BIG_MAP', 'APPLY', 'CHAIN_ID', + // Edo instructions + 'KECCAK', 'SHA3', 'PAIRING_CHECK', 'SAPLING_EMPTY_STATE', 'SAPLING_VERIFY_UPDATE', 'GET_AND_UPDATE', 'NEVER', 'VOTING_POWER', 'TOTAL_VOTING_POWER', 'TICKET', 'READ_TICKET', 'SPLIT_TICKET', 'JOIN_TICKETS', 'SELF_ADDRESS', 'LEVEL' ], macroCADR: macroCADRconst, macroDIP: macroDIPconst, @@ -94,6 +96,10 @@ type -> | %lparen _ %constantType (_ %annot):+ _ %rparen {% comparableTypeToJson %} | %lparen _ %singleArgType (_ %annot):+ _ type %rparen {% singleArgTypeKeywordWithParenToJson %} | %lparen _ %doubleArgType (_ %annot):+ _ type _ type %rparen {% doubleArgTypeKeywordWithParenToJson %} + | %lparen _ "sapling_state" (_ %annot):+ _ %number %rparen {% saplingToJson %} + | %lparen _ "sapling_transaction" (_ %annot):+ _ %number %rparen {% saplingToJson %} + | %lparen _ "sapling_state" _ %number %rparen {% saplingToJson %} + | %lparen _ "sapling_transaction" _ %number %rparen {% saplingToJson %} typeData -> %singleArgType _ typeData {% singleArgKeywordToJson %} @@ -494,7 +500,7 @@ semicolons -> [;]:? const singleArgInstrKeywordToJson = d => { const word = `${d[0].toString()}` if (check_dip(word)) { - return expandDIP(word, d[2]) + return expandDIP(word, d[2]); } else { return `{ "prim": "${d[0]}", "args": [ [ ${d[2]} ] ] }`; /*TODO: [] double-wrapping here is Bad*/ } @@ -524,7 +530,7 @@ semicolons -> [;]:? const doubleArgKeywordToJson = d => { if (d.length === 7) { /* - This handles the case where a blank {} for %subInstuction should be blank, but for %data they should be an empty array, see TODO about double-wrapping + This handles the case where a blank {} for %subInstruction should be blank, but for %data they should be an empty array, see TODO about double-wrapping */ return `{ "prim": "${d[0]}", "args": [ ${d[2]}, [] ] }`; } else { @@ -608,6 +614,14 @@ semicolons -> [;]:? return `{ "prim": "PUSH", "args": [ ${d[3]}, ${d[5]} ], "annots": [${annot}] }`; } + const saplingToJson = d => { + if (d.length == 7) { // if there exists an annotation + const annot = d[3].map(x => `"${x[1]}"`); + return `{ "prim": "${d[2]}", "args": [ { "int": "${d[5]}" } ], "annots": [${annot}] }`; + } else + return `{ "prim": "${d[2]}", "args": [ { "int": "${d[4]}" } ] }`; + } + const dipnToJson = d => (d.length > 4) ? `{ "prim": "${d[0]}", "args": [ { "int": "${d[2]}" }, [ ${d[4]} ] ] }` : `{ "prim": "${d[0]}", "args": [ ${d[2]} ] }`; const dupnToJson = d => { diff --git a/src/chain/tezos/lexer/Michelson.ts b/src/chain/tezos/lexer/Michelson.ts index 5c4c026e..ba9ce678 100644 --- a/src/chain/tezos/lexer/Michelson.ts +++ b/src/chain/tezos/lexer/Michelson.ts @@ -62,9 +62,9 @@ const lexer = moo.compile({ parameter: [ 'parameter' , 'Parameter'], storage: ['Storage', 'storage'], code: ['Code', 'code'], - comparableType: ['int', 'nat', 'string', 'bytes', 'mutez', 'bool', 'key_hash', 'timestamp', 'chain_id'], - constantType: ['key', 'unit', 'signature', 'operation', 'address'], - singleArgType: ['option', 'list', 'set', 'contract'], + comparableType: ['int', 'nat', 'string', 'bytes', 'mutez', 'bool', 'key_hash', 'timestamp', 'chain_id', /* Edo types*/ 'never'], + constantType: ['key', 'unit', 'signature', 'operation', 'address', /* Edo types */ 'bls12_381_fr', 'bls12_381_g1', 'bls12_381_g2'], + singleArgType: ['option', 'list', 'set', 'contract', 'ticket'], doubleArgType: ['pair', 'or', 'lambda', 'map', 'big_map'], baseInstruction: ['ABS', 'ADD', 'ADDRESS', 'AMOUNT', 'AND', 'BALANCE', 'BLAKE2B', 'CAR', 'CAST', 'CDR', 'CHECK_SIGNATURE', 'COMPARE', 'CONCAT', 'CONS', 'CONTRACT', /*'CREATE_CONTRACT',*/ 'DIP', /*'DROP',*/ /*'DUP',*/ 'EDIV', /*'EMPTY_MAP',*/ @@ -77,7 +77,9 @@ const lexer = moo.compile({ 'IF_SOME', // TODO: macro 'IFCMPEQ', 'IFCMPNEQ', 'IFCMPLT', 'IFCMPGT', 'IFCMPLE', 'IFCMPGE', 'CMPEQ', 'CMPNEQ', 'CMPLT', 'CMPGT', 'CMPLE', 'CMPGE', 'IFEQ', 'NEQ', 'IFLT', 'IFGT', 'IFLE', 'IFGE', // TODO: should be separate - /*'DIG',*/ /*'DUG',*/ 'EMPTY_BIG_MAP', 'APPLY', 'CHAIN_ID' + /*'DIG',*/ /*'DUG',*/ 'EMPTY_BIG_MAP', 'APPLY', 'CHAIN_ID', + // Edo instructions + 'KECCAK', 'SHA3', 'PAIRING_CHECK', 'SAPLING_EMPTY_STATE', 'SAPLING_VERIFY_UPDATE', 'GET_AND_UPDATE', 'NEVER', 'VOTING_POWER', 'TOTAL_VOTING_POWER', 'TICKET', 'READ_TICKET', 'SPLIT_TICKET', 'JOIN_TICKETS', 'SELF_ADDRESS', 'LEVEL' ], macroCADR: macroCADRconst, macroDIP: macroDIPconst, @@ -393,7 +395,7 @@ const lexer = moo.compile({ const singleArgInstrKeywordToJson = d => { const word = `${d[0].toString()}` if (check_dip(word)) { - return expandDIP(word, d[2]) + return expandDIP(word, d[2]); } else { return `{ "prim": "${d[0]}", "args": [ [ ${d[2]} ] ] }`; /*TODO: [] double-wrapping here is Bad*/ } @@ -423,7 +425,7 @@ const lexer = moo.compile({ const doubleArgKeywordToJson = d => { if (d.length === 7) { /* - This handles the case where a blank {} for %subInstuction should be blank, but for %data they should be an empty array, see TODO about double-wrapping + This handles the case where a blank {} for %subInstruction should be blank, but for %data they should be an empty array, see TODO about double-wrapping */ return `{ "prim": "${d[0]}", "args": [ ${d[2]}, [] ] }`; } else { @@ -507,6 +509,14 @@ const lexer = moo.compile({ return `{ "prim": "PUSH", "args": [ ${d[3]}, ${d[5]} ], "annots": [${annot}] }`; } + const saplingToJson = d => { + if (d.length == 7) { // if there exists an annotation + const annot = d[3].map(x => `"${x[1]}"`); + return `{ "prim": "${d[2]}", "args": [ { "int": "${d[5]}" } ], "annots": [${annot}] }`; + } else + return `{ "prim": "${d[2]}", "args": [ { "int": "${d[4]}" } ] }`; + } + const dipnToJson = d => (d.length > 4) ? `{ "prim": "${d[0]}", "args": [ { "int": "${d[2]}" }, [ ${d[4]} ] ] }` : `{ "prim": "${d[0]}", "args": [ ${d[2]} ] }`; const dupnToJson = d => { @@ -616,6 +626,18 @@ const grammar: Grammar = { {"name": "type$ebnf$6$subexpression$2", "symbols": ["_", (lexer.has("annot") ? {type: "annot"} : annot)]}, {"name": "type$ebnf$6", "symbols": ["type$ebnf$6", "type$ebnf$6$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])}, {"name": "type", "symbols": [(lexer.has("lparen") ? {type: "lparen"} : lparen), "_", (lexer.has("doubleArgType") ? {type: "doubleArgType"} : doubleArgType), "type$ebnf$6", "_", "type", "_", "type", (lexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": doubleArgTypeKeywordWithParenToJson}, + {"name": "type$ebnf$7$subexpression$1", "symbols": ["_", (lexer.has("annot") ? {type: "annot"} : annot)]}, + {"name": "type$ebnf$7", "symbols": ["type$ebnf$7$subexpression$1"]}, + {"name": "type$ebnf$7$subexpression$2", "symbols": ["_", (lexer.has("annot") ? {type: "annot"} : annot)]}, + {"name": "type$ebnf$7", "symbols": ["type$ebnf$7", "type$ebnf$7$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])}, + {"name": "type", "symbols": [(lexer.has("lparen") ? {type: "lparen"} : lparen), "_", {"literal":"sapling_state"}, "type$ebnf$7", "_", (lexer.has("number") ? {type: "number"} : number), (lexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": saplingToJson}, + {"name": "type$ebnf$8$subexpression$1", "symbols": ["_", (lexer.has("annot") ? {type: "annot"} : annot)]}, + {"name": "type$ebnf$8", "symbols": ["type$ebnf$8$subexpression$1"]}, + {"name": "type$ebnf$8$subexpression$2", "symbols": ["_", (lexer.has("annot") ? {type: "annot"} : annot)]}, + {"name": "type$ebnf$8", "symbols": ["type$ebnf$8", "type$ebnf$8$subexpression$2"], "postprocess": (d) => d[0].concat([d[1]])}, + {"name": "type", "symbols": [(lexer.has("lparen") ? {type: "lparen"} : lparen), "_", {"literal":"sapling_transaction"}, "type$ebnf$8", "_", (lexer.has("number") ? {type: "number"} : number), (lexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": saplingToJson}, + {"name": "type", "symbols": [(lexer.has("lparen") ? {type: "lparen"} : lparen), "_", {"literal":"sapling_state"}, "_", (lexer.has("number") ? {type: "number"} : number), (lexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": saplingToJson}, + {"name": "type", "symbols": [(lexer.has("lparen") ? {type: "lparen"} : lparen), "_", {"literal":"sapling_transaction"}, "_", (lexer.has("number") ? {type: "number"} : number), (lexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": saplingToJson}, {"name": "typeData", "symbols": [(lexer.has("singleArgType") ? {type: "singleArgType"} : singleArgType), "_", "typeData"], "postprocess": singleArgKeywordToJson}, {"name": "typeData", "symbols": [(lexer.has("lparen") ? {type: "lparen"} : lparen), "_", (lexer.has("singleArgType") ? {type: "singleArgType"} : singleArgType), "_", "typeData", "_", (lexer.has("rparen") ? {type: "rparen"} : rparen)], "postprocess": singleArgKeywordWithParenToJson}, {"name": "typeData", "symbols": [(lexer.has("doubleArgType") ? {type: "doubleArgType"} : doubleArgType), "_", "typeData", "_", "typeData"], "postprocess": doubleArgKeywordToJson}, diff --git a/test/chain/tezos/lexer/samples/p008-bls12-381/bls12-381.hex b/test/chain/tezos/lexer/samples/p008-opcodes/bls12-381.hex similarity index 63% rename from test/chain/tezos/lexer/samples/p008-bls12-381/bls12-381.hex rename to test/chain/tezos/lexer/samples/p008-opcodes/bls12-381.hex index 511bdb6f..61e66240 100644 --- a/test/chain/tezos/lexer/samples/p008-bls12-381/bls12-381.hex +++ b/test/chain/tezos/lexer/samples/p008-opcodes/bls12-381.hex @@ -1 +1 @@ -0000025a0200000255050107650765066303590000000c25636865636b526573756c7404820000000325667207650480000000032567310765048100000003256732066303820000000a256d756c526573756c7405000764076408650482000000032566720765048000000003256731048100000003256732000000042561646408650382038200000004256d756c0764046c00000007256e65676174650764065f0765038003810000000e2570616972696e675f636865636b046c0000000625746f496e740502020000019103210317034c0316072e02000000b4072e0200000078034c03210316034c031703210317034c0316057000030321057100040317031603120342034c034203210316034c031703210316034c031703210317034c0316057000040321057100050317031703120342034c0342034c034203210317034c031603210316034c03170570000303160312034c034203420200000030034c03210316034c031703210316034c031703160570000303210317034c0316033a0346034c0342034c0342034c034202000000c3072e020000001e0320032103210316034c031703170570000203170316033b0342034c03420200000099072e0200000018034c03210317034c0316031705700002037f0346034203420200000075032003210316031703300743035b008080808080808080808080808080808080808080808080808080808080aebfbbd5fc95da0903190325072c020000000002000000310743036801000000264661696c656420746f2063617374206669656c6420656c656d656e7420467220746f20496e740327053d036d0342 +0000025a020000025505000764076408650482000000032566720765048000000003256731048100000003256732000000042561646408650382038200000004256d756c0764046c00000007256e65676174650764065f0765038003810000000e2570616972696e675f636865636b046c0000000625746f496e74050107650765066303590000000c25636865636b526573756c7404820000000325667207650480000000032567310765048100000003256732066303820000000a256d756c526573756c740502020000019103210317034c0316072e02000000b4072e0200000078034c03210316034c031703210317034c0316057000030321057100040317031603120342034c034203210316034c031703210316034c031703210317034c0316057000040321057100050317031703120342034c0342034c034203210317034c031603210316034c03170570000303160312034c034203420200000030034c03210316034c031703210316034c031703160570000303210317034c0316033a0346034c0342034c0342034c034202000000c3072e020000001e0320032103210316034c031703170570000203170316033b0342034c03420200000099072e0200000018034c03210317034c0316031705700002037f0346034203420200000075032003210316031703300743035b008080808080808080808080808080808080808080808080808080808080aebfbbd5fc95da0903190325072c020000000002000000310743036801000000264661696c656420746f2063617374206669656c6420656c656d656e7420467220746f20496e740327053d036d0342 diff --git a/test/chain/tezos/lexer/samples/p008-bls12-381/bls12-381.micheline b/test/chain/tezos/lexer/samples/p008-opcodes/bls12-381.micheline similarity index 99% rename from test/chain/tezos/lexer/samples/p008-bls12-381/bls12-381.micheline rename to test/chain/tezos/lexer/samples/p008-opcodes/bls12-381.micheline index ec5060e8..4b0990dc 100644 --- a/test/chain/tezos/lexer/samples/p008-bls12-381/bls12-381.micheline +++ b/test/chain/tezos/lexer/samples/p008-opcodes/bls12-381.micheline @@ -1,25 +1,4 @@ [ - { - "prim": "storage", - "args": [ - { - "prim": "pair", - "args": [ - { "prim": "pair", "args": [ { "prim": "option", "args": [ { "prim": "bool" } ], "annots": [ "%checkResult" ] }, { "prim": "bls12_381_fr", "annots": [ "%fr" ] } ] }, - { - "prim": "pair", - "args": [ - { "prim": "bls12_381_g1", "annots": [ "%g1" ] }, - { - "prim": "pair", - "args": [ { "prim": "bls12_381_g2", "annots": [ "%g2" ] }, { "prim": "option", "args": [ { "prim": "bls12_381_fr" } ], "annots": [ "%mulResult" ] } ] - } - ] - } - ] - } - ] - }, { "prim": "parameter", "args": [ @@ -57,6 +36,27 @@ } ] }, + { + "prim": "storage", + "args": [ + { + "prim": "pair", + "args": [ + { "prim": "pair", "args": [ { "prim": "option", "args": [ { "prim": "bool" } ], "annots": [ "%checkResult" ] }, { "prim": "bls12_381_fr", "annots": [ "%fr" ] } ] }, + { + "prim": "pair", + "args": [ + { "prim": "bls12_381_g1", "annots": [ "%g1" ] }, + { + "prim": "pair", + "args": [ { "prim": "bls12_381_g2", "annots": [ "%g2" ] }, { "prim": "option", "args": [ { "prim": "bls12_381_fr" } ], "annots": [ "%mulResult" ] } ] + } + ] + } + ] + } + ] + }, { "prim": "code", "args": [ @@ -224,4 +224,4 @@ ] ] } -] \ No newline at end of file +] diff --git a/test/chain/tezos/lexer/samples/p008-bls12-381/bls12-381.michelson b/test/chain/tezos/lexer/samples/p008-opcodes/bls12-381.michelson similarity index 100% rename from test/chain/tezos/lexer/samples/p008-bls12-381/bls12-381.michelson rename to test/chain/tezos/lexer/samples/p008-opcodes/bls12-381.michelson diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/hashes.hex b/test/chain/tezos/lexer/samples/p008-opcodes/hashes.hex new file mode 100644 index 00000000..ba7e7a26 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/hashes.hex @@ -0,0 +1 @@ +00000052020000004d0500036905010765046900000007256b656363616b04690000000525736861330502020000002603210316034c03170317034c032105710002037d0342034c037e034c03160342053d036d0342 \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/hashes.micheline b/test/chain/tezos/lexer/samples/p008-opcodes/hashes.micheline new file mode 100644 index 00000000..740d1097 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/hashes.micheline @@ -0,0 +1,28 @@ +[ + { "prim": "parameter", "args": [ { "prim": "bytes" } ] }, + { "prim": "storage", "args": [ { "prim": "pair", "args": [ { "prim": "bytes", "annots": [ "%keccak" ] }, { "prim": "bytes", "annots": [ "%sha3" ] } ] } ] }, + { + "prim": "code", + "args": [ + [ + { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "SWAP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "KECCAK" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "SHA3" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "PAIR" }, + { "prim": "NIL", "args": [ { "prim": "operation" } ] }, + { "prim": "PAIR" } + ] + ] + } +] diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/hashes.michelson b/test/chain/tezos/lexer/samples/p008-opcodes/hashes.michelson new file mode 100644 index 00000000..f149ed37 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/hashes.michelson @@ -0,0 +1,25 @@ +parameter bytes; +storage (pair (bytes %keccak) (bytes %sha3)); +code + { + DUP; # pair @parameter @storage : pair @parameter @storage + CAR; # @parameter : pair @parameter @storage + SWAP; # pair @parameter @storage : @parameter + CDR; # @storage : @parameter + # == new_value == + # self.data.keccak = sp.keccak(params) # @storage : @parameter + CDR; # bytes : @parameter + SWAP; # @parameter : bytes + DUP; # @parameter : @parameter : bytes + DUG 2; # @parameter : bytes : @parameter + KECCAK; # bytes : bytes : @parameter + PAIR; # pair bytes bytes : @parameter + SWAP; # @parameter : pair bytes bytes + # self.data.sha3 = sp.sha3(params) # @parameter : pair bytes bytes + SHA3; # bytes : pair bytes bytes + SWAP; # pair bytes bytes : bytes + CAR; # bytes : bytes + PAIR; # pair bytes bytes + NIL operation; # list operation : pair bytes bytes + PAIR; # pair (list operation) (pair bytes bytes) + }; \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/level.hex b/test/chain/tezos/lexer/samples/p008-opcodes/level.hex new file mode 100644 index 00000000..6beac112 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/level.hex @@ -0,0 +1 @@ +0000001e02000000190500036c050103620502020000000a03200376053d036d0342 diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/level.micheline b/test/chain/tezos/lexer/samples/p008-opcodes/level.micheline new file mode 100644 index 00000000..45ce3eae --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/level.micheline @@ -0,0 +1,5 @@ +[ + { "prim": "parameter", "args": [ { "prim": "unit" } ] }, + { "prim": "storage", "args": [ { "prim": "nat" } ] }, + { "prim": "code", "args": [ [ { "prim": "DROP" }, { "prim": "LEVEL" }, { "prim": "NIL", "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } +] diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/level.michelson b/test/chain/tezos/lexer/samples/p008-opcodes/level.michelson new file mode 100644 index 00000000..8bd66796 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/level.michelson @@ -0,0 +1,11 @@ +parameter unit; +storage nat; +code + { + DROP; # + # == entry_point_1 == + # self.data.level = sp.level # + LEVEL; # nat + NIL operation; # list operation : nat + PAIR; # pair (list operation) nat + }; \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/maps.hex b/test/chain/tezos/lexer/samples/p008-opcodes/maps.hex new file mode 100644 index 00000000..cdfd2d70 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/maps.hex @@ -0,0 +1 @@ +0000033502000003300500076407640764046c0000001425746573745f6765745f616e645f7570646174650860035b03680000000d25746573745f6d61705f67657407640860035b03680000000e25746573745f6d61705f676574320860035b03680000001c25746573745f6d61705f6765745f64656661756c745f76616c756573076407640860035b03680000001b25746573745f6d61705f6765745f6d697373696e675f76616c75650860035b03680000001c25746573745f6d61705f6765745f6d697373696e675f76616c75653207640860035b03680000001125746573745f6d61705f6765745f6f7074046c0000001025746573745f7570646174655f6d61700501076507650860035b036800000002256d04680000000225780765066303680000000225790663036800000002257a050202000001fe03210317034c0316072e0200000102072e0200000082072e0200000044034c03210571000203160316074305630368050901000000036f6e650743035b0001038c034c0320034c0320034c03210316034c0317031605700002034c0342034c03420200000032034c03210317034c03160316057000020743035b000c0329072f02000000080743035b000c03270200000000034c034203420200000074072e0200000032034c03210317034c03160316057000020743035b000c0329072f02000000080743035b001103270200000000034c034203420200000036034c03210317034c03160316057000020743035b000c0329072f020000000c0743036801000000036162630200000000034c0342034202000000e2072e020000007e072e020000003f034c03210317034c03160316057000020743035b000c0329072f020000001507430368010000000a6d697373696e6720313203270200000000034c034203420200000033034c03210317034c03160316057000020743035b000c0329072f02000000090743035b00921303270200000000034c034203420200000058072e020000001e034c03210316034c03170317057000020743035b000c03290342034c0342020000002e032003210317034c031603210317034c0316074305630368050901000000036f6e650743035b0001035003420342053d036d0342 \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/maps.micheline b/test/chain/tezos/lexer/samples/p008-opcodes/maps.micheline new file mode 100644 index 00000000..f1387c7b --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/maps.micheline @@ -0,0 +1,255 @@ +[ + { + "prim": "parameter", + "args": [ + { + "prim": "or", + "args": [ + { + "prim": "or", + "args": [ + { + "prim": "or", + "args": [ + { "prim": "unit", "annots": [ "%test_get_and_update" ] }, + { "prim": "map", "args": [ { "prim": "int" }, { "prim": "string" } ], "annots": [ "%test_map_get" ] } + ] + }, + { + "prim": "or", + "args": [ + { "prim": "map", "args": [ { "prim": "int" }, { "prim": "string" } ], "annots": [ "%test_map_get2" ] }, + { "prim": "map", "args": [ { "prim": "int" }, { "prim": "string" } ], "annots": [ "%test_map_get_default_values" ] } + ] + } + ] + }, + { + "prim": "or", + "args": [ + { + "prim": "or", + "args": [ + { "prim": "map", "args": [ { "prim": "int" }, { "prim": "string" } ], "annots": [ "%test_map_get_missing_value" ] }, + { "prim": "map", "args": [ { "prim": "int" }, { "prim": "string" } ], "annots": [ "%test_map_get_missing_value2" ] } + ] + }, + { + "prim": "or", + "args": [ + { "prim": "map", "args": [ { "prim": "int" }, { "prim": "string" } ], "annots": [ "%test_map_get_opt" ] }, + { "prim": "unit", "annots": [ "%test_update_map" ] } + ] + } + ] + } + ] + } + ] + }, + { + "prim": "storage", + "args": [ + { + "prim": "pair", + "args": [ + { "prim": "pair", "args": [ { "prim": "map", "args": [ { "prim": "int" }, { "prim": "string" } ], "annots": [ "%m" ] }, { "prim": "string", "annots": [ "%x" ] } ] }, + { + "prim": "pair", + "args": [ { "prim": "option", "args": [ { "prim": "string" } ], "annots": [ "%y" ] }, { "prim": "option", "args": [ { "prim": "string" } ], "annots": [ "%z" ] } ] + } + ] + } + ] + }, + { + "prim": "code", + "args": [ + [ + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { + "prim": "IF_LEFT", + "args": [ + [ + { + "prim": "IF_LEFT", + "args": [ + [ + { + "prim": "IF_LEFT", + "args": [ + [ + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "PUSH", "args": [ { "prim": "option", "args": [ { "prim": "string" } ] }, { "prim": "Some", "args": [ { "string": "one" } ] } ] }, + { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "1" } ] }, + { "prim": "GET_AND_UPDATE" }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "SWAP" }, + { "prim": "CDR" }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" } + ], + [ + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "12" } ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", "args": [ [ { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "12" } ] }, { "prim": "FAILWITH" } ], [] ] }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" } + ] + ] + } + ], + [ + { + "prim": "IF_LEFT", + "args": [ + [ + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "12" } ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", "args": [ [ { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "17" } ] }, { "prim": "FAILWITH" } ], [] ] }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" } + ], + [ + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "12" } ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", "args": [ [ { "prim": "PUSH", "args": [ { "prim": "string" }, { "string": "abc" } ] } ], [] ] }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" } + ] + ] + } + ] + ] + } + ], + [ + { + "prim": "IF_LEFT", + "args": [ + [ + { + "prim": "IF_LEFT", + "args": [ + [ + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "12" } ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", "args": [ [ { "prim": "PUSH", "args": [ { "prim": "string" }, { "string": "missing 12" } ] }, { "prim": "FAILWITH" } ], [] ] }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" } + ], + [ + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "12" } ] }, + { "prim": "GET" }, + { "prim": "IF_NONE", "args": [ [ { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "1234" } ] }, { "prim": "FAILWITH" } ], [] ] }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" } + ] + ] + } + ], + [ + { + "prim": "IF_LEFT", + "args": [ + [ + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "SWAP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "12" } ] }, + { "prim": "GET" }, + { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" } + ], + [ + { "prim": "DROP" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "PUSH", "args": [ { "prim": "option", "args": [ { "prim": "string" } ] }, { "prim": "Some", "args": [ { "string": "one" } ] } ] }, + { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "1" } ] }, + { "prim": "UPDATE" }, + { "prim": "PAIR" }, + { "prim": "PAIR" } + ] + ] + } + ] + ] + } + ] + ] + }, + { "prim": "NIL", "args": [ { "prim": "operation" } ] }, + { "prim": "PAIR" } + ] + ] + } +] diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/maps.michelson b/test/chain/tezos/lexer/samples/p008-opcodes/maps.michelson new file mode 100644 index 00000000..869aab9b --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/maps.michelson @@ -0,0 +1,211 @@ +parameter (or (or (or (unit %test_get_and_update) (map %test_map_get int string)) (or (map %test_map_get2 int string) (map %test_map_get_default_values int string))) (or (or (map %test_map_get_missing_value int string) (map %test_map_get_missing_value2 int string)) (or (map %test_map_get_opt int string) (unit %test_update_map)))); +storage (pair (pair (map %m int string) (string %x)) (pair (option %y string) (option %z string))); +code + { + DUP; # pair @parameter @storage : pair @parameter @storage + CDR; # @storage : pair @parameter @storage + SWAP; # pair @parameter @storage : @storage + CAR; # @parameter : @storage + IF_LEFT + { + IF_LEFT + { + IF_LEFT + { + SWAP; # @storage : @parameter%test_get_and_update + # == test_get_and_update == + # match_pair_46_fst, match_pair_46_snd = sp.match_tuple(sp.get_and_update(self.data.m, 1, sp.some('one')), names = [ "match_pair_46_fst", "match_pair_46_snd" ]) # @storage : @parameter%test_get_and_update + DUP; # @storage : @storage : @parameter%test_get_and_update + DUG 2; # @storage : @parameter%test_get_and_update : @storage + CAR; # pair (map %m int string) (string %x) : @parameter%test_get_and_update : @storage + CAR; # map int string : @parameter%test_get_and_update : @storage + PUSH (option string) (Some "one"); # option string : map int string : @parameter%test_get_and_update : @storage + PUSH int 1; # int : option string : map int string : @parameter%test_get_and_update : @storage + GET_AND_UPDATE; # option string : map int string : @parameter%test_get_and_update : @storage + SWAP; # map int string : option string : @parameter%test_get_and_update : @storage + DROP; # option string : @parameter%test_get_and_update : @storage + SWAP; # @parameter%test_get_and_update : option string : @storage + DROP; # option string : @storage + SWAP; # @storage : option string + # self.data.z = match_pair_46_fst # @storage : option string + DUP; # @storage : @storage : option string + CAR; # pair (map %m int string) (string %x) : @storage : option string + SWAP; # @storage : pair (map %m int string) (string %x) : option string + CDR; # pair (option %y string) (option %z string) : pair (map %m int string) (string %x) : option string + CAR; # option string : pair (map %m int string) (string %x) : option string + DIG 2; # option string : option string : pair (map %m int string) (string %x) + SWAP; # option string : option string : pair (map %m int string) (string %x) + PAIR; # pair (option string) (option string) : pair (map %m int string) (string %x) + SWAP; # pair (map %m int string) (string %x) : pair (option string) (option string) + PAIR; # pair (pair (map %m int string) (string %x)) (pair (option string) (option string)) + } + { + SWAP; # @storage : @parameter%test_map_get + # == test_map_get == + # self.data.x = params[12] # @storage : @parameter%test_map_get + DUP; # @storage : @storage : @parameter%test_map_get + CDR; # pair (option %y string) (option %z string) : @storage : @parameter%test_map_get + SWAP; # @storage : pair (option %y string) (option %z string) : @parameter%test_map_get + CAR; # pair (map %m int string) (string %x) : pair (option %y string) (option %z string) : @parameter%test_map_get + CAR; # map int string : pair (option %y string) (option %z string) : @parameter%test_map_get + DIG 2; # @parameter%test_map_get : map int string : pair (option %y string) (option %z string) + PUSH int 12; # int : @parameter%test_map_get : map int string : pair (option %y string) (option %z string) + GET; # option string : map int string : pair (option %y string) (option %z string) + IF_SOME + { + # of_some: Get-item:12 # @some : map int string : pair (option %y string) (option %z string) + } + { + PUSH int 12; # int : map int string : pair (option %y string) (option %z string) + FAILWITH; # FAILED + }; # @some : map int string : pair (option %y string) (option %z string) + SWAP; # map int string : @some : pair (option %y string) (option %z string) + PAIR; # pair (map int string) @some : pair (option %y string) (option %z string) + PAIR; # pair (pair (map int string) @some) (pair (option %y string) (option %z string)) + }; # pair (pair (map %m int string) (string %x)) (pair (option string) (option string)) + } + { + IF_LEFT + { + SWAP; # @storage : @parameter%test_map_get2 + # == test_map_get2 == + # self.data.x = params[12] # @storage : @parameter%test_map_get2 + DUP; # @storage : @storage : @parameter%test_map_get2 + CDR; # pair (option %y string) (option %z string) : @storage : @parameter%test_map_get2 + SWAP; # @storage : pair (option %y string) (option %z string) : @parameter%test_map_get2 + CAR; # pair (map %m int string) (string %x) : pair (option %y string) (option %z string) : @parameter%test_map_get2 + CAR; # map int string : pair (option %y string) (option %z string) : @parameter%test_map_get2 + DIG 2; # @parameter%test_map_get2 : map int string : pair (option %y string) (option %z string) + PUSH int 12; # int : @parameter%test_map_get2 : map int string : pair (option %y string) (option %z string) + GET; # option string : map int string : pair (option %y string) (option %z string) + IF_SOME + { + # of_some: Get-item:17 # @some : map int string : pair (option %y string) (option %z string) + } + { + PUSH int 17; # int : map int string : pair (option %y string) (option %z string) + FAILWITH; # FAILED + }; # @some : map int string : pair (option %y string) (option %z string) + SWAP; # map int string : @some : pair (option %y string) (option %z string) + PAIR; # pair (map int string) @some : pair (option %y string) (option %z string) + PAIR; # pair (pair (map int string) @some) (pair (option %y string) (option %z string)) + } + { + SWAP; # @storage : @parameter%test_map_get_default_values + # == test_map_get_default_values == + # self.data.x = params.get(12, default_value = 'abc') # @storage : @parameter%test_map_get_default_values + DUP; # @storage : @storage : @parameter%test_map_get_default_values + CDR; # pair (option %y string) (option %z string) : @storage : @parameter%test_map_get_default_values + SWAP; # @storage : pair (option %y string) (option %z string) : @parameter%test_map_get_default_values + CAR; # pair (map %m int string) (string %x) : pair (option %y string) (option %z string) : @parameter%test_map_get_default_values + CAR; # map int string : pair (option %y string) (option %z string) : @parameter%test_map_get_default_values + DIG 2; # @parameter%test_map_get_default_values : map int string : pair (option %y string) (option %z string) + PUSH int 12; # int : @parameter%test_map_get_default_values : map int string : pair (option %y string) (option %z string) + GET; # option string : map int string : pair (option %y string) (option %z string) + IF_SOME + { + # of_some: Get-item:28 # @some : map int string : pair (option %y string) (option %z string) + } + { + PUSH string "abc"; # string : map int string : pair (option %y string) (option %z string) + }; # @some : map int string : pair (option %y string) (option %z string) + SWAP; # map int string : @some : pair (option %y string) (option %z string) + PAIR; # pair (map int string) @some : pair (option %y string) (option %z string) + PAIR; # pair (pair (map int string) @some) (pair (option %y string) (option %z string)) + }; # pair (pair (map int string) @some) (pair (option %y string) (option %z string)) + }; # pair (pair (map %m int string) (string %x)) (pair (option string) (option string)) + } + { + IF_LEFT + { + IF_LEFT + { + SWAP; # @storage : @parameter%test_map_get_missing_value + # == test_map_get_missing_value == + # self.data.x = params.get(12, message = 'missing 12') # @storage : @parameter%test_map_get_missing_value + DUP; # @storage : @storage : @parameter%test_map_get_missing_value + CDR; # pair (option %y string) (option %z string) : @storage : @parameter%test_map_get_missing_value + SWAP; # @storage : pair (option %y string) (option %z string) : @parameter%test_map_get_missing_value + CAR; # pair (map %m int string) (string %x) : pair (option %y string) (option %z string) : @parameter%test_map_get_missing_value + CAR; # map int string : pair (option %y string) (option %z string) : @parameter%test_map_get_missing_value + DIG 2; # @parameter%test_map_get_missing_value : map int string : pair (option %y string) (option %z string) + PUSH int 12; # int : @parameter%test_map_get_missing_value : map int string : pair (option %y string) (option %z string) + GET; # option string : map int string : pair (option %y string) (option %z string) + IF_SOME + { + # of_some: Get-item:33 # @some : map int string : pair (option %y string) (option %z string) + } + { + PUSH string "missing 12"; # string : map int string : pair (option %y string) (option %z string) + FAILWITH; # FAILED + }; # @some : map int string : pair (option %y string) (option %z string) + SWAP; # map int string : @some : pair (option %y string) (option %z string) + PAIR; # pair (map int string) @some : pair (option %y string) (option %z string) + PAIR; # pair (pair (map int string) @some) (pair (option %y string) (option %z string)) + } + { + SWAP; # @storage : @parameter%test_map_get_missing_value2 + # == test_map_get_missing_value2 == + # self.data.x = params.get(12, message = 1234) # @storage : @parameter%test_map_get_missing_value2 + DUP; # @storage : @storage : @parameter%test_map_get_missing_value2 + CDR; # pair (option %y string) (option %z string) : @storage : @parameter%test_map_get_missing_value2 + SWAP; # @storage : pair (option %y string) (option %z string) : @parameter%test_map_get_missing_value2 + CAR; # pair (map %m int string) (string %x) : pair (option %y string) (option %z string) : @parameter%test_map_get_missing_value2 + CAR; # map int string : pair (option %y string) (option %z string) : @parameter%test_map_get_missing_value2 + DIG 2; # @parameter%test_map_get_missing_value2 : map int string : pair (option %y string) (option %z string) + PUSH int 12; # int : @parameter%test_map_get_missing_value2 : map int string : pair (option %y string) (option %z string) + GET; # option string : map int string : pair (option %y string) (option %z string) + IF_SOME + { + # of_some: Get-item:38 # @some : map int string : pair (option %y string) (option %z string) + } + { + PUSH int 1234; # int : map int string : pair (option %y string) (option %z string) + FAILWITH; # FAILED + }; # @some : map int string : pair (option %y string) (option %z string) + SWAP; # map int string : @some : pair (option %y string) (option %z string) + PAIR; # pair (map int string) @some : pair (option %y string) (option %z string) + PAIR; # pair (pair (map int string) @some) (pair (option %y string) (option %z string)) + }; # pair (pair (map int string) @some) (pair (option %y string) (option %z string)) + } + { + IF_LEFT + { + SWAP; # @storage : @parameter%test_map_get_opt + # == test_map_get_opt == + # self.data.y = params.get_opt(12) # @storage : @parameter%test_map_get_opt + DUP; # @storage : @storage : @parameter%test_map_get_opt + CAR; # pair (map %m int string) (string %x) : @storage : @parameter%test_map_get_opt + SWAP; # @storage : pair (map %m int string) (string %x) : @parameter%test_map_get_opt + CDR; # pair (option %y string) (option %z string) : pair (map %m int string) (string %x) : @parameter%test_map_get_opt + CDR; # option string : pair (map %m int string) (string %x) : @parameter%test_map_get_opt + DIG 2; # @parameter%test_map_get_opt : option string : pair (map %m int string) (string %x) + PUSH int 12; # int : @parameter%test_map_get_opt : option string : pair (map %m int string) (string %x) + GET; # option string : option string : pair (map %m int string) (string %x) + PAIR; # pair (option string) (option string) : pair (map %m int string) (string %x) + SWAP; # pair (map %m int string) (string %x) : pair (option string) (option string) + PAIR; # pair (pair (map %m int string) (string %x)) (pair (option string) (option string)) + } + { + DROP; # @storage + # == test_update_map == + # self.data.m[1] = 'one' # @storage + DUP; # @storage : @storage + CDR; # pair (option %y string) (option %z string) : @storage + SWAP; # @storage : pair (option %y string) (option %z string) + CAR; # pair (map %m int string) (string %x) : pair (option %y string) (option %z string) + DUP; # pair (map %m int string) (string %x) : pair (map %m int string) (string %x) : pair (option %y string) (option %z string) + CDR; # string : pair (map %m int string) (string %x) : pair (option %y string) (option %z string) + SWAP; # pair (map %m int string) (string %x) : string : pair (option %y string) (option %z string) + CAR; # map int string : string : pair (option %y string) (option %z string) + PUSH (option string) (Some "one"); # option string : map int string : string : pair (option %y string) (option %z string) + PUSH int 1; # int : option string : map int string : string : pair (option %y string) (option %z string) + UPDATE; # map int string : string : pair (option %y string) (option %z string) + PAIR; # pair (map int string) string : pair (option %y string) (option %z string) + PAIR; # pair (pair (map int string) string) (pair (option %y string) (option %z string)) + }; # pair (pair (map %m int string) (string %x)) (pair (option string) (option string)) + }; # pair (pair (map int string) @some) (pair (option %y string) (option %z string)) + }; # pair (pair (map %m int string) (string %x)) (pair (option string) (option string)) + NIL operation; # list operation : pair (pair (map %m int string) (string %x)) (pair (option string) (option string)) + PAIR; # pair (list operation) (pair (pair (map %m int string) (string %x)) (pair (option string) (option string))) + }; \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/never.hex b/test/chain/tezos/lexer/samples/p008-opcodes/never.hex new file mode 100644 index 00000000..a469dc61 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/never.hex @@ -0,0 +1 @@ +00000042020000003d05000764045b00000002254104780000000225420501035b0502020000001e0316072e02000000080743035b000c031202000000020379053d036d0342 \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/never.micheline b/test/chain/tezos/lexer/samples/p008-opcodes/never.micheline new file mode 100644 index 00000000..8c591025 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/never.micheline @@ -0,0 +1,15 @@ +[ + { "prim": "parameter", "args": [ { "prim": "or", "args": [ { "prim": "int", "annots": [ "%A" ] }, { "prim": "never", "annots": [ "%B" ] } ] } ] }, + { "prim": "storage", "args": [ { "prim": "int" } ] }, + { + "prim": "code", + "args": [ + [ + { "prim": "CAR" }, + { "prim": "IF_LEFT", "args": [ [ { "prim": "PUSH", "args": [ { "prim": "int" }, { "int": "12" } ] }, { "prim": "ADD" } ], [ { "prim": "NEVER" } ] ] }, + { "prim": "NIL", "args": [ { "prim": "operation" } ] }, + { "prim": "PAIR" } + ] + ] + } +] diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/never.michelson b/test/chain/tezos/lexer/samples/p008-opcodes/never.michelson new file mode 100644 index 00000000..9cdd00e7 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/never.michelson @@ -0,0 +1,20 @@ +parameter (or (int %A) (never %B)); +storage int; +code + { + CAR; # @parameter + # == entry_point_1 == + # with params.match_cases(...): # @parameter + IF_LEFT + { + # sp.result(arg + 12) # @parameter%A + PUSH int 12; # int : @parameter%A + ADD; # int + } + { + NEVER; # FAILED + }; # int + # self.data.x = x.value # int + NIL operation; # list operation : int + PAIR; # pair (list operation) int + }; \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-sapling/sapling-adv.hex b/test/chain/tezos/lexer/samples/p008-opcodes/sapling-adv.hex similarity index 80% rename from test/chain/tezos/lexer/samples/p008-sapling/sapling-adv.hex rename to test/chain/tezos/lexer/samples/p008-opcodes/sapling-adv.hex index baa3630e..e01583a9 100644 --- a/test/chain/tezos/lexer/samples/p008-sapling/sapling-adv.hex +++ b/test/chain/tezos/lexer/samples/p008-opcodes/sapling-adv.hex @@ -1 +1 @@ -0000018802000001830501058300080500055f07650663035d00000004256b6579068400080000000c257472616e73616374696f6e0502020000015003210317034c03160321053d036d034c0552020000012405700003034c03210571000203170386072f02000000080743035b000a03270200000000032103170571000403210316032103110743036a0001033a0743035b0000057000020321057100030319032a072c020000002e034c0320034c0320057100020316072f02000000080743035b000f03270200000000031e05700002034f034d031b020000009a057000020320057000020316072f0200000004034c0320020000003407430368010000002957726f6e67436f6e646974696f6e3a207e206f7065726174696f6e2e6b65792e69735f736f6d6528290327031303190325072c0200000000020000003807430368010000002d57726f6e67436f6e646974696f6e3a2073702e616d6f756e74203d3d20616d6f756e745f74657a2e76616c75650327034c0320053d036d034c05520200000002031b0342 +0000018802000001830500055f07650663035d00000004256b6579068400080000000c257472616e73616374696f6e0501058300080502020000015003210317034c03160321053d036d034c0552020000012405700003034c03210571000203170386072f02000000080743035b000a03270200000000032103170571000403210316032103110743036a0001033a0743035b0000057000020321057100030319032a072c020000002e034c0320034c0320057100020316072f02000000080743035b000f03270200000000031e05700002034f034d031b020000009a057000020320057000020316072f0200000004034c0320020000003407430368010000002957726f6e67436f6e646974696f6e3a207e206f7065726174696f6e2e6b65792e69735f736f6d6528290327031303190325072c0200000000020000003807430368010000002d57726f6e67436f6e646974696f6e3a2073702e616d6f756e74203d3d20616d6f756e745f74657a2e76616c75650327034c0320053d036d034c05520200000002031b0342 \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-sapling/sapling-adv.micheline b/test/chain/tezos/lexer/samples/p008-opcodes/sapling-adv.micheline similarity index 99% rename from test/chain/tezos/lexer/samples/p008-sapling/sapling-adv.micheline rename to test/chain/tezos/lexer/samples/p008-opcodes/sapling-adv.micheline index cd08a72d..ab502ed4 100644 --- a/test/chain/tezos/lexer/samples/p008-sapling/sapling-adv.micheline +++ b/test/chain/tezos/lexer/samples/p008-opcodes/sapling-adv.micheline @@ -1,5 +1,4 @@ [ - { "prim": "storage", "args": [ { "prim": "sapling_state", "args": [ { "int": "8" } ] } ] }, { "prim": "parameter", "args": [ @@ -17,6 +16,7 @@ } ] }, + { "prim": "storage", "args": [ { "prim": "sapling_state", "args": [ { "int": "8" } ] } ] }, { "prim": "code", "args": [ @@ -108,4 +108,4 @@ ] ] } -] \ No newline at end of file +] diff --git a/test/chain/tezos/lexer/samples/p008-sapling/sapling-adv.michelson b/test/chain/tezos/lexer/samples/p008-opcodes/sapling-adv.michelson similarity index 99% rename from test/chain/tezos/lexer/samples/p008-sapling/sapling-adv.michelson rename to test/chain/tezos/lexer/samples/p008-opcodes/sapling-adv.michelson index fea1a0be..c41982f9 100644 --- a/test/chain/tezos/lexer/samples/p008-sapling/sapling-adv.michelson +++ b/test/chain/tezos/lexer/samples/p008-opcodes/sapling-adv.michelson @@ -102,4 +102,4 @@ code CONS; # list operation : @storage }; # list operation : @storage PAIR; # pair (list operation) @storage - }; \ No newline at end of file + }; diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/sapling.hex b/test/chain/tezos/lexer/samples/p008-opcodes/sapling.hex new file mode 100644 index 00000000..3b6ee1bb --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/sapling.hex @@ -0,0 +1 @@ +000000f602000000f1050007650683000f0000000225730684000f000000022574050107650765085e07650683000c0000000225610684000c00000002256205630765035b0583000c00000002256806830008000000062573746174650765045b0000000225780765066305630765035b0583000f000000022579085e035b0765035b0583000800000002257a0502020000006603210316034c031703210316034c031703210316034c031703170570000303210316034c0321057100050317038603460342034c0342034c034203210571000203210317034c0316031605850008057000030320057000030320034c03420342053d036d0342 \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-sapling/sapling.micheline b/test/chain/tezos/lexer/samples/p008-opcodes/sapling.micheline similarity index 54% rename from test/chain/tezos/lexer/samples/p008-sapling/sapling.micheline rename to test/chain/tezos/lexer/samples/p008-opcodes/sapling.micheline index 36229377..5b304aad 100644 --- a/test/chain/tezos/lexer/samples/p008-sapling/sapling.micheline +++ b/test/chain/tezos/lexer/samples/p008-opcodes/sapling.micheline @@ -1,4 +1,16 @@ [ + { + "prim": "parameter", + "args": [ + { + "prim": "pair", + "args": [ + { "prim": "sapling_state", "args": [ { "int": "15" } ], "annots": [ "%s" ] }, + { "prim": "sapling_transaction", "args": [ { "int": "15" } ], "annots": [ "%t" ] } + ] + } + ] + }, { "prim": "storage", "args": [ @@ -22,21 +34,27 @@ ], "annots": [ "%h" ] }, - { "prim": "int", "annots": [ "%x" ] } + { "prim": "sapling_state", "args": [ { "int": "8" } ], "annots": [ "%state" ] } ] }, { "prim": "pair", "args": [ + { "prim": "int", "annots": [ "%x" ] }, { - "prim": "option", - "args": [ { "prim": "option", "args": [ { "prim": "pair", "args": [ { "prim": "int" }, { "prim": "sapling_state", "args": [ { "int": "15" } ] } ] } ] } ], - "annots": [ "%y" ] - }, - { - "prim": "lambda", - "args": [ { "prim": "int" }, { "prim": "pair", "args": [ { "prim": "int" }, { "prim": "sapling_state", "args": [ { "int": "8" } ] } ] } ], - "annots": [ "%z" ] + "prim": "pair", + "args": [ + { + "prim": "option", + "args": [ { "prim": "option", "args": [ { "prim": "pair", "args": [ { "prim": "int" }, { "prim": "sapling_state", "args": [ { "int": "15" } ] } ] } ] } ], + "annots": [ "%y" ] + }, + { + "prim": "lambda", + "args": [ { "prim": "int" }, { "prim": "pair", "args": [ { "prim": "int" }, { "prim": "sapling_state", "args": [ { "int": "8" } ] } ] } ], + "annots": [ "%z" ] + } + ] } ] } @@ -44,18 +62,6 @@ } ] }, - { - "prim": "parameter", - "args": [ - { - "prim": "pair", - "args": [ - { "prim": "sapling_state", "args": [ { "int": "15" } ], "annots": [ "%s" ] }, - { "prim": "sapling_transaction", "args": [ { "int": "15" } ], "annots": [ "%t" ] } - ] - } - ] - }, { "prim": "code", "args": [ @@ -68,20 +74,43 @@ { "prim": "CAR" }, { "prim": "SWAP" }, { "prim": "CDR" }, + { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "SWAP" }, + { "prim": "CDR" }, { "prim": "CDR" }, - { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, { "prim": "DUP" }, { "prim": "CAR" }, { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "5" } ] }, { "prim": "CDR" }, { "prim": "SAPLING_VERIFY_UPDATE" }, { "prim": "SOME" }, { "prim": "PAIR" }, { "prim": "SWAP" }, { "prim": "PAIR" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "DUP" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "CAR" }, + { "prim": "CAR" }, + { "prim": "SAPLING_EMPTY_STATE", "args": [ { "int": "8" } ] }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", "args": [ { "int": "3" } ] }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "PAIR" }, { "prim": "NIL", "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } -] \ No newline at end of file +] diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/sapling.michelson b/test/chain/tezos/lexer/samples/p008-opcodes/sapling.michelson new file mode 100644 index 00000000..a6a42b67 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/sapling.michelson @@ -0,0 +1,52 @@ +parameter (pair (sapling_state %s 15) (sapling_transaction %t 15)); +storage (pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair (int %x) (pair (option %y (option (pair int (sapling_state 15)))) (lambda %z int (pair int (sapling_state 8)))))); +code + { + DUP; # pair @parameter @storage : pair @parameter @storage + CAR; # @parameter : pair @parameter @storage + SWAP; # pair @parameter @storage : @parameter + CDR; # @storage : @parameter + # == entry_point_1 == + # self.data.y = sp.some(sp.sapling_verify_update(params.s, params.t)) # @storage : @parameter + DUP; # @storage : @storage : @parameter + CAR; # pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @storage : @parameter + SWAP; # @storage : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + CDR; # pair (int %x) (pair (option %y (option (pair int (sapling_state 15)))) (lambda %z int (pair int (sapling_state 8)))) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + DUP; # pair (int %x) (pair (option %y (option (pair int (sapling_state 15)))) (lambda %z int (pair int (sapling_state 8)))) : pair (int %x) (pair (option %y (option (pair int (sapling_state 15)))) (lambda %z int (pair int (sapling_state 8)))) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + CAR; # int : pair (int %x) (pair (option %y (option (pair int (sapling_state 15)))) (lambda %z int (pair int (sapling_state 8)))) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + SWAP; # pair (int %x) (pair (option %y (option (pair int (sapling_state 15)))) (lambda %z int (pair int (sapling_state 8)))) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + CDR; # pair (option %y (option (pair int (sapling_state 15)))) (lambda %z int (pair int (sapling_state 8))) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + CDR; # lambda int (pair int (sapling_state 8)) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + DIG 3; # @parameter : lambda int (pair int (sapling_state 8)) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) + DUP; # @parameter : @parameter : lambda int (pair int (sapling_state 8)) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) + CAR; # sapling_state 15 : @parameter : lambda int (pair int (sapling_state 8)) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) + SWAP; # @parameter : sapling_state 15 : lambda int (pair int (sapling_state 8)) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) + DUP; # @parameter : @parameter : sapling_state 15 : lambda int (pair int (sapling_state 8)) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) + DUG 5; # @parameter : sapling_state 15 : lambda int (pair int (sapling_state 8)) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + CDR; # sapling_transaction 15 : sapling_state 15 : lambda int (pair int (sapling_state 8)) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + SAPLING_VERIFY_UPDATE; # option (pair int (sapling_state 15)) : lambda int (pair int (sapling_state 8)) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + SOME; # option (option (pair int (sapling_state 15))) : lambda int (pair int (sapling_state 8)) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + PAIR; # pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))) : int : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + SWAP; # int : pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + PAIR; # pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : @parameter + SWAP; # pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) : @parameter + PAIR; # pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) : @parameter + # self.data.state = sp.sapling_empty_state(8) # pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) : @parameter + DUP; # pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) : @parameter + DUG 2; # pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) : @parameter : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + DUP; # pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) : @parameter : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + CDR; # pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) : @parameter : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + SWAP; # pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) : @parameter : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + CAR; # pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8) : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) : @parameter : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + CAR; # lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12))) : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) : @parameter : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + SAPLING_EMPTY_STATE 8; # sapling_state 8 : lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12))) : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) : @parameter : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + DIG 3; # @parameter : sapling_state 8 : lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12))) : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + DROP; # sapling_state 8 : lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12))) : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + DIG 3; # pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state %state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) : sapling_state 8 : lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12))) : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) + DROP; # sapling_state 8 : lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12))) : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) + SWAP; # lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12))) : sapling_state 8 : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) + PAIR; # pair (lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state 8) : pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) + PAIR; # pair (pair (lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + NIL operation; # list operation : pair (pair (lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) + PAIR; # pair (list operation) (pair (pair (lambda (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (sapling_state 8)) (pair int (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))))) + }; \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/selfaddress.hex b/test/chain/tezos/lexer/samples/p008-opcodes/selfaddress.hex new file mode 100644 index 00000000..aecd73e1 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/selfaddress.hex @@ -0,0 +1 @@ +0000001e02000000190500036c0501036e0502020000000a03200377053d036d0342 diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/selfaddress.micheline b/test/chain/tezos/lexer/samples/p008-opcodes/selfaddress.micheline new file mode 100644 index 00000000..0992670a --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/selfaddress.micheline @@ -0,0 +1,5 @@ +[ + { "prim": "parameter", "args": [ { "prim": "unit" } ] }, + { "prim": "storage", "args": [ { "prim": "address" } ] }, + { "prim": "code", "args": [ [ { "prim": "DROP" }, { "prim": "SELF_ADDRESS" }, { "prim": "NIL", "args": [ { "prim": "operation" } ] }, { "prim": "PAIR" } ] ] } +] diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/selfaddress.michelson b/test/chain/tezos/lexer/samples/p008-opcodes/selfaddress.michelson new file mode 100644 index 00000000..446d0f84 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/selfaddress.michelson @@ -0,0 +1,11 @@ +parameter unit; +storage address; +code + { + DROP; # + # == entry_point_1 == + # self.data.address = sp.self_address # + SELF_ADDRESS; # address + NIL operation; # list operation : address + PAIR; # pair (list operation) address + }; \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-tickets/tickets.hex b/test/chain/tezos/lexer/samples/p008-opcodes/tickets.hex similarity index 68% rename from test/chain/tezos/lexer/samples/p008-tickets/tickets.hex rename to test/chain/tezos/lexer/samples/p008-opcodes/tickets.hex index 0afdb0a5..aa3cd7ba 100644 --- a/test/chain/tezos/lexer/samples/p008-tickets/tickets.hex +++ b/test/chain/tezos/lexer/samples/p008-opcodes/tickets.hex @@ -1 +1 @@ -00000142020000013d0501076506630587035b00000002257806630587036800000002257905000764046c0000000a256175746f5f63616c6c0687035b000000042572756e050202000000fa037a072e020000002c032007430362002b0743035b00010388053d036d0449000000042572756e0743036a000005700003034d031b02000000be038907430362002a074303680100000003616263038805700003034c0346034c0316034205710002052900040321074303620003034c0322072f02000000080743035b0014032702000000020316034c032105710002034b0356072f02000000080743035b001403270200000000074303620003057000020322072f02000000080743035b00140327020000000203160342034c038a072f02000000080743035b001403270200000000037a034c0342038b034c0317034c0342053d036d0342 +00000142020000013d05000764046c0000000a256175746f5f63616c6c0687035b000000042572756e0501076506630587035b000000022578066305870368000000022579050202000000fa037a072e020000002c032007430362002b0743035b00010388053d036d0449000000042572756e0743036a000005700003034d031b02000000be038907430362002a074303680100000003616263038805700003034c0346034c0316034205710002052900040321074303620003034c0322072f02000000080743035b0014032702000000020316034c032105710002034b0356072f02000000080743035b001403270200000000074303620003057000020322072f02000000080743035b00140327020000000203160342034c038a072f02000000080743035b001403270200000000037a034c0342038b034c0317034c0342053d036d0342 \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-tickets/tickets.micheline b/test/chain/tezos/lexer/samples/p008-opcodes/tickets.micheline similarity index 99% rename from test/chain/tezos/lexer/samples/p008-tickets/tickets.micheline rename to test/chain/tezos/lexer/samples/p008-opcodes/tickets.micheline index 6f511991..522f79be 100644 --- a/test/chain/tezos/lexer/samples/p008-tickets/tickets.micheline +++ b/test/chain/tezos/lexer/samples/p008-opcodes/tickets.micheline @@ -1,4 +1,8 @@ [ + { + "prim": "parameter", + "args": [ { "prim": "or", "args": [ { "prim": "unit", "annots": [ "%auto_call" ] }, { "prim": "ticket", "args": [ { "prim": "int" } ], "annots": [ "%run" ] } ] } ] + }, { "prim": "storage", "args": [ @@ -11,10 +15,6 @@ } ] }, - { - "prim": "parameter", - "args": [ { "prim": "or", "args": [ { "prim": "unit", "annots": [ "%auto_call" ] }, { "prim": "ticket", "args": [ { "prim": "int" } ], "annots": [ "%run" ] } ] } ] - }, { "prim": "code", "args": [ @@ -83,4 +83,4 @@ ] ] } -] \ No newline at end of file +] diff --git a/test/chain/tezos/lexer/samples/p008-tickets/tickets.michelson b/test/chain/tezos/lexer/samples/p008-opcodes/tickets.michelson similarity index 100% rename from test/chain/tezos/lexer/samples/p008-tickets/tickets.michelson rename to test/chain/tezos/lexer/samples/p008-opcodes/tickets.michelson diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/votingpower.hex b/test/chain/tezos/lexer/samples/p008-opcodes/votingpower.hex new file mode 100644 index 00000000..d0e79379 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/votingpower.hex @@ -0,0 +1 @@ +0000005c02000000570500035c05010765046200000002256104620000000225620502020000003803210316034c03170317034c032105710002032b037b03420321057100020316037c057000020320057000020320034c0342053d036d0342 \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/votingpower.micheline b/test/chain/tezos/lexer/samples/p008-opcodes/votingpower.micheline new file mode 100644 index 00000000..d98266a0 --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/votingpower.micheline @@ -0,0 +1,34 @@ +[ + { "prim": "parameter", "args": [ { "prim": "key" } ] }, + { "prim": "storage", "args": [ { "prim": "pair", "args": [ { "prim": "nat", "annots": [ "%a" ] }, { "prim": "nat", "annots": [ "%b" ] } ] } ] }, + { + "prim": "code", + "args": [ + [ + { "prim": "DUP" }, + { "prim": "CAR" }, + { "prim": "SWAP" }, + { "prim": "CDR" }, + { "prim": "CDR" }, + { "prim": "SWAP" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "HASH_KEY" }, + { "prim": "VOTING_POWER" }, + { "prim": "PAIR" }, + { "prim": "DUP" }, + { "prim": "DUG", "args": [ { "int": "2" } ] }, + { "prim": "CAR" }, + { "prim": "TOTAL_VOTING_POWER" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "DIG", "args": [ { "int": "2" } ] }, + { "prim": "DROP" }, + { "prim": "SWAP" }, + { "prim": "PAIR" }, + { "prim": "NIL", "args": [ { "prim": "operation" } ] }, + { "prim": "PAIR" } + ] + ] + } +] diff --git a/test/chain/tezos/lexer/samples/p008-opcodes/votingpower.michelson b/test/chain/tezos/lexer/samples/p008-opcodes/votingpower.michelson new file mode 100644 index 00000000..1ef4a5eb --- /dev/null +++ b/test/chain/tezos/lexer/samples/p008-opcodes/votingpower.michelson @@ -0,0 +1,31 @@ +parameter key; +storage (pair (nat %a) (nat %b)); +code + { + DUP; # pair @parameter @storage : pair @parameter @storage + CAR; # @parameter : pair @parameter @storage + SWAP; # pair @parameter @storage : @parameter + CDR; # @storage : @parameter + # == validate == + # self.data.a = sp.voting_power(sp.hash_key(params)) # @storage : @parameter + CDR; # nat : @parameter + SWAP; # @parameter : nat + DUP; # @parameter : @parameter : nat + DUG 2; # @parameter : nat : @parameter + HASH_KEY; # key_hash : nat : @parameter + VOTING_POWER; # nat : nat : @parameter + PAIR; # pair nat nat : @parameter + # self.data.b = sp.total_voting_power # pair nat nat : @parameter + DUP; # pair nat nat : pair nat nat : @parameter + DUG 2; # pair nat nat : @parameter : pair nat nat + CAR; # nat : @parameter : pair nat nat + TOTAL_VOTING_POWER; # nat : nat : @parameter : pair nat nat + DIG 2; # @parameter : nat : nat : pair nat nat + DROP; # nat : nat : pair nat nat + DIG 2; # pair nat nat : nat : nat + DROP; # nat : nat + SWAP; # nat : nat + PAIR; # pair nat nat + NIL operation; # list operation : pair nat nat + PAIR; # pair (list operation) (pair nat nat) + }; \ No newline at end of file diff --git a/test/chain/tezos/lexer/samples/p008-sapling/sapling.hex b/test/chain/tezos/lexer/samples/p008-sapling/sapling.hex deleted file mode 100644 index c1738144..00000000 --- a/test/chain/tezos/lexer/samples/p008-sapling/sapling.hex +++ /dev/null @@ -1 +0,0 @@ -000000ae02000000a9050107650765085e07650683000c0000000225610684000c00000002256205630765035b0583000c000000022568045b0000000225780765066305630765035b0583000f000000022579085e035b0765035b0583000800000002257a050007650683000f0000000225730684000f0000000225740502020000002e03210316034c031703210316034c031703170570000203210316034c0317038603460342034c0342053d036d0342 diff --git a/test/chain/tezos/lexer/samples/p008-sapling/sapling.michelson b/test/chain/tezos/lexer/samples/p008-sapling/sapling.michelson deleted file mode 100644 index 48c4c194..00000000 --- a/test/chain/tezos/lexer/samples/p008-sapling/sapling.michelson +++ /dev/null @@ -1,28 +0,0 @@ -parameter (pair (sapling_state %s 15) (sapling_transaction %t 15)); -storage (pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x)) (pair (option %y (option (pair int (sapling_state 15)))) (lambda %z int (pair int (sapling_state 8))))); -code - { - DUP; # pair @parameter @storage : pair @parameter @storage - CAR; # @parameter : pair @parameter @storage - SWAP; # pair @parameter @storage : @parameter - CDR; # @storage : @parameter - # == entry_point_1 == - # self.data.y = sp.some(sp.sapling_verify_update(params.s, params.t)) # @storage : @parameter - DUP; # @storage : @storage : @parameter - CAR; # pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) : @storage : @parameter - SWAP; # @storage : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) : @parameter - CDR; # pair (option %y (option (pair int (sapling_state 15)))) (lambda %z int (pair int (sapling_state 8))) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) : @parameter - CDR; # lambda int (pair int (sapling_state 8)) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) : @parameter - DIG 2; # @parameter : lambda int (pair int (sapling_state 8)) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) - DUP; # @parameter : @parameter : lambda int (pair int (sapling_state 8)) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) - CAR; # sapling_state 15 : @parameter : lambda int (pair int (sapling_state 8)) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) - SWAP; # @parameter : sapling_state 15 : lambda int (pair int (sapling_state 8)) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) - CDR; # sapling_transaction 15 : sapling_state 15 : lambda int (pair int (sapling_state 8)) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) - SAPLING_VERIFY_UPDATE; # option (pair int (sapling_state 15)) : lambda int (pair int (sapling_state 8)) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) - SOME; # option (option (pair int (sapling_state 15))) : lambda int (pair int (sapling_state 8)) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) - PAIR; # pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))) : pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) - SWAP; # pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x) : pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))) - PAIR; # pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x)) (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) - NIL operation; # list operation : pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x)) (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8)))) - PAIR; # pair (list operation) (pair (pair (lambda %h (pair (sapling_state %a 12) (sapling_transaction %b 12)) (option (pair int (sapling_state 12)))) (int %x)) (pair (option (option (pair int (sapling_state 15)))) (lambda int (pair int (sapling_state 8))))) - }; \ No newline at end of file