Files
modeling-app/rust/kcl-lib/tests/kcl_samples/hex-nut/ast.snap
Nick Cameron dddcd5ff46 Support paths to names rather than just raw idents (#5778)
* Support paths to names rather than just raw idents

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-24 20:58:55 +13:00

1303 lines
51 KiB
Plaintext

---
source: kcl-lib/src/simulation_tests.rs
description: Result of parsing hex-nut.kcl
---
{
"Ok": {
"body": [
{
"commentStart": 350,
"declaration": {
"commentStart": 397,
"end": 0,
"id": {
"commentStart": 397,
"end": 0,
"name": "wallToWallLength",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 416,
"end": 0,
"raw": "0.5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.5,
"suffix": "None"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"preComments": [
"// Define constants (5/16\" - 24 thread size)"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 420,
"declaration": {
"commentStart": 420,
"end": 0,
"id": {
"commentStart": 420,
"end": 0,
"name": "thickness",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 432,
"end": 0,
"raw": "0.266",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.266,
"suffix": "None"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 438,
"declaration": {
"commentStart": 438,
"end": 0,
"id": {
"commentStart": 438,
"end": 0,
"name": "diameter",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 449,
"end": 0,
"raw": "0.3125",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.3125,
"suffix": "None"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 455,
"declaration": {
"commentStart": 497,
"end": 0,
"id": {
"commentStart": 497,
"end": 0,
"name": "hexNut",
"start": 0,
"type": "Identifier"
},
"init": {
"body": {
"body": [
{
"commentStart": 530,
"declaration": {
"commentStart": 530,
"end": 0,
"id": {
"commentStart": 530,
"end": 0,
"name": "hexNutSketch",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"commentStart": 559,
"end": 0,
"raw": "'-XZ'",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "-XZ"
}
],
"callee": {
"abs_path": false,
"commentStart": 545,
"end": 0,
"name": {
"commentStart": 545,
"end": 0,
"name": "startSketchOn",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 545,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"commentStart": 588,
"elements": [
{
"commentStart": 589,
"end": 0,
"left": {
"commentStart": 589,
"computed": false,
"end": 0,
"object": {
"commentStart": 589,
"end": 0,
"name": "start",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 595,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"start": 0,
"type": "MemberExpression",
"type": "MemberExpression"
},
"operator": "+",
"right": {
"abs_path": false,
"commentStart": 600,
"end": 0,
"name": {
"commentStart": 600,
"end": 0,
"name": "innerDia",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"commentStart": 610,
"computed": false,
"end": 0,
"object": {
"commentStart": 610,
"end": 0,
"name": "start",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 616,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "MemberExpression",
"type": "MemberExpression"
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"commentStart": 621,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"abs_path": false,
"commentStart": 573,
"end": 0,
"name": {
"commentStart": 573,
"end": 0,
"name": "startProfileAt",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 573,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"commentStart": 642,
"end": 0,
"properties": [
{
"commentStart": 644,
"end": 0,
"key": {
"commentStart": 644,
"end": 0,
"name": "angle",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"commentStart": 652,
"end": 0,
"raw": "240",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 240.0,
"suffix": "None"
}
}
},
{
"commentStart": 657,
"end": 0,
"key": {
"commentStart": 657,
"end": 0,
"name": "length",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"abs_path": false,
"commentStart": 666,
"end": 0,
"name": {
"commentStart": 666,
"end": 0,
"name": "innerDia",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
}
],
"start": 0,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"commentStart": 678,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"abs_path": false,
"commentStart": 631,
"end": 0,
"name": {
"commentStart": 631,
"end": 0,
"name": "angledLine",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 631,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"commentStart": 699,
"end": 0,
"properties": [
{
"commentStart": 701,
"end": 0,
"key": {
"commentStart": 701,
"end": 0,
"name": "angle",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"commentStart": 709,
"end": 0,
"raw": "180",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 180.0,
"suffix": "None"
}
}
},
{
"commentStart": 714,
"end": 0,
"key": {
"commentStart": 714,
"end": 0,
"name": "length",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"abs_path": false,
"commentStart": 723,
"end": 0,
"name": {
"commentStart": 723,
"end": 0,
"name": "innerDia",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
}
],
"start": 0,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"commentStart": 735,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"abs_path": false,
"commentStart": 688,
"end": 0,
"name": {
"commentStart": 688,
"end": 0,
"name": "angledLine",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 688,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"commentStart": 756,
"end": 0,
"properties": [
{
"commentStart": 758,
"end": 0,
"key": {
"commentStart": 758,
"end": 0,
"name": "angle",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"commentStart": 766,
"end": 0,
"raw": "120",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 120.0,
"suffix": "None"
}
}
},
{
"commentStart": 771,
"end": 0,
"key": {
"commentStart": 771,
"end": 0,
"name": "length",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"abs_path": false,
"commentStart": 780,
"end": 0,
"name": {
"commentStart": 780,
"end": 0,
"name": "innerDia",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
}
],
"start": 0,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"commentStart": 792,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"abs_path": false,
"commentStart": 745,
"end": 0,
"name": {
"commentStart": 745,
"end": 0,
"name": "angledLine",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 745,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"commentStart": 813,
"end": 0,
"properties": [
{
"commentStart": 815,
"end": 0,
"key": {
"commentStart": 815,
"end": 0,
"name": "angle",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"commentStart": 823,
"end": 0,
"raw": "60",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 60.0,
"suffix": "None"
}
}
},
{
"commentStart": 827,
"end": 0,
"key": {
"commentStart": 827,
"end": 0,
"name": "length",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"abs_path": false,
"commentStart": 836,
"end": 0,
"name": {
"commentStart": 836,
"end": 0,
"name": "innerDia",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
}
],
"start": 0,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"commentStart": 848,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"abs_path": false,
"commentStart": 802,
"end": 0,
"name": {
"commentStart": 802,
"end": 0,
"name": "angledLine",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 802,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"commentStart": 869,
"end": 0,
"properties": [
{
"commentStart": 871,
"end": 0,
"key": {
"commentStart": 871,
"end": 0,
"name": "angle",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"commentStart": 879,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
},
{
"commentStart": 882,
"end": 0,
"key": {
"commentStart": 882,
"end": 0,
"name": "length",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"commentStart": 891,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 891,
"end": 0,
"name": {
"commentStart": 891,
"end": 0,
"name": "innerDia",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"operator": "*",
"right": {
"commentStart": 902,
"end": 0,
"raw": ".90",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.9,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
}
],
"start": 0,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"commentStart": 909,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"abs_path": false,
"commentStart": 858,
"end": 0,
"name": {
"commentStart": 858,
"end": 0,
"name": "angledLine",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 858,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [],
"callee": {
"abs_path": false,
"commentStart": 919,
"end": 0,
"name": {
"commentStart": 919,
"end": 0,
"name": "close",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 919,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 956,
"end": 0,
"name": "center",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 965,
"elements": [
{
"commentStart": 966,
"computed": false,
"end": 0,
"object": {
"commentStart": 966,
"end": 0,
"name": "start",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 972,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
"start": 0,
"type": "MemberExpression",
"type": "MemberExpression"
},
{
"commentStart": 976,
"computed": false,
"end": 0,
"object": {
"commentStart": 976,
"end": 0,
"name": "start",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"commentStart": 982,
"end": 0,
"raw": "1",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 1.0,
"suffix": "None"
}
},
"start": 0,
"type": "MemberExpression",
"type": "MemberExpression"
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 996,
"end": 0,
"name": "radius",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 1005,
"end": 0,
"left": {
"abs_path": false,
"commentStart": 1005,
"end": 0,
"name": {
"commentStart": 1005,
"end": 0,
"name": "innerDia",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"operator": "/",
"right": {
"commentStart": 1016,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
}
],
"callee": {
"abs_path": false,
"commentStart": 939,
"end": 0,
"name": {
"commentStart": 939,
"end": 0,
"name": "circle",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 939,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
},
{
"commentStart": 1028,
"end": 0,
"start": 0,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"abs_path": false,
"commentStart": 934,
"end": 0,
"name": {
"commentStart": 934,
"end": 0,
"name": "hole",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 934,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 1046,
"end": 0,
"name": "length",
"start": 0,
"type": "Identifier"
},
"arg": {
"abs_path": false,
"commentStart": 1055,
"end": 0,
"name": {
"commentStart": 1055,
"end": 0,
"name": "thk",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
}
],
"callee": {
"abs_path": false,
"commentStart": 1038,
"end": 0,
"name": {
"commentStart": 1038,
"end": 0,
"name": "extrude",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 1038,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
}
],
"commentStart": 545,
"end": 0,
"start": 0,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"argument": {
"abs_path": false,
"commentStart": 1069,
"end": 0,
"name": {
"commentStart": 1069,
"end": 0,
"name": "hexNutSketch",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
"commentStart": 1062,
"end": 0,
"start": 0,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"commentStart": 526,
"end": 0,
"start": 0
},
"commentStart": 503,
"end": 0,
"params": [
{
"type": "Parameter",
"identifier": {
"commentStart": 504,
"end": 0,
"name": "start",
"start": 0,
"type": "Identifier"
}
},
{
"type": "Parameter",
"identifier": {
"commentStart": 511,
"end": 0,
"name": "thk",
"start": 0,
"type": "Identifier"
}
},
{
"type": "Parameter",
"identifier": {
"commentStart": 516,
"end": 0,
"name": "innerDia",
"start": 0,
"type": "Identifier"
}
}
],
"start": 0,
"type": "FunctionExpression",
"type": "FunctionExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "fn",
"preComments": [
"",
"",
"// Define a function for the hex nut"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 1083,
"end": 0,
"expression": {
"arguments": [
{
"commentStart": 1112,
"elements": [
{
"commentStart": 1113,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"commentStart": 1116,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"abs_path": false,
"commentStart": 1120,
"end": 0,
"name": {
"commentStart": 1120,
"end": 0,
"name": "thickness",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
},
{
"abs_path": false,
"commentStart": 1131,
"end": 0,
"name": {
"commentStart": 1131,
"end": 0,
"name": "diameter",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
],
"callee": {
"abs_path": false,
"commentStart": 1105,
"end": 0,
"name": {
"commentStart": 1105,
"end": 0,
"name": "hexNut",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name"
},
"commentStart": 1105,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"preComments": [
"",
"",
"// Create a hex nut"
],
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"commentStart": 0,
"end": 0,
"innerAttrs": [
{
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 318,
"end": 0,
"name": "settings",
"start": 0,
"type": "Identifier"
},
"preComments": [
"// Hex nut",
"// A hex nut is a type of fastener with a threaded hole and a hexagonal outer shape, used in a wide variety of applications to secure parts together. The hexagonal shape allows for a greater torque to be applied with wrenches or tools, making it one of the most common nut types in hardware.",
"",
"",
"// Set Units"
],
"properties": [
{
"commentStart": 327,
"end": 0,
"key": {
"commentStart": 327,
"end": 0,
"name": "defaultLengthUnit",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"abs_path": false,
"commentStart": 347,
"end": 0,
"name": {
"commentStart": 347,
"end": 0,
"name": "in",
"start": 0,
"type": "Identifier"
},
"path": [],
"start": 0,
"type": "Name",
"type": "Name"
}
}
],
"start": 0,
"type": "Annotation"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"startNodes": [
{
"commentStart": 350,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"start": 0
}
}