-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Veridise/dev
fixed antlr grammar with new lexer and parser
- Loading branch information
Showing
30 changed files
with
9,899 additions
and
11,853 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
program test.aleo; | ||
|
||
struct CollectionPublicData: | ||
royalty_fees as u64; | ||
royalty_address as u32; | ||
metadata_uri as String64; | ||
negbase_uri as String64; | ||
publicizable as boolean; | ||
|
||
function update_collection_public_data: | ||
input r0 as Collection.record; | ||
input r1 as CollectionPublicData.public; | ||
cast r0.owner r0.id r0.data into r2 as Collection.record; | ||
async update_collection_public_data r0.id r1 into r3; | ||
output r2 as Collection.record; | ||
output r3 as aleo_store_nft.aleo/update_collection_public_data.future; | ||
|
||
finalize update_collection_public_data: | ||
input r0 as CollectionId.public; | ||
input r1 as CollectionPublicData.public; | ||
get collectionPublicData[r0] into r2; | ||
assert.eq r2.publicizable r1.recordjjj ; | ||
set r1 into collectionPublicData[r0]; | ||
set r123 into rafew[r0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,257 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "92a381f1-d0c2-4d81-a601-6204575a5b6a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# only run once every time kernel restarts\n", | ||
"import json\n", | ||
"import os\n", | ||
"import sys\n", | ||
"from antlr4 import *\n", | ||
"os.chdir(\"..\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "0062f4dd-2067-4608-ada1-e423db3c8e27", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from vanguard.aleo.parser.AleoLexer import AleoLexer\n", | ||
"input_stream = FileStream(f\"./tests/lexer-test.aleo\")\n", | ||
"lexer = AleoLexer(input_stream)\n", | ||
"tokens = lexer.getAllTokens()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "1b6e0beb-9df5-4748-a3f2-b7e1e112e248", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"program | 92 | PROGRAM\n", | ||
"test | 116 | IDENTIFIER\n", | ||
". | 1 | DOT\n", | ||
"aleo | 116 | IDENTIFIER\n", | ||
"; | 5 | SC\n", | ||
"struct | 97 | STRUCT\n", | ||
"CollectionPublicData | 116 | IDENTIFIER\n", | ||
": | 7 | CL\n", | ||
"royalty_fees | 116 | IDENTIFIER\n", | ||
"as | 9 | AS\n", | ||
"u64 | 105 | UNSIGNED_TYPE\n", | ||
"; | 5 | SC\n", | ||
"royalty_address | 116 | IDENTIFIER\n", | ||
"as | 9 | AS\n", | ||
"u32 | 105 | UNSIGNED_TYPE\n", | ||
"; | 5 | SC\n", | ||
"metadata_uri | 116 | IDENTIFIER\n", | ||
"as | 9 | AS\n", | ||
"String64 | 116 | IDENTIFIER\n", | ||
"; | 5 | SC\n", | ||
"negbase_uri | 116 | IDENTIFIER\n", | ||
"as | 9 | AS\n", | ||
"String64 | 116 | IDENTIFIER\n", | ||
"; | 5 | SC\n", | ||
"publicizable | 116 | IDENTIFIER\n", | ||
"as | 9 | AS\n", | ||
"boolean | 110 | BOOLEAN\n", | ||
"; | 5 | SC\n", | ||
"function | 101 | FUNCTION\n", | ||
"update_collection_public_data | 116 | IDENTIFIER\n", | ||
": | 7 | CL\n", | ||
"input | 99 | INPUT\n", | ||
"r0 | 115 | REGISTER\n", | ||
"as | 9 | AS\n", | ||
"Collection | 116 | IDENTIFIER\n", | ||
". | 1 | DOT\n", | ||
"record | 16 | RECORD\n", | ||
"; | 5 | SC\n", | ||
"input | 99 | INPUT\n", | ||
"r1 | 115 | REGISTER\n", | ||
"as | 9 | AS\n", | ||
"CollectionPublicData | 116 | IDENTIFIER\n", | ||
". | 1 | DOT\n", | ||
"public | 12 | PUBLIC\n", | ||
"; | 5 | SC\n", | ||
"cast | 89 | CAST\n", | ||
"r0 | 115 | REGISTER\n", | ||
". | 1 | DOT\n", | ||
"owner | 116 | IDENTIFIER\n", | ||
"r0 | 115 | REGISTER\n", | ||
". | 1 | DOT\n", | ||
"id | 116 | IDENTIFIER\n", | ||
"r0 | 115 | REGISTER\n", | ||
". | 1 | DOT\n", | ||
"data | 116 | IDENTIFIER\n", | ||
"into | 10 | INTO\n", | ||
"r2 | 115 | REGISTER\n", | ||
"as | 9 | AS\n", | ||
"Collection | 116 | IDENTIFIER\n", | ||
". | 1 | DOT\n", | ||
"record | 16 | RECORD\n", | ||
"; | 5 | SC\n", | ||
"async | 41 | ASYNC\n", | ||
"update_collection_public_data | 116 | IDENTIFIER\n", | ||
"r0 | 115 | REGISTER\n", | ||
". | 1 | DOT\n", | ||
"id | 116 | IDENTIFIER\n", | ||
"r1 | 115 | REGISTER\n", | ||
"into | 10 | INTO\n", | ||
"r3 | 115 | REGISTER\n", | ||
"; | 5 | SC\n", | ||
"output | 100 | OUTPUT\n", | ||
"r2 | 115 | REGISTER\n", | ||
"as | 9 | AS\n", | ||
"Collection | 116 | IDENTIFIER\n", | ||
". | 1 | DOT\n", | ||
"record | 16 | RECORD\n", | ||
"; | 5 | SC\n", | ||
"output | 100 | OUTPUT\n", | ||
"r3 | 115 | REGISTER\n", | ||
"as | 9 | AS\n", | ||
"aleo_store_nft | 116 | IDENTIFIER\n", | ||
". | 1 | DOT\n", | ||
"aleo | 116 | IDENTIFIER\n", | ||
"/ | 2 | SLASH\n", | ||
"update_collection_public_data | 116 | IDENTIFIER\n", | ||
". | 1 | DOT\n", | ||
"future | 15 | FUTURE\n", | ||
"; | 5 | SC\n", | ||
"finalize | 102 | FINALIZE\n", | ||
"update_collection_public_data | 116 | IDENTIFIER\n", | ||
": | 7 | CL\n", | ||
"input | 99 | INPUT\n", | ||
"r0 | 115 | REGISTER\n", | ||
"as | 9 | AS\n", | ||
"CollectionId | 116 | IDENTIFIER\n", | ||
". | 1 | DOT\n", | ||
"public | 12 | PUBLIC\n", | ||
"; | 5 | SC\n", | ||
"input | 99 | INPUT\n", | ||
"r1 | 115 | REGISTER\n", | ||
"as | 9 | AS\n", | ||
"CollectionPublicData | 116 | IDENTIFIER\n", | ||
". | 1 | DOT\n", | ||
"public | 12 | PUBLIC\n", | ||
"; | 5 | SC\n", | ||
"get | 28 | GET\n", | ||
"collectionPublicData | 116 | IDENTIFIER\n", | ||
"[ | 3 | LB\n", | ||
"r0 | 115 | REGISTER\n", | ||
"] | 4 | RB\n", | ||
"into | 10 | INTO\n", | ||
"r2 | 115 | REGISTER\n", | ||
"; | 5 | SC\n", | ||
"assert | 70 | ASSERT\n", | ||
". | 1 | DOT\n", | ||
"eq | 68 | EQ\n", | ||
"r2 | 115 | REGISTER\n", | ||
". | 1 | DOT\n", | ||
"publicizable | 116 | IDENTIFIER\n", | ||
"r1 | 115 | REGISTER\n", | ||
". | 1 | DOT\n", | ||
"recordjjj | 116 | IDENTIFIER\n", | ||
"; | 5 | SC\n", | ||
"set | 30 | SET\n", | ||
"r1 | 115 | REGISTER\n", | ||
"into | 10 | INTO\n", | ||
"collectionPublicData | 116 | IDENTIFIER\n", | ||
"[ | 3 | LB\n", | ||
"r0 | 115 | REGISTER\n", | ||
"] | 4 | RB\n", | ||
"; | 5 | SC\n", | ||
"set | 30 | SET\n", | ||
"r12 | 115 | REGISTER\n", | ||
"into | 10 | INTO\n", | ||
"r123 | 115 | REGISTER\n", | ||
"[ | 3 | LB\n", | ||
"r0 | 115 | REGISTER\n", | ||
"] | 4 | RB\n", | ||
"; | 5 | SC\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for t in tokens:\n", | ||
" print(f\"{t.text} | {t.type} | {lexer.symbolicNames[t.type]}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "80638ee0-d9a0-42f3-b737-dd5cc70545ef", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 15, | ||
"id": "43f7bc52-ce30-480e-b030-7c2f7b8949ed", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# dir(lexer)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 21, | ||
"id": "1b719ef5-f739-41cf-80e5-36d7680e5380", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# dir(t)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 22, | ||
"id": "68eefa99-d909-48fd-b8fe-ce886397fe76", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# t.type" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b42e12e8-f94f-4399-a64f-a47fee71e36f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.