Files
modeling-app/rust/kcl-lib/tests/bad_units_in_annotation/ast.snap

910 lines
26 KiB
Plaintext
Raw Normal View History

---
source: kcl-lib/src/simulation_tests.rs
description: Result of parsing bad_units_in_annotation.kcl
---
{
"Ok": {
"body": [
{
"commentStart": 33,
"declaration": {
"commentStart": 123,
"end": 0,
"id": {
"commentStart": 123,
"end": 0,
"name": "oxygenRadius",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 138,
"end": 0,
"raw": "0.066",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.066,
"suffix": "None"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"preComments": [
"// Generated by Text-to-CAD: draw a water molecule",
"",
"",
"// Constants for the water molecule"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 143,
"declaration": {
"commentStart": 184,
"end": 0,
"id": {
"commentStart": 184,
"end": 0,
"name": "hydrogenRadius",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 201,
"end": 0,
"raw": "0.053",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.053,
"suffix": "None"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 206,
"declaration": {
"commentStart": 248,
"end": 0,
"id": {
"commentStart": 248,
"end": 0,
"name": "oxygenHydrogenDistance",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 273,
"end": 0,
"raw": "0.096",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.096,
"suffix": "None"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 278,
"declaration": {
"commentStart": 337,
"end": 0,
"id": {
"commentStart": 337,
"end": 0,
"name": "bondAngle",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 349,
"end": 0,
"raw": "104.5",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 104.5,
"suffix": "None"
}
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 354,
"declaration": {
"commentStart": 437,
"end": 0,
"id": {
"commentStart": 437,
"end": 0,
"name": "createAtom",
"start": 0,
"type": "Identifier"
},
"init": {
"body": {
"body": [
{
"argument": {
"body": [
{
"arguments": [
{
"commentStart": 489,
"end": 0,
"raw": "'XY'",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"commentStart": 475,
"end": 0,
"name": "startSketchOn",
"start": 0,
"type": "Identifier"
},
"commentStart": 475,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 509,
"end": 0,
"name": "center",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 518,
"end": 0,
"name": "center",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
},
{
"type": "LabeledArg",
"label": {
"commentStart": 526,
"end": 0,
"name": "radius",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 535,
"end": 0,
"name": "radius",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
}
],
"callee": {
"commentStart": 502,
"end": 0,
"name": "circle",
"start": 0,
"type": "Identifier"
},
"commentStart": 502,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
},
{
"arguments": [
{
"type": "LabeledArg",
"label": {
"commentStart": 558,
"end": 0,
"name": "length",
"start": 0,
"type": "Identifier"
},
"arg": {
"commentStart": 567,
"end": 0,
"left": {
"commentStart": 567,
"end": 0,
"name": "radius",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "*",
"right": {
"commentStart": 576,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
}
],
"callee": {
"commentStart": 550,
"end": 0,
"name": "extrude",
"start": 0,
"type": "Identifier"
},
"commentStart": 550,
"end": 0,
"start": 0,
"type": "CallExpressionKw",
"type": "CallExpressionKw",
"unlabeled": null
}
],
"commentStart": 475,
"end": 0,
"start": 0,
"type": "PipeExpression",
"type": "PipeExpression"
},
"commentStart": 468,
"end": 0,
"start": 0,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"commentStart": 464,
"end": 0,
"start": 0
},
"commentStart": 447,
"end": 0,
"params": [
{
"type": "Parameter",
"identifier": {
"commentStart": 448,
"end": 0,
"name": "center",
"start": 0,
"type": "Identifier"
}
},
{
"type": "Parameter",
"identifier": {
"commentStart": 456,
"end": 0,
"name": "radius",
"start": 0,
"type": "Identifier"
}
}
],
"start": 0,
"type": "FunctionExpression",
"type": "FunctionExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "fn",
"preComments": [
"// Function to create a sphere representing an atom"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 580,
"declaration": {
"commentStart": 622,
"end": 0,
"id": {
"commentStart": 622,
"end": 0,
"name": "oxygenAtom",
"start": 0,
"type": "Identifier"
},
"init": {
"arguments": [
{
"commentStart": 646,
"elements": [
{
"commentStart": 647,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
},
{
"commentStart": 650,
"end": 0,
"raw": "0",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 0.0,
"suffix": "None"
}
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"commentStart": 654,
"end": 0,
"name": "oxygenRadius",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"commentStart": 635,
"end": 0,
"name": "createAtom",
"start": 0,
"type": "Identifier"
},
"commentStart": 635,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"preComments": [
"",
"",
"// Create the oxygen atom at the origin"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 667,
"declaration": {
"commentStart": 718,
"end": 0,
"id": {
"commentStart": 718,
"end": 0,
"name": "hydrogenOffsetX",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 736,
"end": 0,
"left": {
"commentStart": 736,
"end": 0,
"name": "oxygenHydrogenDistance",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "*",
"right": {
"arguments": [
{
"arguments": [
{
"commentStart": 775,
"end": 0,
"left": {
"commentStart": 775,
"end": 0,
"name": "bondAngle",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"commentStart": 787,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"callee": {
"commentStart": 765,
"end": 0,
"name": "toRadians",
"start": 0,
"type": "Identifier"
},
"commentStart": 765,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
}
],
"callee": {
"commentStart": 761,
"end": 0,
"name": "cos",
"start": 0,
"type": "Identifier"
},
"commentStart": 761,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"preComments": [
"",
"",
"// Calculate the positions of the hydrogen atoms"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 791,
"declaration": {
"commentStart": 791,
"end": 0,
"id": {
"commentStart": 791,
"end": 0,
"name": "hydrogenOffsetY",
"start": 0,
"type": "Identifier"
},
"init": {
"commentStart": 809,
"end": 0,
"left": {
"commentStart": 809,
"end": 0,
"name": "oxygenHydrogenDistance",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "*",
"right": {
"arguments": [
{
"arguments": [
{
"commentStart": 848,
"end": 0,
"left": {
"commentStart": 848,
"end": 0,
"name": "bondAngle",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"commentStart": 860,
"end": 0,
"raw": "2",
"start": 0,
"type": "Literal",
"type": "Literal",
"value": {
"value": 2.0,
"suffix": "None"
}
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"callee": {
"commentStart": 838,
"end": 0,
"name": "toRadians",
"start": 0,
"type": "Identifier"
},
"commentStart": 838,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
}
],
"callee": {
"commentStart": 834,
"end": 0,
"name": "sin",
"start": 0,
"type": "Identifier"
},
"commentStart": 834,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 863,
"declaration": {
"commentStart": 894,
"end": 0,
"id": {
"commentStart": 894,
"end": 0,
"name": "hydrogenAtom1",
"start": 0,
"type": "Identifier"
},
"init": {
"arguments": [
{
"commentStart": 921,
"elements": [
{
"commentStart": 922,
"end": 0,
"name": "hydrogenOffsetX",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
{
"commentStart": 939,
"end": 0,
"name": "hydrogenOffsetY",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"commentStart": 957,
"end": 0,
"name": "hydrogenRadius",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"commentStart": 910,
"end": 0,
"name": "createAtom",
"start": 0,
"type": "Identifier"
},
"commentStart": 910,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"preComments": [
"",
"",
"// Create the hydrogen atoms"
],
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"commentStart": 973,
"declaration": {
"commentStart": 973,
"end": 0,
"id": {
"commentStart": 973,
"end": 0,
"name": "hydrogenAtom2",
"start": 0,
"type": "Identifier"
},
"init": {
"arguments": [
{
"commentStart": 1000,
"elements": [
{
"argument": {
"commentStart": 1002,
"end": 0,
"name": "hydrogenOffsetX",
"start": 0,
"type": "Identifier",
"type": "Identifier"
},
"commentStart": 1001,
"end": 0,
"operator": "-",
"start": 0,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"commentStart": 1019,
"end": 0,
"name": "hydrogenOffsetY",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
],
"end": 0,
"start": 0,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"commentStart": 1037,
"end": 0,
"name": "hydrogenRadius",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"commentStart": 989,
"end": 0,
"name": "createAtom",
"start": 0,
"type": "Identifier"
},
"commentStart": 989,
"end": 0,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "VariableDeclarator"
},
"end": 0,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"commentStart": 0,
"end": 0,
"innerAttrs": [
{
"commentStart": 0,
"end": 0,
"name": {
"commentStart": 1,
"end": 0,
"name": "settings",
"start": 0,
"type": "Identifier"
},
"properties": [
{
"commentStart": 10,
"end": 0,
"key": {
"commentStart": 10,
"end": 0,
"name": "defaultLengthUnit",
"start": 0,
"type": "Identifier"
},
"start": 0,
"type": "ObjectProperty",
"value": {
"commentStart": 30,
"end": 0,
"name": "nm",
"start": 0,
"type": "Identifier",
"type": "Identifier"
}
}
],
"start": 0,
"type": "Annotation"
}
],
"nonCodeMeta": {
"nonCodeNodes": {
"0": [
{
"commentStart": 143,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "inlineComment",
"value": "Approximate radius of an oxygen atom",
"style": "line"
}
}
],
"1": [
{
"commentStart": 206,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "inlineComment",
"value": "Approximate radius of a hydrogen atom",
"style": "line"
}
}
],
"2": [
{
"commentStart": 278,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "inlineComment",
"value": "Approximate distance between oxygen and hydrogen atoms",
"style": "line"
}
}
],
"3": [
{
"commentStart": 354,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "inlineComment",
"value": "Bond angle in degrees",
"style": "line"
}
},
{
"commentStart": 379,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": [
{
"commentStart": 33,
"end": 0,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"start": 0
}
}