Created
September 29, 2018 19:40
-
-
Save mattiaerre/22660335641eb939dc436bc96cf3a658 to your computer and use it in GitHub Desktop.
ForStatement AST part
This file contains hidden or 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
{ | |
"type": "ForStatement", | |
"initExpression": { | |
"type": "VariableDeclarationStatement", | |
"variables": [ | |
{ | |
"type": "VariableDeclaration", | |
"typeName": { | |
"type": "ElementaryTypeName", | |
"name": "uint", | |
"loc": { | |
"start": { "line": 30, "column": 11 }, | |
"end": { "line": 30, "column": 11 } | |
}, | |
"range": [838, 841] | |
}, | |
"name": "i", | |
"storageLocation": null, | |
"isStateVar": false, | |
"isIndexed": false, | |
"loc": { | |
"start": { "line": 30, "column": 11 }, | |
"end": { "line": 30, "column": 16 } | |
}, | |
"range": [838, 843] | |
} | |
], | |
"initialValue": { | |
"type": "NumberLiteral", | |
"number": "0", | |
"subdenomination": null, | |
"loc": { | |
"start": { "line": 30, "column": 20 }, | |
"end": { "line": 30, "column": 20 } | |
}, | |
"range": [847, 847] | |
}, | |
"loc": { | |
"start": { "line": 30, "column": 11 }, | |
"end": { "line": 30, "column": 21 } | |
}, | |
"range": [838, 848] | |
}, | |
"conditionExpression": { | |
"type": "BinaryOperation", | |
"operator": "<", | |
"left": { | |
"type": "Identifier", | |
"name": "i", | |
"loc": { | |
"start": { "line": 30, "column": 23 }, | |
"end": { "line": 30, "column": 23 } | |
}, | |
"range": [850, 850] | |
}, | |
"right": { | |
"type": "MemberAccess", | |
"expression": { | |
"type": "Identifier", | |
"name": "a", | |
"loc": { | |
"start": { "line": 30, "column": 27 }, | |
"end": { "line": 30, "column": 27 } | |
}, | |
"range": [854, 854] | |
}, | |
"memberName": "length", | |
"loc": { | |
"start": { "line": 30, "column": 27 }, | |
"end": { "line": 30, "column": 29 } | |
}, | |
"range": [854, 861] | |
}, | |
"loc": { | |
"start": { "line": 30, "column": 23 }, | |
"end": { "line": 30, "column": 29 } | |
}, | |
"range": [850, 861] | |
}, | |
"loopExpression": { | |
"type": "ExpressionStatement", | |
"expression": { | |
"type": "UnaryOperation", | |
"operator": "++", | |
"subExpression": { | |
"type": "Identifier", | |
"name": "i", | |
"loc": { | |
"start": { "line": 30, "column": 37 }, | |
"end": { "line": 30, "column": 37 } | |
}, | |
"range": [864, 864] | |
}, | |
"isPrefix": false, | |
"loc": { | |
"start": { "line": 30, "column": 37 }, | |
"end": { "line": 30, "column": 39 } | |
}, | |
"range": [864, 867] | |
} | |
}, | |
"body": { | |
"type": "Block", | |
"statements": [ | |
{ | |
"type": "IfStatement", | |
"condition": { | |
"type": "BinaryOperation", | |
"operator": "==", | |
"left": { | |
"type": "IndexAccess", | |
"base": { | |
"type": "Identifier", | |
"name": "a", | |
"loc": { | |
"start": { "line": 32, "column": 11 }, | |
"end": { "line": 32, "column": 11 } | |
}, | |
"range": [889, 889] | |
}, | |
"index": { | |
"type": "Identifier", | |
"name": "i", | |
"loc": { | |
"start": { "line": 32, "column": 13 }, | |
"end": { "line": 32, "column": 13 } | |
}, | |
"range": [891, 891] | |
}, | |
"loc": { | |
"start": { "line": 32, "column": 11 }, | |
"end": { "line": 32, "column": 14 } | |
}, | |
"range": [889, 892] | |
}, | |
"right": { | |
"type": "IndexAccess", | |
"base": { | |
"type": "Identifier", | |
"name": "b", | |
"loc": { | |
"start": { "line": 32, "column": 19 }, | |
"end": { "line": 32, "column": 19 } | |
}, | |
"range": [897, 897] | |
}, | |
"index": { | |
"type": "NumberLiteral", | |
"number": "0", | |
"subdenomination": null, | |
"loc": { | |
"start": { "line": 32, "column": 21 }, | |
"end": { "line": 32, "column": 21 } | |
}, | |
"range": [899, 899] | |
}, | |
"loc": { | |
"start": { "line": 32, "column": 19 }, | |
"end": { "line": 32, "column": 22 } | |
}, | |
"range": [897, 900] | |
}, | |
"loc": { | |
"start": { "line": 32, "column": 11 }, | |
"end": { "line": 32, "column": 22 } | |
}, | |
"range": [889, 900], | |
"comments": [ | |
{ | |
"type": "LineComment", | |
"value": "found the first char of b", | |
"range": [903, 931], | |
"loc": { | |
"start": { "line": 32, "column": 25 }, | |
"end": { "line": 32, "column": 53 } | |
}, | |
"raw": " found the first char of b", | |
"leading": false, | |
"trailing": true, | |
"printed": false | |
} | |
] | |
}, | |
"trueBody": { | |
"type": "Block", | |
"statements": [ | |
{ | |
"type": "ExpressionStatement", | |
"expression": { | |
"type": "BinaryOperation", | |
"operator": "=", | |
"left": { | |
"type": "Identifier", | |
"name": "subindex", | |
"loc": { | |
"start": { "line": 34, "column": 8 }, | |
"end": { "line": 34, "column": 8 } | |
}, | |
"range": [949, 956] | |
}, | |
"right": { | |
"type": "NumberLiteral", | |
"number": "1", | |
"subdenomination": null, | |
"loc": { | |
"start": { "line": 34, "column": 19 }, | |
"end": { "line": 34, "column": 19 } | |
}, | |
"range": [960, 960] | |
}, | |
"loc": { | |
"start": { "line": 34, "column": 8 }, | |
"end": { "line": 34, "column": 19 } | |
}, | |
"range": [949, 960] | |
}, | |
"loc": { | |
"start": { "line": 34, "column": 8 }, | |
"end": { "line": 34, "column": 20 } | |
}, | |
"range": [949, 961] | |
}, | |
{ | |
"type": "WhileStatement", | |
"condition": { | |
"type": "BinaryOperation", | |
"operator": "&&", | |
"left": { | |
"type": "BinaryOperation", | |
"operator": "&&", | |
"left": { | |
"type": "BinaryOperation", | |
"operator": "<", | |
"left": { | |
"type": "Identifier", | |
"name": "subindex", | |
"loc": { | |
"start": { "line": 35, "column": 14 }, | |
"end": { "line": 35, "column": 14 } | |
}, | |
"range": [977, 984] | |
}, | |
"right": { | |
"type": "MemberAccess", | |
"expression": { | |
"type": "Identifier", | |
"name": "b", | |
"loc": { | |
"start": { "line": 35, "column": 25 }, | |
"end": { "line": 35, "column": 25 } | |
}, | |
"range": [988, 988] | |
}, | |
"memberName": "length", | |
"loc": { | |
"start": { "line": 35, "column": 25 }, | |
"end": { "line": 35, "column": 27 } | |
}, | |
"range": [988, 995] | |
}, | |
"loc": { | |
"start": { "line": 35, "column": 14 }, | |
"end": { "line": 35, "column": 27 } | |
}, | |
"range": [977, 995] | |
}, | |
"right": { | |
"type": "BinaryOperation", | |
"operator": "<", | |
"left": { | |
"type": "TupleExpression", | |
"components": [ | |
{ | |
"type": "BinaryOperation", | |
"operator": "+", | |
"left": { | |
"type": "Identifier", | |
"name": "i", | |
"loc": { | |
"start": { "line": 35, "column": 38 }, | |
"end": { "line": 35, "column": 38 } | |
}, | |
"range": [1001, 1001] | |
}, | |
"right": { | |
"type": "Identifier", | |
"name": "subindex", | |
"loc": { | |
"start": { "line": 35, "column": 42 }, | |
"end": { "line": 35, "column": 42 } | |
}, | |
"range": [1005, 1012] | |
}, | |
"loc": { | |
"start": { "line": 35, "column": 38 }, | |
"end": { "line": 35, "column": 42 } | |
}, | |
"range": [1001, 1012] | |
} | |
], | |
"isArray": false, | |
"loc": { | |
"start": { "line": 35, "column": 37 }, | |
"end": { "line": 35, "column": 50 } | |
}, | |
"range": [1000, 1013] | |
}, | |
"right": { | |
"type": "MemberAccess", | |
"expression": { | |
"type": "Identifier", | |
"name": "a", | |
"loc": { | |
"start": { "line": 35, "column": 54 }, | |
"end": { "line": 35, "column": 54 } | |
}, | |
"range": [1017, 1017] | |
}, | |
"memberName": "length", | |
"loc": { | |
"start": { "line": 35, "column": 54 }, | |
"end": { "line": 35, "column": 56 } | |
}, | |
"range": [1017, 1024] | |
}, | |
"loc": { | |
"start": { "line": 35, "column": 37 }, | |
"end": { "line": 35, "column": 56 } | |
}, | |
"range": [1000, 1024] | |
}, | |
"loc": { | |
"start": { "line": 35, "column": 14 }, | |
"end": { "line": 35, "column": 56 } | |
}, | |
"range": [977, 1024] | |
}, | |
"right": { | |
"type": "BinaryOperation", | |
"operator": "==", | |
"left": { | |
"type": "IndexAccess", | |
"base": { | |
"type": "Identifier", | |
"name": "a", | |
"loc": { | |
"start": { "line": 35, "column": 66 }, | |
"end": { "line": 35, "column": 66 } | |
}, | |
"range": [1029, 1029] | |
}, | |
"index": { | |
"type": "BinaryOperation", | |
"operator": "+", | |
"left": { | |
"type": "Identifier", | |
"name": "i", | |
"loc": { | |
"start": { "line": 35, "column": 68 }, | |
"end": { "line": 35, "column": 68 } | |
}, | |
"range": [1031, 1031] | |
}, | |
"right": { | |
"type": "Identifier", | |
"name": "subindex", | |
"loc": { | |
"start": { "line": 35, "column": 72 }, | |
"end": { "line": 35, "column": 72 } | |
}, | |
"range": [1035, 1042] | |
}, | |
"loc": { | |
"start": { "line": 35, "column": 68 }, | |
"end": { "line": 35, "column": 72 } | |
}, | |
"range": [1031, 1042] | |
}, | |
"loc": { | |
"start": { "line": 35, "column": 66 }, | |
"end": { "line": 35, "column": 80 } | |
}, | |
"range": [1029, 1043] | |
}, | |
"right": { | |
"type": "IndexAccess", | |
"base": { | |
"type": "Identifier", | |
"name": "b", | |
"loc": { | |
"start": { "line": 35, "column": 85 }, | |
"end": { "line": 35, "column": 85 } | |
}, | |
"range": [1048, 1048] | |
}, | |
"index": { | |
"type": "Identifier", | |
"name": "subindex", | |
"loc": { | |
"start": { "line": 35, "column": 87 }, | |
"end": { "line": 35, "column": 87 } | |
}, | |
"range": [1050, 1057] | |
}, | |
"loc": { | |
"start": { "line": 35, "column": 85 }, | |
"end": { "line": 35, "column": 95 } | |
}, | |
"range": [1048, 1058] | |
}, | |
"loc": { | |
"start": { "line": 35, "column": 66 }, | |
"end": { "line": 35, "column": 95 } | |
}, | |
"range": [1029, 1058] | |
}, | |
"loc": { | |
"start": { "line": 35, "column": 14 }, | |
"end": { "line": 35, "column": 95 } | |
}, | |
"range": [977, 1058], | |
"comments": [ | |
{ | |
"type": "LineComment", | |
"value": "search until the chars don't match or until we reach the end of a or b", | |
"range": [1061, 1134], | |
"loc": { | |
"start": { "line": 35, "column": 98 }, | |
"end": { "line": 35, "column": 171 } | |
}, | |
"raw": " search until the chars don't match or until we reach the end of a or b", | |
"leading": false, | |
"trailing": true, | |
"printed": false | |
} | |
] | |
}, | |
"body": { | |
"type": "Block", | |
"statements": [ | |
{ | |
"type": "ExpressionStatement", | |
"expression": { | |
"type": "UnaryOperation", | |
"operator": "++", | |
"subExpression": { | |
"type": "Identifier", | |
"name": "subindex", | |
"loc": { | |
"start": { "line": 37, "column": 9 }, | |
"end": { "line": 37, "column": 9 } | |
}, | |
"range": [1154, 1161] | |
}, | |
"isPrefix": false, | |
"loc": { | |
"start": { "line": 37, "column": 9 }, | |
"end": { "line": 37, "column": 17 } | |
}, | |
"range": [1154, 1163] | |
}, | |
"loc": { | |
"start": { "line": 37, "column": 9 }, | |
"end": { "line": 37, "column": 19 } | |
}, | |
"range": [1154, 1164] | |
} | |
], | |
"loc": { | |
"start": { "line": 36, "column": 8 }, | |
"end": { "line": 38, "column": 8 } | |
}, | |
"range": [1143, 1174] | |
}, | |
"loc": { | |
"start": { "line": 35, "column": 8 }, | |
"end": { "line": 38, "column": 8 } | |
}, | |
"range": [971, 1174] | |
}, | |
{ | |
"type": "IfStatement", | |
"condition": { | |
"type": "BinaryOperation", | |
"operator": "==", | |
"left": { | |
"type": "Identifier", | |
"name": "subindex", | |
"loc": { | |
"start": { "line": 39, "column": 11 }, | |
"end": { "line": 39, "column": 11 } | |
}, | |
"range": [1188, 1195] | |
}, | |
"right": { | |
"type": "MemberAccess", | |
"expression": { | |
"type": "Identifier", | |
"name": "b", | |
"loc": { | |
"start": { "line": 39, "column": 23 }, | |
"end": { "line": 39, "column": 23 } | |
}, | |
"range": [1200, 1200] | |
}, | |
"memberName": "length", | |
"loc": { | |
"start": { "line": 39, "column": 23 }, | |
"end": { "line": 39, "column": 25 } | |
}, | |
"range": [1200, 1207] | |
}, | |
"loc": { | |
"start": { "line": 39, "column": 11 }, | |
"end": { "line": 39, "column": 25 } | |
}, | |
"range": [1188, 1207] | |
}, | |
"trueBody": { | |
"type": "Block", | |
"statements": [ | |
{ | |
"type": "ExpressionStatement", | |
"expression": { | |
"type": "BinaryOperation", | |
"operator": "=", | |
"left": { | |
"type": "Identifier", | |
"name": "whatwastheval", | |
"loc": { | |
"start": { "line": 41, "column": 9 }, | |
"end": { "line": 41, "column": 9 } | |
}, | |
"range": [1230, 1242] | |
}, | |
"right": { | |
"type": "FunctionCall", | |
"expression": { | |
"type": "ElementaryTypeNameExpression", | |
"typeName": { | |
"type": "ElementaryTypeName", | |
"name": "int", | |
"loc": { | |
"start": { "line": 41, "column": 25 }, | |
"end": { "line": 41, "column": 25 } | |
}, | |
"range": [1246, 1248] | |
}, | |
"loc": { | |
"start": { "line": 41, "column": 25 }, | |
"end": { "line": 41, "column": 25 } | |
}, | |
"range": [1246, 1248] | |
}, | |
"arguments": [ | |
{ | |
"type": "Identifier", | |
"name": "i", | |
"loc": { | |
"start": { "line": 41, "column": 29 }, | |
"end": { "line": 41, "column": 29 } | |
}, | |
"range": [1250, 1250] | |
} | |
], | |
"names": [], | |
"loc": { | |
"start": { "line": 41, "column": 25 }, | |
"end": { "line": 41, "column": 30 } | |
}, | |
"range": [1246, 1251] | |
}, | |
"loc": { | |
"start": { "line": 41, "column": 9 }, | |
"end": { "line": 41, "column": 30 } | |
}, | |
"range": [1230, 1251] | |
}, | |
"loc": { | |
"start": { "line": 41, "column": 9 }, | |
"end": { "line": 41, "column": 31 } | |
}, | |
"range": [1230, 1252] | |
}, | |
{ | |
"type": "ReturnStatement", | |
"expression": { | |
"type": "FunctionCall", | |
"expression": { | |
"type": "ElementaryTypeNameExpression", | |
"typeName": { | |
"type": "ElementaryTypeName", | |
"name": "int", | |
"loc": { | |
"start": { "line": 42, "column": 16 }, | |
"end": { "line": 42, "column": 16 } | |
}, | |
"range": [1270, 1272] | |
}, | |
"loc": { | |
"start": { "line": 42, "column": 16 }, | |
"end": { "line": 42, "column": 16 } | |
}, | |
"range": [1270, 1272] | |
}, | |
"arguments": [ | |
{ | |
"type": "Identifier", | |
"name": "i", | |
"loc": { | |
"start": { "line": 42, "column": 20 }, | |
"end": { "line": 42, "column": 20 } | |
}, | |
"range": [1274, 1274] | |
} | |
], | |
"names": [], | |
"loc": { | |
"start": { "line": 42, "column": 16 }, | |
"end": { "line": 42, "column": 21 } | |
}, | |
"range": [1270, 1275] | |
}, | |
"loc": { | |
"start": { "line": 42, "column": 9 }, | |
"end": { "line": 42, "column": 22 } | |
}, | |
"range": [1263, 1276] | |
} | |
], | |
"loc": { | |
"start": { "line": 40, "column": 8 }, | |
"end": { "line": 43, "column": 8 } | |
}, | |
"range": [1218, 1286] | |
}, | |
"falseBody": null, | |
"loc": { | |
"start": { "line": 39, "column": 8 }, | |
"end": { "line": 43, "column": 8 } | |
}, | |
"range": [1185, 1286] | |
} | |
], | |
"loc": { | |
"start": { "line": 33, "column": 7 }, | |
"end": { "line": 44, "column": 7 } | |
}, | |
"range": [939, 1295] | |
}, | |
"falseBody": null, | |
"loc": { | |
"start": { "line": 32, "column": 7 }, | |
"end": { "line": 44, "column": 7 } | |
}, | |
"range": [885, 1295] | |
} | |
], | |
"loc": { | |
"start": { "line": 31, "column": 6 }, | |
"end": { "line": 45, "column": 6 } | |
}, | |
"range": [876, 1303] | |
}, | |
"loc": { | |
"start": { "line": 30, "column": 6 }, | |
"end": { "line": 45, "column": 6 } | |
}, | |
"range": [833, 1303] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment