Files
modeling-app/rust/kcl-lib/tests/kcl_samples/walkie-talkie/ast.snap
Nick Cameron 461a2c3ab2 Support comments on attributes (#5850)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2025-03-20 16:23:20 +13:00

1078 lines
30 KiB
Plaintext

---
source: kcl-lib/src/simulation_tests.rs
description: Result of parsing walkie-talkie.kcl
---
{
"Ok": {
"body": [
{
"commentStart": 383,
"end": 0,
"path": {
"type": "Kcl",
"filename": "body.kcl"
},
"preComments": [
"// Import parts and constants"
],
"selector": {
"type": "None",
"alias": null
},
"start": 0,
"type": "ImportStatement",
"type": "ImportStatement"
},
{
"commentStart": 433,
"end": 0,
"path": {
"type": "Kcl",
"filename": "antenna.kcl"
},
"selector": {
"type": "None",
"alias": null
},
"start": 0,
"type": "ImportStatement",
"type": "ImportStatement"
},
{
"commentStart": 454,
"end": 0,
"path": {
"type": "Kcl",
"filename": "case.kcl"
},
"selector": {
"type": "None",
"alias": null
},
"start": 0,
"type": "ImportStatement",
"type": "ImportStatement"
},
{
"commentStart": 472,
"end": 0,
"path": {
"type": "Kcl",
"filename": "talk-button.kcl"
},
"selector": {
"type": "None",
"alias": {
"commentStart": 500,
"end": 0,
"name": "talkButton",
"start": 0,
"type": "Identifier"
}
},
"start": 0,
"type": "ImportStatement",
"type": "ImportStatement"
},
{
"commentStart": 511,
"end": 0,
"path": {
"type": "Kcl",
"filename": "knob.kcl"
},
"selector": {
"type": "None",
"alias": null
},
"start": 0,
"type": "ImportStatement",
"type": "ImportStatement"
},
{
"commentStart": 529,
"end": 0,
"path": {
"type": "Kcl",
"filename": "button.kcl"
},
"selector": {
"type": "List",
"items": [
{
"alias": null,
"commentStart": 536,
"end": 0,
"name": {
"commentStart": 536,
"end": 0,
"name": "button",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ImportItem"
}
]
},
"start": 0,
"type": "ImportStatement",
"type": "ImportStatement"
},
{
"commentStart": 561,
"end": 0,
"path": {
"type": "Kcl",
"filename": "globals.kcl"
},
"selector": {
"type": "List",
"items": [
{
"alias": null,
"commentStart": 568,
"end": 0,
"name": {
"commentStart": 568,
"end": 0,
"name": "width",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ImportItem"
},
{
"alias": null,
"commentStart": 575,
"end": 0,
"name": {
"commentStart": 575,
"end": 0,
"name": "height",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ImportItem"
},
{
"alias": null,
"commentStart": 583,
"end": 0,
"name": {
"commentStart": 583,
"end": 0,
"name": "thickness",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ImportItem"
},
{
"alias": null,
"commentStart": 594,
"end": 0,
"name": {
"commentStart": 594,
"end": 0,
"name": "screenWidth",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ImportItem"
},
{
"alias": null,
"commentStart": 607,
"end": 0,
"name": {
"commentStart": 607,
"end": 0,
"name": "screenHeight",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ImportItem"
},
{
"alias": null,
"commentStart": 621,
"end": 0,
"name": {
"commentStart": 621,
"end": 0,
"name": "screenYPosition",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ImportItem"
},
{
"alias": null,
"commentStart": 638,
"end": 0,
"name": {
"commentStart": 638,
"end": 0,
"name": "tolerance",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ImportItem"
}
]
},
"start": 0,
"type": "ImportStatement",
"type": "ImportStatement"
},
{
"commentStart": 666,
"end": 0,
"expression": {
"commentStart": 687,
"end": 0,
"name": "body",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"preComments": [
"",
"",
"// Import the body"
],
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"commentStart": 691,
"end": 0,
"expression": {
"commentStart": 712,
"end": 0,
"name": "case",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"preComments": [
"",
"",
"// Import the case"
],
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"commentStart": 716,
"end": 0,
"expression": {
"commentStart": 740,
"end": 0,
"name": "antenna",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"preComments": [
"",
"",
"// Import the antenna"
],
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"commentStart": 747,
"end": 0,
"expression": {
"arguments": [
{
"commentStart": 778,
"elements": [
{
"argument": {
"commentStart": 784,
"end": 0,
"left": {
"commentStart": 784,
"end": 0,
"left": {
"commentStart": 784,
"end": 0,
"name": "screenWidth",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"commentStart": 798,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"operator": "+",
"right": {
"commentStart": 802,
"end": 0,
"name": "tolerance",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"commentStart": 782,
"end": 0,
"operator": "-",
"start": 0,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"commentStart": 816,
"end": 0,
"name": "screenYPosition",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"commentStart": 835,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 856,
"end": 0,
"name": "offset",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 865,
"end": 0,
"name": "thickness",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
}
],
"callee": {
"commentStart": 838,
"end": 0,
"name": "offsetPlane",
"start": 0,
"type": "Identifier"
},
"commentStart": 838,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 850,
"end": 0,
"raw": "\"XZ\"",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "XZ"
}
}
],
"callee": {
"commentStart": 771,
"end": 0,
"name": "button",
"start": 0,
"type": "Identifier"
},
"commentStart": 771,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"preComments": [
"",
"",
"// Import the buttons"
],
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"commentStart": 877,
"end": 0,
"expression": {
"arguments": [
{
"commentStart": 884,
"elements": [
{
"argument": {
"commentStart": 890,
"end": 0,
"left": {
"commentStart": 890,
"end": 0,
"left": {
"commentStart": 890,
"end": 0,
"name": "screenWidth",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"commentStart": 904,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"operator": "+",
"right": {
"commentStart": 908,
"end": 0,
"name": "tolerance",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"commentStart": 888,
"end": 0,
"operator": "-",
"start": 0,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"commentStart": 922,
"end": 0,
"left": {
"commentStart": 922,
"end": 0,
"name": "screenYPosition",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "-",
"right": {
"commentStart": 941,
"end": 0,
"left": {
"commentStart": 941,
"end": 0,
"name": "screenHeight",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"commentStart": 956,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"commentStart": 962,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 983,
"end": 0,
"name": "offset",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 992,
"end": 0,
"name": "thickness",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
}
],
"callee": {
"commentStart": 965,
"end": 0,
"name": "offsetPlane",
"start": 0,
"type": "Identifier"
},
"commentStart": 965,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 977,
"end": 0,
"raw": "\"XZ\"",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "XZ"
}
}
],
"callee": {
"commentStart": 877,
"end": 0,
"name": "button",
"start": 0,
"type": "Identifier"
},
"commentStart": 877,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"commentStart": 1004,
"end": 0,
"expression": {
"arguments": [
{
"commentStart": 1011,
"elements": [
{
"commentStart": 1015,
"end": 0,
"left": {
"commentStart": 1015,
"end": 0,
"left": {
"commentStart": 1015,
"end": 0,
"name": "screenWidth",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"commentStart": 1029,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"operator": "+",
"right": {
"commentStart": 1033,
"end": 0,
"name": "tolerance",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"commentStart": 1046,
"end": 0,
"left": {
"commentStart": 1046,
"end": 0,
"name": "screenYPosition",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "-",
"right": {
"commentStart": 1064,
"end": 0,
"name": "screenHeight",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"commentStart": 1080,
"end": 0,
"raw": "180",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 180.0,
"suffix": "None"
}
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 1103,
"end": 0,
"name": "offset",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 1112,
"end": 0,
"name": "thickness",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
}
],
"callee": {
"commentStart": 1085,
"end": 0,
"name": "offsetPlane",
"start": 0,
"type": "Identifier"
},
"commentStart": 1085,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 1097,
"end": 0,
"raw": "\"XZ\"",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "XZ"
}
}
],
"callee": {
"commentStart": 1004,
"end": 0,
"name": "button",
"start": 0,
"type": "Identifier"
},
"commentStart": 1004,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"commentStart": 1124,
"end": 0,
"expression": {
"arguments": [
{
"commentStart": 1131,
"elements": [
{
"commentStart": 1135,
"end": 0,
"left": {
"commentStart": 1135,
"end": 0,
"left": {
"commentStart": 1135,
"end": 0,
"name": "screenWidth",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"commentStart": 1149,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"operator": "+",
"right": {
"commentStart": 1153,
"end": 0,
"name": "tolerance",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"commentStart": 1166,
"end": 0,
"left": {
"commentStart": 1166,
"end": 0,
"name": "screenYPosition",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "-",
"right": {
"commentStart": 1185,
"end": 0,
"left": {
"commentStart": 1185,
"end": 0,
"name": "screenHeight",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"commentStart": 1200,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"commentStart": 1206,
"end": 0,
"raw": "180",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 180.0,
"suffix": "None"
}
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 1229,
"end": 0,
"name": "offset",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 1238,
"end": 0,
"name": "thickness",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
}
],
"callee": {
"commentStart": 1211,
"end": 0,
"name": "offsetPlane",
"start": 0,
"type": "Identifier"
},
"commentStart": 1211,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": {
"commentStart": 1223,
"end": 0,
"raw": "\"XZ\"",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "XZ"
}
}
],
"callee": {
"commentStart": 1124,
"end": 0,
"name": "button",
"start": 0,
"type": "Identifier"
},
"commentStart": 1124,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"commentStart": 1249,
"end": 0,
"expression": {
"commentStart": 1277,
"end": 0,
"name": "talkButton",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"preComments": [
"",
"",
"// Import the talk button"
],
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"commentStart": 1289,
"end": 0,
"expression": {
"commentStart": 1320,
"end": 0,
"name": "knob",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"preComments": [
"",
"",
"// Import the frequency knob"
],
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"commentStart": 0,
"end": 0,
"innerAttrs": [
{
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 351,
"end": 0,
"name": "settings",
"start": 0,
"type": "Identifier"
},
"preComments": [
"// Walkie Talkie",
"// A portable, handheld two-way radio device that allows users to communicate wirelessly over short to medium distances. It operates on specific radio frequencies and features a push-to-talk button for transmitting messages, making it ideal for quick and reliable communication in outdoor, work, or emergency settings.",
"",
"",
"// Set units"
],
"properties": [
{
"commentStart": 360,
"end": 0,
"key": {
"commentStart": 360,
"end": 0,
"name": "defaultLengthUnit",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"commentStart": 380,
"end": 0,
"name": "in",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
}
],
"start": 0,
"type": "Annotation"
}
],
"nonCodeMeta": {
"nonCodeNodes": {
"15": [
{
"commentStart": 1324,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": [
{
"commentStart": 383,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"start": 0
}
}