Merge branch 'main' into cut-release-v0.26.6

This commit is contained in:
Pierre Jacquier
2024-11-19 13:58:12 +01:00
committed by GitHub
255 changed files with 366812 additions and 924 deletions

File diff suppressed because one or more lines are too long

41
docs/kcl/arcTo.md Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,7 @@ layout: manual
## Table of Contents
* [Types](kcl/types)
* [Modules](kcl/modules)
* [Known Issues](kcl/KNOWN-ISSUES)
* [`abs`](kcl/abs)
* [`acos`](kcl/acos)
@ -19,6 +20,7 @@ layout: manual
* [`angledLineToX`](kcl/angledLineToX)
* [`angledLineToY`](kcl/angledLineToY)
* [`arc`](kcl/arc)
* [`arcTo`](kcl/arcTo)
* [`asin`](kcl/asin)
* [`assert`](kcl/assert)
* [`assertEqual`](kcl/assertEqual)

View File

@ -9,7 +9,7 @@ Offset a plane by a distance along its normal.
For example, if you offset the 'XZ' plane by 10, the new plane will be parallel to the 'XZ' plane and 10 units away from it.
```js
offsetPlane(std_plane: StandardPlane, offset: number) -> PlaneData
offsetPlane(std_plane: StandardPlane, offset: number) -> Plane
```
@ -22,7 +22,7 @@ offsetPlane(std_plane: StandardPlane, offset: number) -> PlaneData
### Returns
[`PlaneData`](/docs/kcl/types/PlaneData) - Data for a plane.
[`Plane`](/docs/kcl/types/Plane) - A plane.
### Examples

View File

@ -36,15 +36,15 @@ fn add = (a, b) => {
// This function adds an array of numbers.
// It uses the `reduce` function, to call the `add` function on every
// element of the `array` parameter. The starting value is 0.
fn sum = (array) => {
return reduce(array, 0, add)
// element of the `arr` parameter. The starting value is 0.
fn sum = (arr) => {
return reduce(arr, 0, add)
}
/* The above is basically like this pseudo-code:
fn sum(array):
fn sum(arr):
let sumSoFar = 0
for i in array:
for i in arr:
sumSoFar = add(sumSoFar, i)
return sumSoFar */
@ -60,8 +60,8 @@ assertEqual(sum([1, 2, 3]), 6, 0.00001, "1 + 2 + 3 summed is 6")
// This example works just like the previous example above, but it uses
// an anonymous `add` function as its parameter, instead of declaring a
// named function outside.
array = [1, 2, 3]
sum = reduce(array, 0, (i, result_so_far) => {
arr = [1, 2, 3]
sum = reduce(arr, 0, (i, result_so_far) => {
return i + result_so_far
})

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
---
title: "ArcToData"
excerpt: "Data to draw a three point arc (arcTo)."
layout: manual
---
Data to draw a three point arc (arcTo).
**Type:** `object`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `end` |`[number, number]`| End point of the arc. A point in 3D space | No |
| `interior` |`[number, number]`| Interior point of the arc. A point in 3D space | No |

View File

@ -180,7 +180,7 @@ A plane.
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `type` |enum: `Plane`| | No |
| `type` |enum: [`Plane`](/docs/kcl/types/Plane)| | No |
| `id` |`string`| The id of the plane. | No |
| `value` |[`PlaneType`](/docs/kcl/types/PlaneType)| Any KCL value. | No |
| `origin` |[`Point3d`](/docs/kcl/types/Point3d)| Origin of the plane. | No |

27
docs/kcl/types/Plane.md Normal file
View File

@ -0,0 +1,27 @@
---
title: "Plane"
excerpt: "A plane."
layout: manual
---
A plane.
**Type:** `object`
## Properties
| Property | Type | Description | Required |
|----------|------|-------------|----------|
| `id` |`string`| The id of the plane. | No |
| `value` |[`PlaneType`](/docs/kcl/types/PlaneType)| A plane. | No |
| `origin` |[`Point3d`](/docs/kcl/types/Point3d)| Origin of the plane. | No |
| `xAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the planes X axis be? | No |
| `yAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the planes Y axis be? | No |
| `zAxis` |[`Point3d`](/docs/kcl/types/Point3d)| The z-axis (normal). | No |
| `__meta` |`[` [`Metadata`](/docs/kcl/types/Metadata) `]`| | No |

View File

@ -1,10 +1,10 @@
---
title: "PlaneData"
excerpt: "Data for a plane."
excerpt: "Orientation data that can be used to construct a plane, not a plane in itself."
layout: manual
---
Data for a plane.
Orientation data that can be used to construct a plane, not a plane in itself.

View File

@ -22,6 +22,18 @@ Data for start sketch on. You can start a sketch on a plane or an solid.
----
Data for start sketch on. You can start a sketch on a plane or an solid.
[`Plane`](/docs/kcl/types/Plane)
----
Data for start sketch on. You can start a sketch on a plane or an solid.

View File

@ -1135,3 +1135,189 @@ _test.describe('Deleting items from the file pane', () => {
}
)
})
_test.describe(
'Undo and redo do not keep history when navigating between files',
() => {
_test(
`open a file, change something, open a different file, hitting undo should do nothing`,
{ tag: '@electron' },
async ({ browserName }, testInfo) => {
const { page } = await setupElectron({
testInfo,
folderSetupFn: async (dir) => {
const testDir = join(dir, 'testProject')
await fsp.mkdir(testDir, { recursive: true })
await fsp.copyFile(
executorInputPath('cylinder.kcl'),
join(testDir, 'main.kcl')
)
await fsp.copyFile(
executorInputPath('basic_fillet_cube_end.kcl'),
join(testDir, 'other.kcl')
)
},
})
const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 })
page.on('console', console.log)
// Constants and locators
const projectCard = page.getByText('testProject')
const otherFile = page
.getByRole('listitem')
.filter({ has: page.getByRole('button', { name: 'other.kcl' }) })
await _test.step(
'Open project and make a change to the file',
async () => {
await projectCard.click()
await u.waitForPageLoad()
// Get the text in the code locator.
const originalText = await u.codeLocator.innerText()
// Click in the editor and add some new lines.
await u.codeLocator.click()
await page.keyboard.type(`sketch001 = startSketchOn('XY')
some other shit`)
// Ensure the content in the editor changed.
const newContent = await u.codeLocator.innerText()
expect(originalText !== newContent)
}
)
await _test.step('navigate to other.kcl', async () => {
await u.openFilePanel()
await otherFile.click()
await u.waitForPageLoad()
await u.openKclCodePanel()
await _expect(u.codeLocator).toContainText('getOppositeEdge(thing)')
})
await _test.step('hit undo', async () => {
// Get the original content of the file.
const originalText = await u.codeLocator.innerText()
// Now hit undo
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyZ')
await page.keyboard.up('ControlOrMeta')
await page.waitForTimeout(100)
await expect(u.codeLocator).toContainText(originalText)
})
}
)
_test(
`open a file, change something, undo it, open a different file, hitting redo should do nothing`,
{ tag: '@electron' },
// Skip on windows i think the keybindings are different for redo.
async ({ browserName }, testInfo) => {
test.skip(process.platform === 'win32', 'Skip on windows')
const { page } = await setupElectron({
testInfo,
folderSetupFn: async (dir) => {
const testDir = join(dir, 'testProject')
await fsp.mkdir(testDir, { recursive: true })
await fsp.copyFile(
executorInputPath('cylinder.kcl'),
join(testDir, 'main.kcl')
)
await fsp.copyFile(
executorInputPath('basic_fillet_cube_end.kcl'),
join(testDir, 'other.kcl')
)
},
})
const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 })
page.on('console', console.log)
// Constants and locators
const projectCard = page.getByText('testProject')
const otherFile = page
.getByRole('listitem')
.filter({ has: page.getByRole('button', { name: 'other.kcl' }) })
const badContent = 'this shit'
await _test.step(
'Open project and make a change to the file',
async () => {
await projectCard.click()
await u.waitForPageLoad()
// Get the text in the code locator.
const originalText = await u.codeLocator.innerText()
// Click in the editor and add some new lines.
await u.codeLocator.click()
await page.keyboard.type(badContent)
// Ensure the content in the editor changed.
const newContent = await u.codeLocator.innerText()
expect(originalText !== newContent)
// Now hit undo
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyZ')
await page.keyboard.up('ControlOrMeta')
await page.waitForTimeout(100)
await expect(u.codeLocator).toContainText(originalText)
await expect(u.codeLocator).not.toContainText(badContent)
// Hit redo.
await page.keyboard.down('Shift')
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyZ')
await page.keyboard.up('ControlOrMeta')
await page.keyboard.up('Shift')
await page.waitForTimeout(100)
await expect(u.codeLocator).toContainText(originalText)
await expect(u.codeLocator).toContainText(badContent)
// Now hit undo
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyZ')
await page.keyboard.up('ControlOrMeta')
await page.waitForTimeout(100)
await expect(u.codeLocator).toContainText(originalText)
await expect(u.codeLocator).not.toContainText(badContent)
}
)
await _test.step('navigate to other.kcl', async () => {
await u.openFilePanel()
await otherFile.click()
await u.waitForPageLoad()
await u.openKclCodePanel()
await _expect(u.codeLocator).toContainText('getOppositeEdge(thing)')
await expect(u.codeLocator).not.toContainText(badContent)
})
await _test.step('hit redo', async () => {
// Get the original content of the file.
const originalText = await u.codeLocator.innerText()
// Now hit redo
await page.keyboard.down('Shift')
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyZ')
await page.keyboard.up('ControlOrMeta')
await page.keyboard.up('Shift')
await page.waitForTimeout(100)
await expect(u.codeLocator).toContainText(originalText)
await expect(u.codeLocator).not.toContainText(badContent)
})
}
)
}
)

View File

@ -1274,3 +1274,44 @@ test2.describe('Sketch mode should be toleratant to syntax errors', () => {
}
)
})
test2.describe(`Sketching with offset planes`, () => {
test2(
`Can select an offset plane to sketch on`,
async ({ app, scene, toolbar, editor }) => {
// We seed the scene with a single offset plane
await app.initialise(`offsetPlane001 = offsetPlane("XY", 10)`)
const [planeClick, planeHover] = scene.makeMouseHelpers(650, 200)
await test2.step(`Start sketching on the offset plane`, async () => {
await toolbar.startSketchPlaneSelection()
await test2.step(`Hovering should highlight code`, async () => {
await planeHover()
await editor.expectState({
activeLines: [`offsetPlane001=offsetPlane("XY",10)`],
diagnostics: [],
highlightedCode: 'offsetPlane("XY", 10)',
})
})
await test2.step(
`Clicking should select the plane and enter sketch mode`,
async () => {
await planeClick()
// Have to wait for engine-side animation to finish
await app.page.waitForTimeout(600)
await expect2(toolbar.lineBtn).toBeEnabled()
await editor.expectEditor.toContain('startSketchOn(offsetPlane001)')
await editor.expectState({
activeLines: [`offsetPlane001=offsetPlane("XY",10)`],
diagnostics: [],
highlightedCode: '',
})
}
)
})
}
)
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -63,6 +63,7 @@ import {
import {
moveValueIntoNewVariablePath,
sketchOnExtrudedFace,
sketchOnOffsetPlane,
startSketchOnDefault,
} from 'lang/modifyAst'
import { Program, parse, recast } from 'lang/wasm'
@ -636,13 +637,16 @@ export const ModelingMachineProvider = ({
),
'animate-to-face': fromPromise(async ({ input }) => {
if (!input) return undefined
if (input.type === 'extrudeFace') {
const sketched = sketchOnExtrudedFace(
kclManager.ast,
input.sketchPathToNode,
input.extrudePathToNode,
input.faceInfo
)
if (input.type === 'extrudeFace' || input.type === 'offsetPlane') {
const sketched =
input.type === 'extrudeFace'
? sketchOnExtrudedFace(
kclManager.ast,
input.sketchPathToNode,
input.extrudePathToNode,
input.faceInfo
)
: sketchOnOffsetPlane(kclManager.ast, input.pathToNode)
if (err(sketched)) {
const sketchedError = new Error(
'Incompatible face, please try another'
@ -654,10 +658,9 @@ export const ModelingMachineProvider = ({
await kclManager.executeAstMock(modifiedAst)
await letEngineAnimateAndSyncCamAfter(
engineCommandManager,
input.faceId
)
const id =
input.type === 'extrudeFace' ? input.faceId : input.planeId
await letEngineAnimateAndSyncCamAfter(engineCommandManager, id)
sceneInfra.camControls.syncDirection = 'clientToEngine'
return {
sketchPathToNode: pathToNewSketchNode,

View File

@ -43,6 +43,7 @@ import {
completionKeymap,
} from '@codemirror/autocomplete'
import CodeEditor from './CodeEditor'
import { codeManagerHistoryCompartment } from 'lang/codeManager'
export const editorShortcutMeta = {
formatCode: {
@ -89,7 +90,7 @@ export const KclEditorPane = () => {
cursorBlinkRate: cursorBlinking.current ? 1200 : 0,
}),
lineHighlightField,
history(),
codeManagerHistoryCompartment.of(history()),
closeBrackets(),
codeFolding(),
keymap.of([
@ -121,7 +122,6 @@ export const KclEditorPane = () => {
lineNumbers(),
highlightActiveLineGutter(),
highlightSpecialChars(),
history(),
foldGutter(),
EditorState.allowMultipleSelections.of(true),
indentOnInput(),

View File

@ -88,6 +88,10 @@ export function useEngineConnectionSubscriptions() {
? [codeRef.range]
: [codeRef.range, consumedCodeRef.range]
)
} else if (artifact?.type === 'plane') {
const codeRef = artifact.codeRef
if (err(codeRef)) return
editorManager.setHighlightRange([codeRef.range])
} else {
editorManager.setHighlightRange([[0, 0]])
}
@ -186,8 +190,42 @@ export function useEngineConnectionSubscriptions() {
})
return
}
const artifact =
engineCommandManager.artifactGraph.get(planeOrFaceId)
if (artifact?.type === 'plane') {
const planeInfo = await getFaceDetails(planeOrFaceId)
sceneInfra.modelingSend({
type: 'Select default plane',
data: {
type: 'offsetPlane',
zAxis: [
planeInfo.z_axis.x,
planeInfo.z_axis.y,
planeInfo.z_axis.z,
],
yAxis: [
planeInfo.y_axis.x,
planeInfo.y_axis.y,
planeInfo.y_axis.z,
],
position: [
planeInfo.origin.x,
planeInfo.origin.y,
planeInfo.origin.z,
].map((num) => num / sceneInfra._baseUnitMultiplier) as [
number,
number,
number
],
planeId: planeOrFaceId,
pathToNode: artifact.codeRef.pathToNode,
},
})
}
// Artifact is likely an extrusion face
const faceId = planeOrFaceId
const artifact = engineCommandManager.artifactGraph.get(faceId)
const extrusion = getSweepFromSuspectedSweepSurface(
faceId,
engineCommandManager.artifactGraph

View File

@ -6,14 +6,17 @@ import { isDesktop } from 'lib/isDesktop'
import toast from 'react-hot-toast'
import { editorManager } from 'lib/singletons'
import { Annotation, Transaction } from '@codemirror/state'
import { KeyBinding } from '@codemirror/view'
import { EditorView, KeyBinding } from '@codemirror/view'
import { recast, Program } from 'lang/wasm'
import { err } from 'lib/trap'
import { Compartment } from '@codemirror/state'
import { history } from '@codemirror/commands'
const PERSIST_CODE_KEY = 'persistCode'
const codeManagerUpdateAnnotation = Annotation.define<boolean>()
export const codeManagerUpdateEvent = codeManagerUpdateAnnotation.of(true)
export const codeManagerHistoryCompartment = new Compartment()
export default class CodeManager {
private _code: string = bracket
@ -90,9 +93,12 @@ export default class CodeManager {
/**
* Update the code in the editor.
*/
updateCodeEditor(code: string): void {
updateCodeEditor(code: string, clearHistory?: boolean): void {
this.code = code
if (editorManager.editorView) {
if (clearHistory) {
clearCodeMirrorHistory(editorManager.editorView)
}
editorManager.editorView.dispatch({
changes: {
from: 0,
@ -101,7 +107,7 @@ export default class CodeManager {
},
annotations: [
codeManagerUpdateEvent,
Transaction.addToHistory.of(true),
Transaction.addToHistory.of(!clearHistory),
],
})
}
@ -110,11 +116,11 @@ export default class CodeManager {
/**
* Update the code, state, and the code the code mirror editor sees.
*/
updateCodeStateEditor(code: string): void {
updateCodeStateEditor(code: string, clearHistory?: boolean): void {
if (this._code !== code) {
this.code = code
this.#updateState(code)
this.updateCodeEditor(code)
this.updateCodeEditor(code, clearHistory)
}
}
@ -167,3 +173,17 @@ function safeLSSetItem(key: string, value: string) {
if (typeof window === 'undefined') return
localStorage?.setItem(key, value)
}
function clearCodeMirrorHistory(view: EditorView) {
// Clear history
view.dispatch({
effects: [codeManagerHistoryCompartment.reconfigure([])],
annotations: [codeManagerUpdateEvent],
})
// Add history back
view.dispatch({
effects: [codeManagerHistoryCompartment.reconfigure([history()])],
annotations: [codeManagerUpdateEvent],
})
}

View File

@ -19,6 +19,7 @@ import {
ProgramMemory,
SourceRange,
sketchFromKclValue,
isPathToNodeNumber,
} from './wasm'
import {
isNodeSafeToReplacePath,
@ -526,6 +527,60 @@ export function sketchOnExtrudedFace(
}
}
/**
* Modify the AST to create a new sketch using the variable declaration
* of an offset plane. The new sketch just has to come after the offset
* plane declaration.
*/
export function sketchOnOffsetPlane(
node: Node<Program>,
offsetPathToNode: PathToNode
) {
let _node = { ...node }
// Find the offset plane declaration
const offsetPlaneDeclarator = getNodeFromPath<VariableDeclarator>(
_node,
offsetPathToNode,
'VariableDeclarator',
true
)
if (err(offsetPlaneDeclarator)) return offsetPlaneDeclarator
const { node: offsetPlaneNode } = offsetPlaneDeclarator
const offsetPlaneName = offsetPlaneNode.id.name
// Create a new sketch declaration
const newSketchName = findUniqueName(
node,
KCL_DEFAULT_CONSTANT_PREFIXES.SKETCH
)
const newSketch = createVariableDeclaration(
newSketchName,
createCallExpressionStdLib('startSketchOn', [
createIdentifier(offsetPlaneName),
]),
undefined,
'const'
)
// Decide where to insert the new sketch declaration
const offsetIndex = offsetPathToNode[1][0]
if (!isPathToNodeNumber(offsetIndex)) {
return new Error('Expected offsetIndex to be a number')
}
// and insert it
_node.body.splice(offsetIndex + 1, 0, newSketch)
const newPathToNode = structuredClone(offsetPathToNode)
newPathToNode[1][0] = offsetIndex + 1
// Return the modified AST and the path to the new sketch declaration
return {
modifiedAst: _node,
pathToNode: newPathToNode,
}
}
export const getLastIndex = (pathToNode: PathToNode): number =>
splitPathAtLastIndex(pathToNode).index

View File

@ -98,12 +98,22 @@ sketch004 = startSketchOn(extrude003, seg02)
|> close(%)
extrude004 = extrude(3, sketch004)
`
const exampleCodeOffsetPlanes = `
offsetPlane001 = offsetPlane("XY", 20)
offsetPlane002 = offsetPlane("XZ", -50)
offsetPlane003 = offsetPlane("YZ", 10)
sketch002 = startSketchOn(offsetPlane001)
|> startProfileAt([0, 0], %)
|> line([6.78, 15.01], %)
`
// add more code snippets here and use `getCommands` to get the orderedCommands and responseMap for more tests
const codeToWriteCacheFor = {
exampleCode1,
sketchOnFaceOnFaceEtc,
exampleCodeNo3D,
exampleCodeOffsetPlanes,
} as const
type CodeKey = keyof typeof codeToWriteCacheFor
@ -165,6 +175,52 @@ afterAll(() => {
})
describe('testing createArtifactGraph', () => {
describe('code with offset planes and a sketch:', () => {
let ast: Program
let theMap: ReturnType<typeof createArtifactGraph>
it('setup', () => {
// putting this logic in here because describe blocks runs before beforeAll has finished
const {
orderedCommands,
responseMap,
ast: _ast,
} = getCommands('exampleCodeOffsetPlanes')
ast = _ast
theMap = createArtifactGraph({ orderedCommands, responseMap, ast })
})
it(`there should be one sketch`, () => {
const sketches = [...filterArtifacts({ types: ['path'] }, theMap)].map(
(path) => expandPath(path[1], theMap)
)
expect(sketches).toHaveLength(1)
sketches.forEach((path) => {
if (err(path)) throw path
expect(path.type).toBe('path')
})
})
it(`there should be three offsetPlanes`, () => {
const offsetPlanes = [
...filterArtifacts({ types: ['plane'] }, theMap),
].map((plane) => expandPlane(plane[1], theMap))
expect(offsetPlanes).toHaveLength(3)
offsetPlanes.forEach((path) => {
expect(path.type).toBe('plane')
})
})
it(`Only one offset plane should have a path`, () => {
const offsetPlanes = [
...filterArtifacts({ types: ['plane'] }, theMap),
].map((plane) => expandPlane(plane[1], theMap))
const offsetPlaneWithPaths = offsetPlanes.filter(
(plane) => plane.paths.length
)
expect(offsetPlaneWithPaths).toHaveLength(1)
})
})
describe('code with an extrusion, fillet and sketch of face:', () => {
let ast: Program
let theMap: ReturnType<typeof createArtifactGraph>

View File

@ -249,7 +249,20 @@ export function getArtifactsToUpdate({
const cmd = command.cmd
const returnArr: ReturnType<typeof getArtifactsToUpdate> = []
if (!response) return returnArr
if (cmd.type === 'enable_sketch_mode') {
if (cmd.type === 'make_plane' && range[1] !== 0) {
// If we're calling `make_plane` and the code range doesn't end at `0`
// it's not a default plane, but a custom one from the offsetPlane standard library function
return [
{
id,
artifact: {
type: 'plane',
pathIds: [],
codeRef: { range, pathToNode },
},
},
]
} else if (cmd.type === 'enable_sketch_mode') {
const plane = getArtifact(currentPlaneId)
const pathIds = plane?.type === 'plane' ? plane?.pathIds : []
const codeRef =

View File

@ -144,6 +144,12 @@ export const parse = (code: string | Error): Node<Program> | Error => {
export type PathToNode = [string | number, string][]
export const isPathToNodeNumber = (
pathToNode: string | number
): pathToNode is number => {
return typeof pathToNode === 'number'
}
export interface ExecState {
memory: ProgramMemory
idGenerator: IdGenerator

View File

@ -124,7 +124,9 @@ export const fileLoader: LoaderFunction = async (
// We explicitly do not write to the file here since we are loading from
// the file system and not the editor.
codeManager.updateCurrentFilePath(currentFilePath)
codeManager.updateCodeStateEditor(code)
// We pass true on the end here to clear the code editor history.
// This way undo and redo are not super weird when opening new files.
codeManager.updateCodeStateEditor(code, true)
}
// Set the file system manager to the project path

View File

@ -159,6 +159,15 @@ export type DefaultPlane = {
yAxis: [number, number, number]
}
export type OffsetPlane = {
type: 'offsetPlane'
position: [number, number, number]
planeId: string
pathToNode: PathToNode
zAxis: [number, number, number]
yAxis: [number, number, number]
}
export type SegmentOverlayPayload =
| {
type: 'set-one'
@ -198,7 +207,7 @@ export type ModelingMachineEvent =
| { type: 'Sketch On Face' }
| {
type: 'Select default plane'
data: DefaultPlane | ExtrudeFacePlane
data: DefaultPlane | ExtrudeFacePlane | OffsetPlane
}
| {
type: 'Set selection'
@ -1394,7 +1403,7 @@ export const modelingMachine = setup({
}
),
'animate-to-face': fromPromise(
async (_: { input?: ExtrudeFacePlane | DefaultPlane }) => {
async (_: { input?: ExtrudeFacePlane | DefaultPlane | OffsetPlane }) => {
return {} as
| undefined
| {

View File

@ -1589,6 +1589,8 @@ dependencies = [
"console",
"lazy_static",
"linked-hash-map",
"pest",
"pest_derive",
"regex",
"serde",
"similar",
@ -1689,6 +1691,7 @@ dependencies = [
"databake",
"derive-docs",
"expectorate",
"fnv",
"form_urlencoded",
"futures",
"git_rev",

View File

@ -9,21 +9,16 @@ new-test name:
lint:
cargo clippy --workspace --all-targets -- -D warnings
# Generate the stdlib image artifacts
# Then run the stdlib docs generation
redo-kcl-stdlib-docs:
TWENTY_TWENTY=overwrite {{cnr}} -p kcl-lib kcl_test_example
EXPECTORATE=overwrite {{cnr}} -p kcl-lib docs::gen_std_tests::test_generate_stdlib
# Create a new KCL deterministic simulation test case.
new-sim-test test_name kcl_program render_to_png="true":
# Each test file gets its own directory. This will contain the KCL program, and its
# snapshotted artifacts (e.g. serialized tokens, serialized ASTs, program memory,
# PNG snapshots, etc).
mkdir kcl/tests/{{test_name}}
echo "{{kcl_program}}" > kcl/tests/{{test_name}}/input.kcl
# Add the various tests for this new test case.
cat kcl/tests/simtest.tmpl | sed "s/TEST_NAME_HERE/{{test_name}}/" | sed "s/RENDER_TO_PNG/{{render_to_png}}/" >> kcl/src/simulation_tests.rs
# Run all the tests for the first time, in the right order.
new-sim-test test_name render_to_png="true":
{{cita}} -p kcl-lib -- tests::{{test_name}}::tokenize
{{cita}} -p kcl-lib -- tests::{{test_name}}::parse
{{cita}} -p kcl-lib -- tests::{{test_name}}::unparse
TWENTY_TWENTY=overwrite {{cita}} -p kcl-lib -- tests::{{test_name}}::kcl_test_execute

View File

@ -21,6 +21,7 @@ convert_case = "0.6.0"
dashmap = "6.1.0"
databake = { version = "0.1.8", features = ["derive"] }
derive-docs = { version = "0.1.29", path = "../derive-docs" }
fnv = "1.0.7"
form_urlencoded = "1.2.1"
futures = { version = "0.3.31" }
git_rev = "0.1.0"
@ -86,7 +87,7 @@ expectorate = "1.1.0"
handlebars = "6.2.0"
iai = "0.1"
image = { version = "0.25.5", default-features = false, features = ["png"] }
insta = { version = "1.41.1", features = ["json", "filters"] }
insta = { version = "1.41.1", features = ["json", "filters", "redactions"] }
itertools = "0.13.0"
pretty_assertions = "1.4.1"
tokio = { version = "1.40.0", features = ["rt-multi-thread", "macros", "time"] }

View File

@ -39,5 +39,5 @@ const KITT_PROGRAM: &str = include_str!("../../tests/executor/inputs/kittycad_sv
const PIPES_PROGRAM: &str = include_str!("../../tests/executor/inputs/pipes_on_pipes.kcl");
const CUBE_PROGRAM: &str = include_str!("../../tests/executor/inputs/cube.kcl");
const MATH_PROGRAM: &str = include_str!("../../tests/executor/inputs/math.kcl");
const MIKE_STRESS_TEST_PROGRAM: &str = include_str!("../../tests/executor/inputs/mike_stress_test.kcl");
const MIKE_STRESS_TEST_PROGRAM: &str = include_str!("../tests/mike_stress_test/input.kcl");
const LSYSTEM_KOCH_SNOWFLAKE_PROGRAM: &str = include_str!("../../tests/executor/inputs/lsystem.kcl");

View File

@ -28,5 +28,5 @@ const KITT_PROGRAM: &str = include_str!("../../tests/executor/inputs/kittycad_sv
const PIPES_PROGRAM: &str = include_str!("../../tests/executor/inputs/pipes_on_pipes.kcl");
const CUBE_PROGRAM: &str = include_str!("../../tests/executor/inputs/cube.kcl");
const MATH_PROGRAM: &str = include_str!("../../tests/executor/inputs/math.kcl");
const MIKE_STRESS_TEST_PROGRAM: &str = include_str!("../../tests/executor/inputs/mike_stress_test.kcl");
const MIKE_STRESS_TEST_PROGRAM: &str = include_str!("../tests/mike_stress_test/input.kcl");
const LSYSTEM_PROGRAM: &str = include_str!("../../tests/executor/inputs/lsystem.kcl");

View File

@ -62,6 +62,6 @@ const KITT_PROGRAM: &str = include_str!("../../tests/executor/inputs/kittycad_sv
const PIPES_PROGRAM: &str = include_str!("../../tests/executor/inputs/pipes_on_pipes.kcl");
const CUBE_PROGRAM: &str = include_str!("../../tests/executor/inputs/cube.kcl");
const MATH_PROGRAM: &str = include_str!("../../tests/executor/inputs/math.kcl");
const MIKE_STRESS_TEST_PROGRAM: &str = include_str!("../../tests/executor/inputs/mike_stress_test.kcl");
const MIKE_STRESS_TEST_PROGRAM: &str = include_str!("../tests/mike_stress_test/input.kcl");
const GLOBAL_TAGS_FILE: &str = include_str!("../../tests/executor/inputs/global-tags.kcl");
const LSYSTEM_PROGRAM: &str = include_str!("../../tests/executor/inputs/lsystem.kcl");

View File

@ -0,0 +1,20 @@
// This file is used by the import docs.
export fn width = () => {
return 10
}
export fn height = () => {
return 10
}
export fn buildSketch = (plane, offset) => {
w = width()
h = height()
return startSketchOn(plane)
|> startProfileAt(offset, %)
|> line([w, 0], %)
|> line([0, h], %)
|> line([-w, 0], %)
|> close(%)
}

View File

@ -7,6 +7,7 @@ layout: manual
## Table of Contents
* [Types](kcl/types)
* [Modules](kcl/modules)
* [Known Issues](kcl/KNOWN-ISSUES)
{{#each functions}}
* [`{{name}}`](kcl/{{name}})

View File

@ -801,6 +801,17 @@ impl Plane {
},
}
}
/// The standard planes are XY, YZ and XZ (in both positive and negative)
pub fn is_standard(&self) -> bool {
!self.is_custom()
}
/// The standard planes are XY, YZ and XZ (in both positive and negative)
/// Custom planes are any other plane that the user might specify.
pub fn is_custom(&self) -> bool {
matches!(self.value, PlaneType::Custom)
}
}
#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
@ -1049,6 +1060,14 @@ impl KclValue {
}
}
pub fn as_plane(&self) -> Option<&Plane> {
if let KclValue::Plane(value) = &self {
Some(value)
} else {
None
}
}
pub fn as_solid(&self) -> Option<&Solid> {
if let KclValue::Solid(value) = &self {
Some(value)
@ -3033,14 +3052,14 @@ for var in [[3, 6, 10, [0,0]], [1.5, 3, 5, [-10,-10]]] {
#[tokio::test(flavor = "multi_thread")]
async fn test_get_member_of_array_with_function() {
let ast = r#"fn box = (array) => {
let ast = r#"fn box = (arr) => {
let myBox =startSketchOn('XY')
|> startProfileAt(array[0], %)
|> line([0, array[1]], %)
|> line([array[2], 0], %)
|> line([0, -array[1]], %)
|> startProfileAt(arr[0], %)
|> line([0, arr[1]], %)
|> line([arr[2], 0], %)
|> line([0, -arr[1]], %)
|> close(%)
|> extrude(array[3], %)
|> extrude(arr[3], %)
return myBox
}

View File

@ -2,7 +2,7 @@ use std::collections::BTreeMap;
use pretty_assertions::assert_eq;
use tower_lsp::{
lsp_types::{SemanticTokenModifier, SemanticTokenType},
lsp_types::{Diagnostic, SemanticTokenModifier, SemanticTokenType},
LanguageServer,
};
@ -2369,7 +2369,14 @@ async fn kcl_test_kcl_lsp_diagnostics_on_execution_error() {
// Get the diagnostics.
let diagnostics = server.diagnostics_map.get("file:///test.kcl");
assert!(diagnostics.is_none());
if let Some(diagnostics) = diagnostics {
let ds: Vec<Diagnostic> = diagnostics.to_owned();
eprintln!("Expected no diagnostics, but found some.");
for d in ds {
eprintln!("{:?}: {}", d.severity, d.message);
}
panic!();
}
}
#[tokio::test(flavor = "multi_thread")]

View File

@ -2040,11 +2040,39 @@ fn fn_call(i: TokenSlice) -> PResult<Node<CallExpression>> {
#[cfg(test)]
mod tests {
use itertools::Itertools;
use pretty_assertions::assert_eq;
use super::*;
use crate::ast::types::{BodyItem, Expr, ModuleId, VariableKind};
fn assert_reserved(word: &str) {
// Try to use it as a variable name.
let code = format!(r#"{} = 0"#, word);
let result = crate::parser::top_level_parse(code.as_str());
let err = result.unwrap_err();
// Which token causes the error may change. In "return = 0", for
// example, "return" is the problem.
assert!(
err.message().starts_with("Unexpected token: ")
|| err
.message()
.starts_with("Cannot assign a variable to a reserved keyword: "),
"Error message is: {}",
err.message(),
);
}
#[test]
fn reserved_words() {
// Since these are stored in a set, we sort to make the tests
// deterministic.
for word in crate::token::RESERVED_WORDS.keys().sorted() {
assert_reserved(word);
}
assert_reserved("import");
}
#[test]
fn parse_args() {
for (i, (test, expected_len)) in [("someVar", 1), ("5, 3", 2), (r#""a""#, 1)].into_iter().enumerate() {

File diff suppressed because it is too large Load Diff

View File

@ -794,6 +794,45 @@ impl<'a> FromKclValue<'a> for crate::std::planes::StandardPlane {
}
}
impl<'a> FromKclValue<'a> for crate::executor::Plane {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
if let Some(plane) = arg.as_plane() {
return Some(plane.clone());
}
let obj = arg.as_object()?;
let_field_of!(obj, id);
let_field_of!(obj, value);
let_field_of!(obj, origin);
let_field_of!(obj, x_axis "xAxis");
let_field_of!(obj, y_axis "yAxis");
let_field_of!(obj, z_axis "zAxis");
let_field_of!(obj, meta "__meta");
Some(Self {
id,
value,
origin,
x_axis,
y_axis,
z_axis,
meta,
})
}
}
impl<'a> FromKclValue<'a> for crate::executor::PlaneType {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let plane_type = match arg.as_str()? {
"XY" | "xy" => Self::XY,
"XZ" | "xz" => Self::XZ,
"YZ" | "yz" => Self::YZ,
"Custom" => Self::Custom,
_ => return None,
};
Some(plane_type)
}
}
impl<'a> FromKclValue<'a> for kittycad_modeling_cmds::units::UnitLength {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let s = arg.as_str()?;
@ -1032,6 +1071,15 @@ impl<'a> FromKclValue<'a> for super::sketch::ArcData {
}
}
impl<'a> FromKclValue<'a> for super::sketch::ArcToData {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let obj = arg.as_object()?;
let_field_of!(obj, end);
let_field_of!(obj, interior);
Some(Self { end, interior })
}
}
impl<'a> FromKclValue<'a> for super::revolve::RevolveData {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let obj = arg.as_object()?;
@ -1264,11 +1312,15 @@ impl<'a> FromKclValue<'a> for crate::executor::Solid {
impl<'a> FromKclValue<'a> for super::sketch::SketchData {
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
let case1 = super::sketch::PlaneData::from_kcl_val;
let case2 = crate::executor::Solid::from_kcl_val;
// Order is critical since PlaneData is a subset of Plane.
let case1 = crate::executor::Plane::from_kcl_val;
let case2 = super::sketch::PlaneData::from_kcl_val;
let case3 = crate::executor::Solid::from_kcl_val;
case1(arg)
.map(Box::new)
.map(Self::Plane)
.or_else(|| case2(arg).map(Box::new).map(Self::Solid))
.or_else(|| case2(arg).map(Self::PlaneOrientation))
.or_else(|| case3(arg).map(Box::new).map(Self::Solid))
}
}

View File

@ -107,14 +107,14 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
///
/// // This function adds an array of numbers.
/// // It uses the `reduce` function, to call the `add` function on every
/// // element of the `array` parameter. The starting value is 0.
/// fn sum = (array) => { return reduce(array, 0, add) }
/// // element of the `arr` parameter. The starting value is 0.
/// fn sum = (arr) => { return reduce(arr, 0, add) }
///
/// /*
/// The above is basically like this pseudo-code:
/// fn sum(array):
/// fn sum(arr):
/// let sumSoFar = 0
/// for i in array:
/// for i in arr:
/// sumSoFar = add(sumSoFar, i)
/// return sumSoFar
/// */
@ -127,8 +127,8 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// // This example works just like the previous example above, but it uses
/// // an anonymous `add` function as its parameter, instead of declaring a
/// // named function outside.
/// array = [1, 2, 3]
/// sum = reduce(array, 0, (i, result_so_far) => { return i + result_so_far })
/// arr = [1, 2, 3]
/// sum = reduce(arr, 0, (i, result_so_far) => { return i + result_so_far })
///
/// // We use `assertEqual` to check that our `sum` function gives the
/// // expected result. It's good to check your work!

View File

@ -144,6 +144,9 @@ pub async fn import(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// Note: The import command currently only works when using the native
/// Modeling App.
///
/// For importing KCL functions using the `import` statement, see the docs on
/// [KCL modules](/docs/kcl/modules).
///
/// ```no_run
/// const model = import("tests/inputs/cube.obj")
/// ```
@ -163,6 +166,15 @@ pub async fn import(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
/// ```no_run
/// const model = import("tests/inputs/cube.step")
/// ```
///
/// ```no_run
/// import height, buildSketch from 'common.kcl'
///
/// plane = 'XZ'
/// margin = 2
/// s1 = buildSketch(plane, [0, 0])
/// s2 = buildSketch(plane, [0, height() + margin])
/// ```
#[stdlib {
name = "import",
tags = [],

View File

@ -91,6 +91,7 @@ lazy_static! {
Box::new(crate::std::sketch::ProfileStart),
Box::new(crate::std::sketch::Close),
Box::new(crate::std::sketch::Arc),
Box::new(crate::std::sketch::ArcTo),
Box::new(crate::std::sketch::TangentialArc),
Box::new(crate::std::sketch::TangentialArcTo),
Box::new(crate::std::sketch::TangentialArcToRelative),

View File

@ -1,17 +1,20 @@
//! Standard library plane helpers.
use derive_docs::stdlib;
use kcmc::{each_cmd as mcmd, length_unit::LengthUnit, shared::Color, ModelingCmd};
use kittycad_modeling_cmds as kcmc;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{
errors::KclError,
executor::{ExecState, KclValue, Plane},
executor::{ExecState, KclValue, Plane, PlaneType},
std::{sketch::PlaneData, Args},
};
/// One of the standard planes.
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, JsonSchema)]
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub enum StandardPlane {
/// The XY plane.
@ -50,8 +53,8 @@ impl From<StandardPlane> for PlaneData {
/// Offset a plane by a distance along its normal.
pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (std_plane, offset): (StandardPlane, f64) = args.get_data_and_float()?;
let plane_data = inner_offset_plane(std_plane, offset, exec_state).await?;
let plane = Plane::from_plane_data(plane_data, exec_state);
let plane = inner_offset_plane(std_plane, offset, exec_state).await?;
make_offset_plane_in_engine(&plane, exec_state, &args).await?;
Ok(KclValue::Plane(Box::new(plane)))
}
@ -144,11 +147,14 @@ async fn inner_offset_plane(
std_plane: StandardPlane,
offset: f64,
exec_state: &mut ExecState,
) -> Result<PlaneData, KclError> {
) -> Result<Plane, KclError> {
// Convert to the plane type.
let plane_data: PlaneData = std_plane.into();
// Convert to a plane.
let mut plane = Plane::from_plane_data(plane_data, exec_state);
// Though offset planes are derived from standard planes, they are not
// standard planes themselves.
plane.value = PlaneType::Custom;
match std_plane {
StandardPlane::XY => {
@ -171,10 +177,44 @@ async fn inner_offset_plane(
}
}
Ok(PlaneData::Plane {
origin: Box::new(plane.origin),
x_axis: Box::new(plane.x_axis),
y_axis: Box::new(plane.y_axis),
z_axis: Box::new(plane.z_axis),
})
Ok(plane)
}
// Engine-side effectful creation of an actual plane object.
// offset planes are shown by default, and hidden by default if they
// are used as a sketch plane. That hiding command is sent within inner_start_profile_at
async fn make_offset_plane_in_engine(plane: &Plane, exec_state: &mut ExecState, args: &Args) -> Result<(), KclError> {
// Create new default planes.
let default_size = 100.0;
let color = Color {
r: 0.6,
g: 0.6,
b: 0.6,
a: 0.3,
};
args.batch_modeling_cmd(
plane.id,
ModelingCmd::from(mcmd::MakePlane {
clobber: false,
origin: plane.origin.into(),
size: LengthUnit(default_size),
x_axis: plane.x_axis.into(),
y_axis: plane.y_axis.into(),
hide: Some(false),
}),
)
.await?;
// Set the color.
args.batch_modeling_cmd(
exec_state.id_generator.next_uuid(),
ModelingCmd::from(mcmd::PlaneSetColor {
color,
plane_id: plane.id,
}),
)
.await?;
Ok(())
}

View File

@ -894,7 +894,7 @@ pub async fn start_sketch_at(exec_state: &mut ExecState, args: Args) -> Result<K
async fn inner_start_sketch_at(data: [f64; 2], exec_state: &mut ExecState, args: Args) -> Result<Sketch, KclError> {
// Let's assume it's the XY plane for now, this is just for backwards compatibility.
let xy_plane = PlaneData::XY;
let sketch_surface = inner_start_sketch_on(SketchData::Plane(xy_plane), None, exec_state, &args).await?;
let sketch_surface = inner_start_sketch_on(SketchData::PlaneOrientation(xy_plane), None, exec_state, &args).await?;
let sketch = inner_start_profile_at(data, sketch_surface, None, exec_state, args).await?;
Ok(sketch)
}
@ -905,11 +905,12 @@ async fn inner_start_sketch_at(data: [f64; 2], exec_state: &mut ExecState, args:
#[ts(export)]
#[serde(rename_all = "camelCase", untagged)]
pub enum SketchData {
Plane(PlaneData),
PlaneOrientation(PlaneData),
Plane(Box<Plane>),
Solid(Box<Solid>),
}
/// Data for a plane.
/// Orientation data that can be used to construct a plane, not a plane in itself.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
@ -1069,10 +1070,11 @@ async fn inner_start_sketch_on(
args: &Args,
) -> Result<SketchSurface, KclError> {
match data {
SketchData::Plane(plane_data) => {
let plane = start_sketch_on_plane(plane_data, exec_state, args).await?;
SketchData::PlaneOrientation(plane_data) => {
let plane = make_sketch_plane_from_orientation(plane_data, exec_state, args).await?;
Ok(SketchSurface::Plane(plane))
}
SketchData::Plane(plane) => Ok(SketchSurface::Plane(plane)),
SketchData::Solid(solid) => {
let Some(tag) = tag else {
return Err(KclError::Type(KclErrorDetails {
@ -1106,7 +1108,7 @@ async fn start_sketch_on_face(
}))
}
async fn start_sketch_on_plane(
async fn make_sketch_plane_from_orientation(
data: PlaneData,
exec_state: &mut ExecState,
args: &Args,
@ -1122,10 +1124,10 @@ async fn start_sketch_on_plane(
plane.id = match data {
PlaneData::XY => default_planes.xy,
PlaneData::XZ => default_planes.xz,
PlaneData::YZ => default_planes.yz,
PlaneData::NegXY => default_planes.neg_xy,
PlaneData::XZ => default_planes.xz,
PlaneData::NegXZ => default_planes.neg_xz,
PlaneData::YZ => default_planes.yz,
PlaneData::NegYZ => default_planes.neg_yz,
PlaneData::Plane {
origin,
@ -1210,11 +1212,26 @@ pub(crate) async fn inner_start_profile_at(
exec_state: &mut ExecState,
args: Args,
) -> Result<Sketch, KclError> {
if let SketchSurface::Face(face) = &sketch_surface {
// Flush the batch for our fillets/chamfers if there are any.
// If we do not do these for sketch on face, things will fail with face does not exist.
args.flush_batch_for_solid_set(exec_state, face.solid.clone().into())
match &sketch_surface {
SketchSurface::Face(face) => {
// Flush the batch for our fillets/chamfers if there are any.
// If we do not do these for sketch on face, things will fail with face does not exist.
args.flush_batch_for_solid_set(exec_state, face.solid.clone().into())
.await?;
}
SketchSurface::Plane(plane) if !plane.is_standard() => {
// Hide whatever plane we are sketching on.
// This is especially helpful for offset planes, which would be visible otherwise.
args.batch_end_cmd(
exec_state.id_generator.next_uuid(),
ModelingCmd::from(mcmd::ObjectVisible {
object_id: plane.id,
hidden: true,
}),
)
.await?;
}
_ => {}
}
// Enter sketch mode on the surface.
@ -1469,6 +1486,17 @@ pub enum ArcData {
},
}
/// Data to draw a three point arc (arcTo).
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub struct ArcToData {
/// End point of the arc. A point in 3D space
pub end: [f64; 2],
/// Interior point of the arc. A point in 3D space
pub interior: [f64; 2],
}
/// Draw an arc.
pub async fn arc(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (data, sketch, tag): (ArcData, Sketch, Option<TagNode>) = args.get_data_and_sketch_and_tag()?;
@ -1499,7 +1527,7 @@ pub async fn arc(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
/// radius: 16
/// }, %)
/// |> close(%)
// const example = extrude(10, exampleSketch)
/// const example = extrude(10, exampleSketch)
/// ```
#[stdlib {
name = "arc",
@ -1578,6 +1606,104 @@ pub(crate) async fn inner_arc(
Ok(new_sketch)
}
/// Draw a three point arc.
pub async fn arc_to(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
let (data, sketch, tag): (ArcToData, Sketch, Option<TagNode>) = args.get_data_and_sketch_and_tag()?;
let new_sketch = inner_arc_to(data, sketch, tag, exec_state, args).await?;
Ok(KclValue::Sketch {
value: Box::new(new_sketch),
})
}
/// Draw a 3 point arc.
///
/// The arc is constructed such that the start point is the current position of the sketch and two more points defined as the end and interior point.
/// The interior point is placed between the start point and end point. The radius of the arc will be controlled by how far the interior point is placed from
/// the start and end.
///
/// ```no_run
/// const exampleSketch = startSketchOn('XZ')
/// |> startProfileAt([0, 0], %)
/// |> arcTo({
/// end: [10,0],
/// interior: [5,5]
/// }, %)
/// |> close(%)
/// const example = extrude(10, exampleSketch)
/// ```
#[stdlib {
name = "arcTo",
}]
pub(crate) async fn inner_arc_to(
data: ArcToData,
sketch: Sketch,
tag: Option<TagNode>,
exec_state: &mut ExecState,
args: Args,
) -> Result<Sketch, KclError> {
let from: Point2d = sketch.current_pen_position()?;
let id = exec_state.id_generator.next_uuid();
// The start point is taken from the path you are extending.
args.batch_modeling_cmd(
id,
ModelingCmd::from(mcmd::ExtendPath {
path: sketch.id.into(),
segment: PathSegment::ArcTo {
end: kcmc::shared::Point3d {
x: LengthUnit(data.end[0]),
y: LengthUnit(data.end[1]),
z: LengthUnit(0.0),
},
interior: kcmc::shared::Point3d {
x: LengthUnit(data.interior[0]),
y: LengthUnit(data.interior[1]),
z: LengthUnit(0.0),
},
relative: false,
},
}),
)
.await?;
let start = [from.x, from.y];
let interior = [data.interior[0], data.interior[1]];
let end = [data.end[0], data.end[1]];
// compute the center of the circle since we do not have the value returned from the engine
let center = calculate_circle_center(start, interior, end);
// compute the radius since we do not have the value returned from the engine
// Pick any of the 3 points since they all lie along the circle
let sum_of_square_differences =
(center[0] - start[0] * center[0] - start[0]) + (center[1] - start[1] * center[1] - start[1]);
let radius = sum_of_square_differences.sqrt();
let current_path = Path::Arc {
base: BasePath {
from: from.into(),
to: data.end,
tag: tag.clone(),
geo_meta: GeoMeta {
id,
metadata: args.source_range.into(),
},
},
center,
radius,
};
let mut new_sketch = sketch.clone();
if let Some(tag) = &tag {
new_sketch.add_tag(tag, &current_path);
}
new_sketch.paths.push(current_path);
Ok(new_sketch)
}
/// Data to draw a tangential arc.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, JsonSchema, ts_rs::TS)]
#[ts(export)]
@ -1897,6 +2023,42 @@ async fn inner_tangential_arc_to_relative(
Ok(new_sketch)
}
// Calculate the center of 3 points
// To calculate the center of the 3 point circle 2 perpendicular lines are created
// These perpendicular lines will intersect at the center of the circle.
fn calculate_circle_center(p1: [f64; 2], p2: [f64; 2], p3: [f64; 2]) -> [f64; 2] {
// y2 - y1
let y_2_1 = p2[1] - p1[1];
// y3 - y2
let y_3_2 = p3[1] - p2[1];
// x2 - x1
let x_2_1 = p2[0] - p1[0];
// x3 - x2
let x_3_2 = p3[0] - p2[0];
// Slope of two perpendicular lines
let slope_a = y_2_1 / x_2_1;
let slope_b = y_3_2 / x_3_2;
// Values for line intersection
// y1 - y3
let y_1_3 = p1[1] - p3[1];
// x1 + x2
let x_1_2 = p1[0] + p2[0];
// x2 + x3
let x_2_3 = p2[0] + p3[0];
// y1 + y2
let y_1_2 = p1[1] + p2[1];
// Solve for the intersection of these two lines
let numerator = (slope_a * slope_b * y_1_3) + (slope_b * x_1_2) - (slope_a * x_2_3);
let x = numerator / (2.0 * (slope_b - slope_a));
let y = ((-1.0 / slope_a) * (x - (x_1_2 / 2.0))) + (y_1_2 / 2.0);
[x, y]
}
/// Data to draw a bezier curve.
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
@ -2073,7 +2235,7 @@ mod tests {
use pretty_assertions::assert_eq;
use crate::{executor::TagIdentifier, std::sketch::PlaneData};
use crate::{executor::TagIdentifier, std::sketch::calculate_circle_center, std::sketch::PlaneData};
#[test]
fn test_deserialize_plane_data() {
@ -2144,4 +2306,11 @@ mod tests {
crate::std::sketch::FaceTag::StartOrEnd(crate::std::sketch::StartOrEnd::Start)
);
}
#[test]
fn test_circle_center() {
let actual = calculate_circle_center([0.0, 0.0], [5.0, 5.0], [10.0, 0.0]);
assert_eq!(actual[0], 5.0);
assert_eq!(actual[1], 0.0);
}
}

View File

@ -17,6 +17,8 @@ mod tokeniser;
// Re-export
pub use tokeniser::Input;
#[cfg(test)]
pub(crate) use tokeniser::RESERVED_WORDS;
/// The types of tokens.
#[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize, ts_rs::TS, JsonSchema, FromStr, Display)]

View File

@ -1,6 +1,8 @@
use fnv::FnvHashMap;
use lazy_static::lazy_static;
use winnow::{
ascii::{digit1, multispace1},
combinator::{alt, opt, peek, preceded, repeat, terminated},
combinator::{alt, opt, peek, preceded, repeat},
error::{ContextError, ParseError},
prelude::*,
stream::{Location, Stream},
@ -13,6 +15,52 @@ use crate::{
token::{Token, TokenType},
};
lazy_static! {
pub(crate) static ref RESERVED_WORDS: FnvHashMap<&'static str, TokenType> = {
let mut set = FnvHashMap::default();
set.insert("if", TokenType::Keyword);
set.insert("else", TokenType::Keyword);
set.insert("for", TokenType::Keyword);
set.insert("while", TokenType::Keyword);
set.insert("return", TokenType::Keyword);
set.insert("break", TokenType::Keyword);
set.insert("continue", TokenType::Keyword);
set.insert("fn", TokenType::Keyword);
set.insert("let", TokenType::Keyword);
set.insert("mut", TokenType::Keyword);
set.insert("as", TokenType::Keyword);
set.insert("loop", TokenType::Keyword);
set.insert("true", TokenType::Keyword);
set.insert("false", TokenType::Keyword);
set.insert("nil", TokenType::Keyword);
// This isn't a type because brackets are used for the type.
set.insert("array", TokenType::Keyword);
set.insert("and", TokenType::Keyword);
set.insert("or", TokenType::Keyword);
set.insert("not", TokenType::Keyword);
set.insert("var", TokenType::Keyword);
set.insert("const", TokenType::Keyword);
// "import" is special because of import().
set.insert("export", TokenType::Keyword);
set.insert("interface", TokenType::Keyword);
set.insert("new", TokenType::Keyword);
set.insert("self", TokenType::Keyword);
set.insert("record", TokenType::Keyword);
set.insert("struct", TokenType::Keyword);
set.insert("object", TokenType::Keyword);
set.insert("_", TokenType::Keyword);
set.insert("string", TokenType::Type);
set.insert("number", TokenType::Type);
set.insert("bool", TokenType::Type);
set.insert("sketch", TokenType::Type);
set.insert("sketch_surface", TokenType::Type);
set.insert("solid", TokenType::Type);
set
};
}
pub fn lexer(i: &str, module_id: ModuleId) -> Result<Vec<Token>, ParseError<Input<'_>, ContextError>> {
let state = State::new(module_id);
let input = Input {
@ -50,7 +98,7 @@ pub fn token(i: &mut Input<'_>) -> PResult<Token> {
'$' => dollar,
'!' => alt((operator, bang)),
' ' | '\t' | '\n' => whitespace,
_ => alt((operator, keyword,type_, word))
_ => alt((operator, keyword_type_or_word))
}
.parse_next(i)
{
@ -287,47 +335,16 @@ fn import_keyword(i: &mut Input<'_>) -> PResult<Token> {
))
}
fn unambiguous_keywords(i: &mut Input<'_>) -> PResult<Token> {
// These are the keywords themselves.
let keyword_candidates = alt((
"if", "else", "for", "while", "return", "break", "continue", "fn", "let", "mut", "loop", "true", "false",
"nil", "and", "or", "not", "var", "const", "export",
));
// Look ahead. If any of these characters follow the keyword, then it's not a keyword, it's just
// the start of a normal word.
let keyword = terminated(
keyword_candidates,
peek(none_of(('a'..='z', 'A'..='Z', '-', '_', '0'..='9'))),
);
let (value, range) = keyword.with_span().parse_next(i)?;
Ok(Token::from_range(
range,
i.state.module_id,
TokenType::Keyword,
value.to_owned(),
))
fn unambiguous_keyword_type_or_word(i: &mut Input<'_>) -> PResult<Token> {
let mut w = word.parse_next(i)?;
if let Some(token_type) = RESERVED_WORDS.get(w.value.as_str()) {
w.token_type = *token_type;
}
Ok(w)
}
fn keyword(i: &mut Input<'_>) -> PResult<Token> {
alt((import_keyword, unambiguous_keywords)).parse_next(i)
}
fn type_(i: &mut Input<'_>) -> PResult<Token> {
// These are the types themselves.
let type_candidates = alt(("string", "number", "bool", "sketch", "sketch_surface", "solid"));
// Look ahead. If any of these characters follow the type, then it's not a type, it's just
// the start of a normal word.
let type_ = terminated(
type_candidates,
peek(none_of(('a'..='z', 'A'..='Z', '-', '_', '0'..='9'))),
);
let (value, range) = type_.with_span().parse_next(i)?;
Ok(Token::from_range(
range,
i.state.module_id,
TokenType::Type,
value.to_owned(),
))
fn keyword_type_or_word(i: &mut Input<'_>) -> PResult<Token> {
alt((import_keyword, unambiguous_keyword_type_or_word)).parse_next(i)
}
#[cfg(test)]

View File

@ -0,0 +1,157 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing array_elem_push_fail.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 15,
"id": {
"end": 3,
"name": "arr",
"start": 0,
"type": "Identifier"
},
"init": {
"elements": [
{
"end": 8,
"raw": "1",
"start": 7,
"type": "Literal",
"type": "Literal",
"value": 1
},
{
"end": 11,
"raw": "2",
"start": 10,
"type": "Literal",
"type": "Literal",
"value": 2
},
{
"end": 14,
"raw": "3",
"start": 13,
"type": "Literal",
"type": "Literal",
"value": 3
}
],
"end": 15,
"start": 6,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 0,
"type": "VariableDeclarator"
}
],
"end": 15,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 40,
"id": {
"end": 25,
"name": "pushedArr",
"start": 16,
"type": "Identifier"
},
"init": {
"arguments": [
{
"end": 36,
"name": "arr",
"start": 33,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 39,
"raw": "4",
"start": 38,
"type": "Literal",
"type": "Literal",
"value": 4
}
],
"callee": {
"end": 32,
"name": "push",
"start": 28,
"type": "Identifier"
},
"end": 40,
"optional": false,
"start": 28,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 16,
"type": "VariableDeclarator"
}
],
"end": 40,
"kind": "const",
"start": 16,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 54,
"id": {
"end": 45,
"name": "fail",
"start": 41,
"type": "Identifier"
},
"init": {
"computed": false,
"end": 54,
"object": {
"end": 51,
"name": "arr",
"start": 48,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 53,
"raw": "3",
"start": 52,
"type": "Literal",
"type": "Literal",
"value": 3
},
"start": 48,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 41,
"type": "VariableDeclarator"
}
],
"end": 54,
"kind": "const",
"start": 41,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 55,
"start": 0
}
}

View File

@ -0,0 +1,6 @@
---
source: kcl/src/simulation_tests.rs
description: Error from executing array_elem_push_fail.kcl
snapshot_kind: text
---
undefined value: KclErrorDetails { source_ranges: [SourceRange([48, 54, 0])], message: "The array doesn't have any item at index 3" }

View File

@ -0,0 +1,3 @@
arr = [1, 2, 3]
pushedArr = push(arr, 4)
fail = arr[3]

View File

@ -0,0 +1,219 @@
---
source: kcl/src/simulation_tests.rs
description: Result of tokenizing array_elem_push_fail.kcl
snapshot_kind: text
---
{
"Ok": [
{
"type": "word",
"start": 0,
"end": 3,
"value": "arr"
},
{
"type": "whitespace",
"start": 3,
"end": 4,
"value": " "
},
{
"type": "operator",
"start": 4,
"end": 5,
"value": "="
},
{
"type": "whitespace",
"start": 5,
"end": 6,
"value": " "
},
{
"type": "brace",
"start": 6,
"end": 7,
"value": "["
},
{
"type": "number",
"start": 7,
"end": 8,
"value": "1"
},
{
"type": "comma",
"start": 8,
"end": 9,
"value": ","
},
{
"type": "whitespace",
"start": 9,
"end": 10,
"value": " "
},
{
"type": "number",
"start": 10,
"end": 11,
"value": "2"
},
{
"type": "comma",
"start": 11,
"end": 12,
"value": ","
},
{
"type": "whitespace",
"start": 12,
"end": 13,
"value": " "
},
{
"type": "number",
"start": 13,
"end": 14,
"value": "3"
},
{
"type": "brace",
"start": 14,
"end": 15,
"value": "]"
},
{
"type": "whitespace",
"start": 15,
"end": 16,
"value": "\n"
},
{
"type": "word",
"start": 16,
"end": 25,
"value": "pushedArr"
},
{
"type": "whitespace",
"start": 25,
"end": 26,
"value": " "
},
{
"type": "operator",
"start": 26,
"end": 27,
"value": "="
},
{
"type": "whitespace",
"start": 27,
"end": 28,
"value": " "
},
{
"type": "word",
"start": 28,
"end": 32,
"value": "push"
},
{
"type": "brace",
"start": 32,
"end": 33,
"value": "("
},
{
"type": "word",
"start": 33,
"end": 36,
"value": "arr"
},
{
"type": "comma",
"start": 36,
"end": 37,
"value": ","
},
{
"type": "whitespace",
"start": 37,
"end": 38,
"value": " "
},
{
"type": "number",
"start": 38,
"end": 39,
"value": "4"
},
{
"type": "brace",
"start": 39,
"end": 40,
"value": ")"
},
{
"type": "whitespace",
"start": 40,
"end": 41,
"value": "\n"
},
{
"type": "word",
"start": 41,
"end": 45,
"value": "fail"
},
{
"type": "whitespace",
"start": 45,
"end": 46,
"value": " "
},
{
"type": "operator",
"start": 46,
"end": 47,
"value": "="
},
{
"type": "whitespace",
"start": 47,
"end": 48,
"value": " "
},
{
"type": "word",
"start": 48,
"end": 51,
"value": "arr"
},
{
"type": "brace",
"start": 51,
"end": 52,
"value": "["
},
{
"type": "number",
"start": 52,
"end": 53,
"value": "3"
},
{
"type": "brace",
"start": 53,
"end": 54,
"value": "]"
},
{
"type": "whitespace",
"start": 54,
"end": 55,
"value": "\n"
}
]
}

View File

@ -0,0 +1,82 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing array_index_oob.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 8,
"id": {
"end": 3,
"name": "arr",
"start": 0,
"type": "Identifier"
},
"init": {
"elements": [],
"end": 8,
"start": 6,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 0,
"type": "VariableDeclarator"
}
],
"end": 8,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 19,
"id": {
"end": 10,
"name": "x",
"start": 9,
"type": "Identifier"
},
"init": {
"computed": false,
"end": 19,
"object": {
"end": 16,
"name": "arr",
"start": 13,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 18,
"raw": "0",
"start": 17,
"type": "Literal",
"type": "Literal",
"value": 0
},
"start": 13,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 9,
"type": "VariableDeclarator"
}
],
"end": 19,
"kind": "const",
"start": 9,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 20,
"start": 0
}
}

View File

@ -0,0 +1,6 @@
---
source: kcl/src/simulation_tests.rs
description: Error from executing array_index_oob.kcl
snapshot_kind: text
---
undefined value: KclErrorDetails { source_ranges: [SourceRange([13, 19, 0])], message: "The array doesn't have any item at index 0" }

View File

@ -0,0 +1,2 @@
arr = []
x = arr[0]

View File

@ -0,0 +1,105 @@
---
source: kcl/src/simulation_tests.rs
description: Result of tokenizing array_index_oob.kcl
snapshot_kind: text
---
{
"Ok": [
{
"type": "word",
"start": 0,
"end": 3,
"value": "arr"
},
{
"type": "whitespace",
"start": 3,
"end": 4,
"value": " "
},
{
"type": "operator",
"start": 4,
"end": 5,
"value": "="
},
{
"type": "whitespace",
"start": 5,
"end": 6,
"value": " "
},
{
"type": "brace",
"start": 6,
"end": 7,
"value": "["
},
{
"type": "brace",
"start": 7,
"end": 8,
"value": "]"
},
{
"type": "whitespace",
"start": 8,
"end": 9,
"value": "\n"
},
{
"type": "word",
"start": 9,
"end": 10,
"value": "x"
},
{
"type": "whitespace",
"start": 10,
"end": 11,
"value": " "
},
{
"type": "operator",
"start": 11,
"end": 12,
"value": "="
},
{
"type": "whitespace",
"start": 12,
"end": 13,
"value": " "
},
{
"type": "word",
"start": 13,
"end": 16,
"value": "arr"
},
{
"type": "brace",
"start": 16,
"end": 17,
"value": "["
},
{
"type": "number",
"start": 17,
"end": 18,
"value": "0"
},
{
"type": "brace",
"start": 18,
"end": 19,
"value": "]"
},
{
"type": "whitespace",
"start": 19,
"end": 20,
"value": "\n"
}
]
}

View File

@ -0,0 +1,418 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing basic_fillet_cube_close_opposite.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 277,
"id": {
"end": 7,
"name": "part001",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 28,
"raw": "'XY'",
"start": 24,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"end": 23,
"name": "startSketchOn",
"start": 10,
"type": "Identifier"
},
"end": 29,
"optional": false,
"start": 10,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 52,
"raw": "0",
"start": 51,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 55,
"raw": "0",
"start": 54,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 56,
"start": 50,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 59,
"start": 58,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 49,
"name": "startProfileAt",
"start": 35,
"type": "Identifier"
},
"end": 60,
"optional": false,
"start": 35,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 73,
"raw": "0",
"start": 72,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 77,
"raw": "10",
"start": 75,
"type": "Literal",
"type": "Literal",
"value": 10
}
],
"end": 78,
"start": 71,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 81,
"start": 80,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 89,
"start": 83,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing"
}
],
"callee": {
"end": 70,
"name": "line",
"start": 66,
"type": "Identifier"
},
"end": 90,
"optional": false,
"start": 66,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 104,
"raw": "10",
"start": 102,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 107,
"raw": "0",
"start": 106,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 108,
"start": 101,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 111,
"start": 110,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 100,
"name": "line",
"start": 96,
"type": "Identifier"
},
"end": 112,
"optional": false,
"start": 96,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 125,
"raw": "0",
"start": 124,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"argument": {
"end": 130,
"raw": "10",
"start": 128,
"type": "Literal",
"type": "Literal",
"value": 10
},
"end": 130,
"operator": "-",
"start": 127,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 131,
"start": 123,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 134,
"start": 133,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 143,
"start": 136,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing2"
}
],
"callee": {
"end": 122,
"name": "line",
"start": 118,
"type": "Identifier"
},
"end": 144,
"optional": false,
"start": 118,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 157,
"start": 156,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 166,
"start": 159,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing3"
}
],
"callee": {
"end": 155,
"name": "close",
"start": 150,
"type": "Identifier"
},
"end": 167,
"optional": false,
"start": 150,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 183,
"raw": "10",
"start": 181,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 186,
"start": 185,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 180,
"name": "extrude",
"start": 173,
"type": "Identifier"
},
"end": 187,
"optional": false,
"start": 173,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 273,
"properties": [
{
"end": 218,
"key": {
"end": 215,
"name": "radius",
"start": 209,
"type": "Identifier"
},
"start": 209,
"type": "ObjectProperty",
"value": {
"end": 218,
"raw": "2",
"start": 217,
"type": "Literal",
"type": "Literal",
"value": 2
}
},
{
"end": 266,
"key": {
"end": 231,
"name": "tags",
"start": 227,
"type": "Identifier"
},
"start": 227,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 240,
"name": "thing3",
"start": 234,
"type": "Identifier",
"type": "Identifier"
},
{
"arguments": [
{
"end": 264,
"name": "thing3",
"start": 258,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"end": 257,
"name": "getOppositeEdge",
"start": 242,
"type": "Identifier"
},
"end": 265,
"optional": false,
"start": 242,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 266,
"start": 233,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"start": 200,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 276,
"start": 275,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 199,
"name": "fillet",
"start": 193,
"type": "Identifier"
},
"end": 277,
"optional": false,
"start": 193,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 277,
"start": 10,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
}
],
"end": 277,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 278,
"start": 0
}
}

View File

@ -0,0 +1,11 @@
part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([0, 10], %, $thing)
|> line([10, 0], %)
|> line([0, -10], %, $thing2)
|> close(%, $thing3)
|> extrude(10, %)
|> fillet({
radius: 2,
tags: [thing3, getOppositeEdge(thing3)]
}, %)

View File

@ -0,0 +1,644 @@
---
source: kcl/src/simulation_tests.rs
description: Program memory after executing basic_fillet_cube_close_opposite.kcl
snapshot_kind: text
---
{
"environments": [
{
"bindings": {
"HALF_TURN": {
"type": "Number",
"value": 180.0,
"__meta": []
},
"QUARTER_TURN": {
"type": "Number",
"value": 90.0,
"__meta": []
},
"THREE_QUARTER_TURN": {
"type": "Number",
"value": 270.0,
"__meta": []
},
"ZERO": {
"type": "Number",
"value": 0.0,
"__meta": []
},
"part001": {
"type": "Solid",
"type": "Solid",
"id": "[uuid]",
"value": [
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
96,
112,
0
],
"tag": null,
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
118,
144,
0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
150,
167,
0
],
"tag": {
"end": 166,
"start": 159,
"type": "TagDeclarator",
"value": "thing3"
},
"type": "extrudePlane"
}
],
"sketch": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
96,
112,
0
]
},
"from": [
0.0,
10.0
],
"tag": null,
"to": [
10.0,
10.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
118,
144,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
150,
167,
0
]
},
"from": [
10.0,
0.0
],
"tag": {
"end": 166,
"start": 159,
"type": "TagDeclarator",
"value": "thing3"
},
"to": [
0.0,
0.0
],
"type": "ToPoint"
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"__meta": []
},
"start": {
"from": [
0.0,
0.0
],
"to": [
0.0,
0.0
],
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
35,
60,
0
]
}
},
"tags": {
"thing": {
"type": "TagIdentifier",
"value": "thing",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
83,
89,
0
]
}
]
},
"thing2": {
"type": "TagIdentifier",
"value": "thing2",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
118,
144,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
118,
144,
0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
136,
143,
0
]
}
]
},
"thing3": {
"type": "TagIdentifier",
"value": "thing3",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
150,
167,
0
]
},
"from": [
10.0,
0.0
],
"tag": {
"end": 166,
"start": 159,
"type": "TagDeclarator",
"value": "thing3"
},
"to": [
0.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
150,
167,
0
],
"tag": {
"end": 166,
"start": 159,
"type": "TagDeclarator",
"value": "thing3"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
159,
166,
0
]
}
]
}
},
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"height": 10.0,
"startCapId": "[uuid]",
"endCapId": "[uuid]",
"edgeCuts": [
{
"type": "fillet",
"id": "[uuid]",
"radius": 2.0,
"edgeId": "[uuid]",
"tag": null
},
{
"type": "fillet",
"id": "[uuid]",
"radius": 2.0,
"edgeId": "[uuid]",
"tag": null
}
],
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"thing": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
83,
89,
0
]
}
]
},
"thing2": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing2",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
118,
144,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
118,
144,
0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
136,
143,
0
]
}
]
},
"thing3": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing3",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
150,
167,
0
]
},
"from": [
10.0,
0.0
],
"tag": {
"end": 166,
"start": 159,
"type": "TagDeclarator",
"value": "thing3"
},
"to": [
0.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
150,
167,
0
],
"tag": {
"end": 166,
"start": 159,
"type": "TagDeclarator",
"value": "thing3"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
159,
166,
0
]
}
]
}
},
"parent": null
}
],
"currentEnv": 0,
"return": null
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

View File

@ -0,0 +1,789 @@
---
source: kcl/src/simulation_tests.rs
description: Result of tokenizing basic_fillet_cube_close_opposite.kcl
snapshot_kind: text
---
{
"Ok": [
{
"type": "word",
"start": 0,
"end": 7,
"value": "part001"
},
{
"type": "whitespace",
"start": 7,
"end": 8,
"value": " "
},
{
"type": "operator",
"start": 8,
"end": 9,
"value": "="
},
{
"type": "whitespace",
"start": 9,
"end": 10,
"value": " "
},
{
"type": "word",
"start": 10,
"end": 23,
"value": "startSketchOn"
},
{
"type": "brace",
"start": 23,
"end": 24,
"value": "("
},
{
"type": "string",
"start": 24,
"end": 28,
"value": "'XY'"
},
{
"type": "brace",
"start": 28,
"end": 29,
"value": ")"
},
{
"type": "whitespace",
"start": 29,
"end": 32,
"value": "\n "
},
{
"type": "operator",
"start": 32,
"end": 34,
"value": "|>"
},
{
"type": "whitespace",
"start": 34,
"end": 35,
"value": " "
},
{
"type": "word",
"start": 35,
"end": 49,
"value": "startProfileAt"
},
{
"type": "brace",
"start": 49,
"end": 50,
"value": "("
},
{
"type": "brace",
"start": 50,
"end": 51,
"value": "["
},
{
"type": "number",
"start": 51,
"end": 52,
"value": "0"
},
{
"type": "comma",
"start": 52,
"end": 53,
"value": ","
},
{
"type": "whitespace",
"start": 53,
"end": 54,
"value": " "
},
{
"type": "number",
"start": 54,
"end": 55,
"value": "0"
},
{
"type": "brace",
"start": 55,
"end": 56,
"value": "]"
},
{
"type": "comma",
"start": 56,
"end": 57,
"value": ","
},
{
"type": "whitespace",
"start": 57,
"end": 58,
"value": " "
},
{
"type": "operator",
"start": 58,
"end": 59,
"value": "%"
},
{
"type": "brace",
"start": 59,
"end": 60,
"value": ")"
},
{
"type": "whitespace",
"start": 60,
"end": 63,
"value": "\n "
},
{
"type": "operator",
"start": 63,
"end": 65,
"value": "|>"
},
{
"type": "whitespace",
"start": 65,
"end": 66,
"value": " "
},
{
"type": "word",
"start": 66,
"end": 70,
"value": "line"
},
{
"type": "brace",
"start": 70,
"end": 71,
"value": "("
},
{
"type": "brace",
"start": 71,
"end": 72,
"value": "["
},
{
"type": "number",
"start": 72,
"end": 73,
"value": "0"
},
{
"type": "comma",
"start": 73,
"end": 74,
"value": ","
},
{
"type": "whitespace",
"start": 74,
"end": 75,
"value": " "
},
{
"type": "number",
"start": 75,
"end": 77,
"value": "10"
},
{
"type": "brace",
"start": 77,
"end": 78,
"value": "]"
},
{
"type": "comma",
"start": 78,
"end": 79,
"value": ","
},
{
"type": "whitespace",
"start": 79,
"end": 80,
"value": " "
},
{
"type": "operator",
"start": 80,
"end": 81,
"value": "%"
},
{
"type": "comma",
"start": 81,
"end": 82,
"value": ","
},
{
"type": "whitespace",
"start": 82,
"end": 83,
"value": " "
},
{
"type": "dollar",
"start": 83,
"end": 84,
"value": "$"
},
{
"type": "word",
"start": 84,
"end": 89,
"value": "thing"
},
{
"type": "brace",
"start": 89,
"end": 90,
"value": ")"
},
{
"type": "whitespace",
"start": 90,
"end": 93,
"value": "\n "
},
{
"type": "operator",
"start": 93,
"end": 95,
"value": "|>"
},
{
"type": "whitespace",
"start": 95,
"end": 96,
"value": " "
},
{
"type": "word",
"start": 96,
"end": 100,
"value": "line"
},
{
"type": "brace",
"start": 100,
"end": 101,
"value": "("
},
{
"type": "brace",
"start": 101,
"end": 102,
"value": "["
},
{
"type": "number",
"start": 102,
"end": 104,
"value": "10"
},
{
"type": "comma",
"start": 104,
"end": 105,
"value": ","
},
{
"type": "whitespace",
"start": 105,
"end": 106,
"value": " "
},
{
"type": "number",
"start": 106,
"end": 107,
"value": "0"
},
{
"type": "brace",
"start": 107,
"end": 108,
"value": "]"
},
{
"type": "comma",
"start": 108,
"end": 109,
"value": ","
},
{
"type": "whitespace",
"start": 109,
"end": 110,
"value": " "
},
{
"type": "operator",
"start": 110,
"end": 111,
"value": "%"
},
{
"type": "brace",
"start": 111,
"end": 112,
"value": ")"
},
{
"type": "whitespace",
"start": 112,
"end": 115,
"value": "\n "
},
{
"type": "operator",
"start": 115,
"end": 117,
"value": "|>"
},
{
"type": "whitespace",
"start": 117,
"end": 118,
"value": " "
},
{
"type": "word",
"start": 118,
"end": 122,
"value": "line"
},
{
"type": "brace",
"start": 122,
"end": 123,
"value": "("
},
{
"type": "brace",
"start": 123,
"end": 124,
"value": "["
},
{
"type": "number",
"start": 124,
"end": 125,
"value": "0"
},
{
"type": "comma",
"start": 125,
"end": 126,
"value": ","
},
{
"type": "whitespace",
"start": 126,
"end": 127,
"value": " "
},
{
"type": "operator",
"start": 127,
"end": 128,
"value": "-"
},
{
"type": "number",
"start": 128,
"end": 130,
"value": "10"
},
{
"type": "brace",
"start": 130,
"end": 131,
"value": "]"
},
{
"type": "comma",
"start": 131,
"end": 132,
"value": ","
},
{
"type": "whitespace",
"start": 132,
"end": 133,
"value": " "
},
{
"type": "operator",
"start": 133,
"end": 134,
"value": "%"
},
{
"type": "comma",
"start": 134,
"end": 135,
"value": ","
},
{
"type": "whitespace",
"start": 135,
"end": 136,
"value": " "
},
{
"type": "dollar",
"start": 136,
"end": 137,
"value": "$"
},
{
"type": "word",
"start": 137,
"end": 143,
"value": "thing2"
},
{
"type": "brace",
"start": 143,
"end": 144,
"value": ")"
},
{
"type": "whitespace",
"start": 144,
"end": 147,
"value": "\n "
},
{
"type": "operator",
"start": 147,
"end": 149,
"value": "|>"
},
{
"type": "whitespace",
"start": 149,
"end": 150,
"value": " "
},
{
"type": "word",
"start": 150,
"end": 155,
"value": "close"
},
{
"type": "brace",
"start": 155,
"end": 156,
"value": "("
},
{
"type": "operator",
"start": 156,
"end": 157,
"value": "%"
},
{
"type": "comma",
"start": 157,
"end": 158,
"value": ","
},
{
"type": "whitespace",
"start": 158,
"end": 159,
"value": " "
},
{
"type": "dollar",
"start": 159,
"end": 160,
"value": "$"
},
{
"type": "word",
"start": 160,
"end": 166,
"value": "thing3"
},
{
"type": "brace",
"start": 166,
"end": 167,
"value": ")"
},
{
"type": "whitespace",
"start": 167,
"end": 170,
"value": "\n "
},
{
"type": "operator",
"start": 170,
"end": 172,
"value": "|>"
},
{
"type": "whitespace",
"start": 172,
"end": 173,
"value": " "
},
{
"type": "word",
"start": 173,
"end": 180,
"value": "extrude"
},
{
"type": "brace",
"start": 180,
"end": 181,
"value": "("
},
{
"type": "number",
"start": 181,
"end": 183,
"value": "10"
},
{
"type": "comma",
"start": 183,
"end": 184,
"value": ","
},
{
"type": "whitespace",
"start": 184,
"end": 185,
"value": " "
},
{
"type": "operator",
"start": 185,
"end": 186,
"value": "%"
},
{
"type": "brace",
"start": 186,
"end": 187,
"value": ")"
},
{
"type": "whitespace",
"start": 187,
"end": 190,
"value": "\n "
},
{
"type": "operator",
"start": 190,
"end": 192,
"value": "|>"
},
{
"type": "whitespace",
"start": 192,
"end": 193,
"value": " "
},
{
"type": "word",
"start": 193,
"end": 199,
"value": "fillet"
},
{
"type": "brace",
"start": 199,
"end": 200,
"value": "("
},
{
"type": "brace",
"start": 200,
"end": 201,
"value": "{"
},
{
"type": "whitespace",
"start": 201,
"end": 209,
"value": "\n "
},
{
"type": "word",
"start": 209,
"end": 215,
"value": "radius"
},
{
"type": "colon",
"start": 215,
"end": 216,
"value": ":"
},
{
"type": "whitespace",
"start": 216,
"end": 217,
"value": " "
},
{
"type": "number",
"start": 217,
"end": 218,
"value": "2"
},
{
"type": "comma",
"start": 218,
"end": 219,
"value": ","
},
{
"type": "whitespace",
"start": 219,
"end": 227,
"value": "\n "
},
{
"type": "word",
"start": 227,
"end": 231,
"value": "tags"
},
{
"type": "colon",
"start": 231,
"end": 232,
"value": ":"
},
{
"type": "whitespace",
"start": 232,
"end": 233,
"value": " "
},
{
"type": "brace",
"start": 233,
"end": 234,
"value": "["
},
{
"type": "word",
"start": 234,
"end": 240,
"value": "thing3"
},
{
"type": "comma",
"start": 240,
"end": 241,
"value": ","
},
{
"type": "whitespace",
"start": 241,
"end": 242,
"value": " "
},
{
"type": "word",
"start": 242,
"end": 257,
"value": "getOppositeEdge"
},
{
"type": "brace",
"start": 257,
"end": 258,
"value": "("
},
{
"type": "word",
"start": 258,
"end": 264,
"value": "thing3"
},
{
"type": "brace",
"start": 264,
"end": 265,
"value": ")"
},
{
"type": "brace",
"start": 265,
"end": 266,
"value": "]"
},
{
"type": "whitespace",
"start": 266,
"end": 272,
"value": "\n "
},
{
"type": "brace",
"start": 272,
"end": 273,
"value": "}"
},
{
"type": "comma",
"start": 273,
"end": 274,
"value": ","
},
{
"type": "whitespace",
"start": 274,
"end": 275,
"value": " "
},
{
"type": "operator",
"start": 275,
"end": 276,
"value": "%"
},
{
"type": "brace",
"start": 276,
"end": 277,
"value": ")"
},
{
"type": "whitespace",
"start": 277,
"end": 278,
"value": "\n"
}
]
}

View File

@ -0,0 +1,411 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing basic_fillet_cube_end.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 266,
"id": {
"end": 7,
"name": "part001",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 28,
"raw": "'XY'",
"start": 24,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"end": 23,
"name": "startSketchOn",
"start": 10,
"type": "Identifier"
},
"end": 29,
"optional": false,
"start": 10,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 52,
"raw": "0",
"start": 51,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 55,
"raw": "0",
"start": 54,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 56,
"start": 50,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 59,
"start": 58,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 49,
"name": "startProfileAt",
"start": 35,
"type": "Identifier"
},
"end": 60,
"optional": false,
"start": 35,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 73,
"raw": "0",
"start": 72,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 77,
"raw": "10",
"start": 75,
"type": "Literal",
"type": "Literal",
"value": 10
}
],
"end": 78,
"start": 71,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 81,
"start": 80,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 89,
"start": 83,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing"
}
],
"callee": {
"end": 70,
"name": "line",
"start": 66,
"type": "Identifier"
},
"end": 90,
"optional": false,
"start": 66,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 104,
"raw": "10",
"start": 102,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 107,
"raw": "0",
"start": 106,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 108,
"start": 101,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 111,
"start": 110,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 100,
"name": "line",
"start": 96,
"type": "Identifier"
},
"end": 112,
"optional": false,
"start": 96,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 125,
"raw": "0",
"start": 124,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"argument": {
"end": 130,
"raw": "10",
"start": 128,
"type": "Literal",
"type": "Literal",
"value": 10
},
"end": 130,
"operator": "-",
"start": 127,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 131,
"start": 123,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 134,
"start": 133,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 143,
"start": 136,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing2"
}
],
"callee": {
"end": 122,
"name": "line",
"start": 118,
"type": "Identifier"
},
"end": 144,
"optional": false,
"start": 118,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 157,
"start": 156,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 155,
"name": "close",
"start": 150,
"type": "Identifier"
},
"end": 158,
"optional": false,
"start": 150,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 174,
"raw": "10",
"start": 172,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 177,
"start": 176,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 171,
"name": "extrude",
"start": 164,
"type": "Identifier"
},
"end": 178,
"optional": false,
"start": 164,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 262,
"properties": [
{
"end": 209,
"key": {
"end": 206,
"name": "radius",
"start": 200,
"type": "Identifier"
},
"start": 200,
"type": "ObjectProperty",
"value": {
"end": 209,
"raw": "2",
"start": 208,
"type": "Literal",
"type": "Literal",
"value": 2
}
},
{
"end": 255,
"key": {
"end": 222,
"name": "tags",
"start": 218,
"type": "Identifier"
},
"start": 218,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 230,
"name": "thing",
"start": 225,
"type": "Identifier",
"type": "Identifier"
},
{
"arguments": [
{
"end": 253,
"name": "thing",
"start": 248,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"end": 247,
"name": "getOppositeEdge",
"start": 232,
"type": "Identifier"
},
"end": 254,
"optional": false,
"start": 232,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 255,
"start": 224,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"start": 191,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 265,
"start": 264,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 190,
"name": "fillet",
"start": 184,
"type": "Identifier"
},
"end": 266,
"optional": false,
"start": 184,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 266,
"start": 10,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
}
],
"end": 266,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 267,
"start": 0
}
}

View File

@ -0,0 +1,11 @@
part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([0, 10], %, $thing)
|> line([10, 0], %)
|> line([0, -10], %, $thing2)
|> close(%)
|> extrude(10, %)
|> fillet({
radius: 2,
tags: [thing, getOppositeEdge(thing)]
}, %)

View File

@ -0,0 +1,515 @@
---
source: kcl/src/simulation_tests.rs
description: Program memory after executing basic_fillet_cube_end.kcl
snapshot_kind: text
---
{
"environments": [
{
"bindings": {
"HALF_TURN": {
"type": "Number",
"value": 180.0,
"__meta": []
},
"QUARTER_TURN": {
"type": "Number",
"value": 90.0,
"__meta": []
},
"THREE_QUARTER_TURN": {
"type": "Number",
"value": 270.0,
"__meta": []
},
"ZERO": {
"type": "Number",
"value": 0.0,
"__meta": []
},
"part001": {
"type": "Solid",
"type": "Solid",
"id": "[uuid]",
"value": [
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
96,
112,
0
],
"tag": null,
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
118,
144,
0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
150,
158,
0
],
"tag": null,
"type": "extrudePlane"
}
],
"sketch": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
96,
112,
0
]
},
"from": [
0.0,
10.0
],
"tag": null,
"to": [
10.0,
10.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
118,
144,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
150,
158,
0
]
},
"from": [
10.0,
0.0
],
"tag": null,
"to": [
0.0,
0.0
],
"type": "ToPoint"
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"__meta": []
},
"start": {
"from": [
0.0,
0.0
],
"to": [
0.0,
0.0
],
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
35,
60,
0
]
}
},
"tags": {
"thing": {
"type": "TagIdentifier",
"value": "thing",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
83,
89,
0
]
}
]
},
"thing2": {
"type": "TagIdentifier",
"value": "thing2",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
118,
144,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
118,
144,
0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
136,
143,
0
]
}
]
}
},
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"height": 10.0,
"startCapId": "[uuid]",
"endCapId": "[uuid]",
"edgeCuts": [
{
"type": "fillet",
"id": "[uuid]",
"radius": 2.0,
"edgeId": "[uuid]",
"tag": null
},
{
"type": "fillet",
"id": "[uuid]",
"radius": 2.0,
"edgeId": "[uuid]",
"tag": null
}
],
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"thing": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
83,
89,
0
]
}
]
},
"thing2": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing2",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
118,
144,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
118,
144,
0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
136,
143,
0
]
}
]
}
},
"parent": null
}
],
"currentEnv": 0,
"return": null
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

View File

@ -0,0 +1,765 @@
---
source: kcl/src/simulation_tests.rs
description: Result of tokenizing basic_fillet_cube_end.kcl
snapshot_kind: text
---
{
"Ok": [
{
"type": "word",
"start": 0,
"end": 7,
"value": "part001"
},
{
"type": "whitespace",
"start": 7,
"end": 8,
"value": " "
},
{
"type": "operator",
"start": 8,
"end": 9,
"value": "="
},
{
"type": "whitespace",
"start": 9,
"end": 10,
"value": " "
},
{
"type": "word",
"start": 10,
"end": 23,
"value": "startSketchOn"
},
{
"type": "brace",
"start": 23,
"end": 24,
"value": "("
},
{
"type": "string",
"start": 24,
"end": 28,
"value": "'XY'"
},
{
"type": "brace",
"start": 28,
"end": 29,
"value": ")"
},
{
"type": "whitespace",
"start": 29,
"end": 32,
"value": "\n "
},
{
"type": "operator",
"start": 32,
"end": 34,
"value": "|>"
},
{
"type": "whitespace",
"start": 34,
"end": 35,
"value": " "
},
{
"type": "word",
"start": 35,
"end": 49,
"value": "startProfileAt"
},
{
"type": "brace",
"start": 49,
"end": 50,
"value": "("
},
{
"type": "brace",
"start": 50,
"end": 51,
"value": "["
},
{
"type": "number",
"start": 51,
"end": 52,
"value": "0"
},
{
"type": "comma",
"start": 52,
"end": 53,
"value": ","
},
{
"type": "whitespace",
"start": 53,
"end": 54,
"value": " "
},
{
"type": "number",
"start": 54,
"end": 55,
"value": "0"
},
{
"type": "brace",
"start": 55,
"end": 56,
"value": "]"
},
{
"type": "comma",
"start": 56,
"end": 57,
"value": ","
},
{
"type": "whitespace",
"start": 57,
"end": 58,
"value": " "
},
{
"type": "operator",
"start": 58,
"end": 59,
"value": "%"
},
{
"type": "brace",
"start": 59,
"end": 60,
"value": ")"
},
{
"type": "whitespace",
"start": 60,
"end": 63,
"value": "\n "
},
{
"type": "operator",
"start": 63,
"end": 65,
"value": "|>"
},
{
"type": "whitespace",
"start": 65,
"end": 66,
"value": " "
},
{
"type": "word",
"start": 66,
"end": 70,
"value": "line"
},
{
"type": "brace",
"start": 70,
"end": 71,
"value": "("
},
{
"type": "brace",
"start": 71,
"end": 72,
"value": "["
},
{
"type": "number",
"start": 72,
"end": 73,
"value": "0"
},
{
"type": "comma",
"start": 73,
"end": 74,
"value": ","
},
{
"type": "whitespace",
"start": 74,
"end": 75,
"value": " "
},
{
"type": "number",
"start": 75,
"end": 77,
"value": "10"
},
{
"type": "brace",
"start": 77,
"end": 78,
"value": "]"
},
{
"type": "comma",
"start": 78,
"end": 79,
"value": ","
},
{
"type": "whitespace",
"start": 79,
"end": 80,
"value": " "
},
{
"type": "operator",
"start": 80,
"end": 81,
"value": "%"
},
{
"type": "comma",
"start": 81,
"end": 82,
"value": ","
},
{
"type": "whitespace",
"start": 82,
"end": 83,
"value": " "
},
{
"type": "dollar",
"start": 83,
"end": 84,
"value": "$"
},
{
"type": "word",
"start": 84,
"end": 89,
"value": "thing"
},
{
"type": "brace",
"start": 89,
"end": 90,
"value": ")"
},
{
"type": "whitespace",
"start": 90,
"end": 93,
"value": "\n "
},
{
"type": "operator",
"start": 93,
"end": 95,
"value": "|>"
},
{
"type": "whitespace",
"start": 95,
"end": 96,
"value": " "
},
{
"type": "word",
"start": 96,
"end": 100,
"value": "line"
},
{
"type": "brace",
"start": 100,
"end": 101,
"value": "("
},
{
"type": "brace",
"start": 101,
"end": 102,
"value": "["
},
{
"type": "number",
"start": 102,
"end": 104,
"value": "10"
},
{
"type": "comma",
"start": 104,
"end": 105,
"value": ","
},
{
"type": "whitespace",
"start": 105,
"end": 106,
"value": " "
},
{
"type": "number",
"start": 106,
"end": 107,
"value": "0"
},
{
"type": "brace",
"start": 107,
"end": 108,
"value": "]"
},
{
"type": "comma",
"start": 108,
"end": 109,
"value": ","
},
{
"type": "whitespace",
"start": 109,
"end": 110,
"value": " "
},
{
"type": "operator",
"start": 110,
"end": 111,
"value": "%"
},
{
"type": "brace",
"start": 111,
"end": 112,
"value": ")"
},
{
"type": "whitespace",
"start": 112,
"end": 115,
"value": "\n "
},
{
"type": "operator",
"start": 115,
"end": 117,
"value": "|>"
},
{
"type": "whitespace",
"start": 117,
"end": 118,
"value": " "
},
{
"type": "word",
"start": 118,
"end": 122,
"value": "line"
},
{
"type": "brace",
"start": 122,
"end": 123,
"value": "("
},
{
"type": "brace",
"start": 123,
"end": 124,
"value": "["
},
{
"type": "number",
"start": 124,
"end": 125,
"value": "0"
},
{
"type": "comma",
"start": 125,
"end": 126,
"value": ","
},
{
"type": "whitespace",
"start": 126,
"end": 127,
"value": " "
},
{
"type": "operator",
"start": 127,
"end": 128,
"value": "-"
},
{
"type": "number",
"start": 128,
"end": 130,
"value": "10"
},
{
"type": "brace",
"start": 130,
"end": 131,
"value": "]"
},
{
"type": "comma",
"start": 131,
"end": 132,
"value": ","
},
{
"type": "whitespace",
"start": 132,
"end": 133,
"value": " "
},
{
"type": "operator",
"start": 133,
"end": 134,
"value": "%"
},
{
"type": "comma",
"start": 134,
"end": 135,
"value": ","
},
{
"type": "whitespace",
"start": 135,
"end": 136,
"value": " "
},
{
"type": "dollar",
"start": 136,
"end": 137,
"value": "$"
},
{
"type": "word",
"start": 137,
"end": 143,
"value": "thing2"
},
{
"type": "brace",
"start": 143,
"end": 144,
"value": ")"
},
{
"type": "whitespace",
"start": 144,
"end": 147,
"value": "\n "
},
{
"type": "operator",
"start": 147,
"end": 149,
"value": "|>"
},
{
"type": "whitespace",
"start": 149,
"end": 150,
"value": " "
},
{
"type": "word",
"start": 150,
"end": 155,
"value": "close"
},
{
"type": "brace",
"start": 155,
"end": 156,
"value": "("
},
{
"type": "operator",
"start": 156,
"end": 157,
"value": "%"
},
{
"type": "brace",
"start": 157,
"end": 158,
"value": ")"
},
{
"type": "whitespace",
"start": 158,
"end": 161,
"value": "\n "
},
{
"type": "operator",
"start": 161,
"end": 163,
"value": "|>"
},
{
"type": "whitespace",
"start": 163,
"end": 164,
"value": " "
},
{
"type": "word",
"start": 164,
"end": 171,
"value": "extrude"
},
{
"type": "brace",
"start": 171,
"end": 172,
"value": "("
},
{
"type": "number",
"start": 172,
"end": 174,
"value": "10"
},
{
"type": "comma",
"start": 174,
"end": 175,
"value": ","
},
{
"type": "whitespace",
"start": 175,
"end": 176,
"value": " "
},
{
"type": "operator",
"start": 176,
"end": 177,
"value": "%"
},
{
"type": "brace",
"start": 177,
"end": 178,
"value": ")"
},
{
"type": "whitespace",
"start": 178,
"end": 181,
"value": "\n "
},
{
"type": "operator",
"start": 181,
"end": 183,
"value": "|>"
},
{
"type": "whitespace",
"start": 183,
"end": 184,
"value": " "
},
{
"type": "word",
"start": 184,
"end": 190,
"value": "fillet"
},
{
"type": "brace",
"start": 190,
"end": 191,
"value": "("
},
{
"type": "brace",
"start": 191,
"end": 192,
"value": "{"
},
{
"type": "whitespace",
"start": 192,
"end": 200,
"value": "\n "
},
{
"type": "word",
"start": 200,
"end": 206,
"value": "radius"
},
{
"type": "colon",
"start": 206,
"end": 207,
"value": ":"
},
{
"type": "whitespace",
"start": 207,
"end": 208,
"value": " "
},
{
"type": "number",
"start": 208,
"end": 209,
"value": "2"
},
{
"type": "comma",
"start": 209,
"end": 210,
"value": ","
},
{
"type": "whitespace",
"start": 210,
"end": 218,
"value": "\n "
},
{
"type": "word",
"start": 218,
"end": 222,
"value": "tags"
},
{
"type": "colon",
"start": 222,
"end": 223,
"value": ":"
},
{
"type": "whitespace",
"start": 223,
"end": 224,
"value": " "
},
{
"type": "brace",
"start": 224,
"end": 225,
"value": "["
},
{
"type": "word",
"start": 225,
"end": 230,
"value": "thing"
},
{
"type": "comma",
"start": 230,
"end": 231,
"value": ","
},
{
"type": "whitespace",
"start": 231,
"end": 232,
"value": " "
},
{
"type": "word",
"start": 232,
"end": 247,
"value": "getOppositeEdge"
},
{
"type": "brace",
"start": 247,
"end": 248,
"value": "("
},
{
"type": "word",
"start": 248,
"end": 253,
"value": "thing"
},
{
"type": "brace",
"start": 253,
"end": 254,
"value": ")"
},
{
"type": "brace",
"start": 254,
"end": 255,
"value": "]"
},
{
"type": "whitespace",
"start": 255,
"end": 261,
"value": "\n "
},
{
"type": "brace",
"start": 261,
"end": 262,
"value": "}"
},
{
"type": "comma",
"start": 262,
"end": 263,
"value": ","
},
{
"type": "whitespace",
"start": 263,
"end": 264,
"value": " "
},
{
"type": "operator",
"start": 264,
"end": 265,
"value": "%"
},
{
"type": "brace",
"start": 265,
"end": 266,
"value": ")"
},
{
"type": "whitespace",
"start": 266,
"end": 267,
"value": "\n"
}
]
}

View File

@ -0,0 +1,418 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing basic_fillet_cube_next_adjacent.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 282,
"id": {
"end": 7,
"name": "part001",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 28,
"raw": "'XY'",
"start": 24,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"end": 23,
"name": "startSketchOn",
"start": 10,
"type": "Identifier"
},
"end": 29,
"optional": false,
"start": 10,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 52,
"raw": "0",
"start": 51,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 55,
"raw": "0",
"start": 54,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 56,
"start": 50,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 59,
"start": 58,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 49,
"name": "startProfileAt",
"start": 35,
"type": "Identifier"
},
"end": 60,
"optional": false,
"start": 35,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 73,
"raw": "0",
"start": 72,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 77,
"raw": "10",
"start": 75,
"type": "Literal",
"type": "Literal",
"value": 10
}
],
"end": 78,
"start": 71,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 81,
"start": 80,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 89,
"start": 83,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing"
}
],
"callee": {
"end": 70,
"name": "line",
"start": 66,
"type": "Identifier"
},
"end": 90,
"optional": false,
"start": 66,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 104,
"raw": "10",
"start": 102,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 107,
"raw": "0",
"start": 106,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 108,
"start": 101,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 111,
"start": 110,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 120,
"start": 113,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing1"
}
],
"callee": {
"end": 100,
"name": "line",
"start": 96,
"type": "Identifier"
},
"end": 121,
"optional": false,
"start": 96,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 134,
"raw": "0",
"start": 133,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"argument": {
"end": 139,
"raw": "10",
"start": 137,
"type": "Literal",
"type": "Literal",
"value": 10
},
"end": 139,
"operator": "-",
"start": 136,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 140,
"start": 132,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 143,
"start": 142,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 152,
"start": 145,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing2"
}
],
"callee": {
"end": 131,
"name": "line",
"start": 127,
"type": "Identifier"
},
"end": 153,
"optional": false,
"start": 127,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 166,
"start": 165,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 175,
"start": 168,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing3"
}
],
"callee": {
"end": 164,
"name": "close",
"start": 159,
"type": "Identifier"
},
"end": 176,
"optional": false,
"start": 159,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 192,
"raw": "10",
"start": 190,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 195,
"start": 194,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 189,
"name": "extrude",
"start": 182,
"type": "Identifier"
},
"end": 196,
"optional": false,
"start": 182,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 278,
"properties": [
{
"end": 227,
"key": {
"end": 224,
"name": "radius",
"start": 218,
"type": "Identifier"
},
"start": 218,
"type": "ObjectProperty",
"value": {
"end": 227,
"raw": "2",
"start": 226,
"type": "Literal",
"type": "Literal",
"value": 2
}
},
{
"end": 271,
"key": {
"end": 240,
"name": "tags",
"start": 236,
"type": "Identifier"
},
"start": 236,
"type": "ObjectProperty",
"value": {
"elements": [
{
"arguments": [
{
"end": 269,
"name": "thing3",
"start": 263,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"end": 262,
"name": "getNextAdjacentEdge",
"start": 243,
"type": "Identifier"
},
"end": 270,
"optional": false,
"start": 243,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 271,
"start": 242,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"start": 209,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 281,
"start": 280,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 208,
"name": "fillet",
"start": 202,
"type": "Identifier"
},
"end": 282,
"optional": false,
"start": 202,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 282,
"start": 10,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
}
],
"end": 282,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 283,
"start": 0
}
}

View File

@ -0,0 +1,11 @@
part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([0, 10], %, $thing)
|> line([10, 0], %, $thing1)
|> line([0, -10], %, $thing2)
|> close(%, $thing3)
|> extrude(10, %)
|> fillet({
radius: 2,
tags: [getNextAdjacentEdge(thing3)]
}, %)

View File

@ -0,0 +1,766 @@
---
source: kcl/src/simulation_tests.rs
description: Program memory after executing basic_fillet_cube_next_adjacent.kcl
snapshot_kind: text
---
{
"environments": [
{
"bindings": {
"HALF_TURN": {
"type": "Number",
"value": 180.0,
"__meta": []
},
"QUARTER_TURN": {
"type": "Number",
"value": 90.0,
"__meta": []
},
"THREE_QUARTER_TURN": {
"type": "Number",
"value": 270.0,
"__meta": []
},
"ZERO": {
"type": "Number",
"value": 0.0,
"__meta": []
},
"part001": {
"type": "Solid",
"type": "Solid",
"id": "[uuid]",
"value": [
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
96,
121,
0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
127,
153,
0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
159,
176,
0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"type": "extrudePlane"
}
],
"sketch": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
96,
121,
0
]
},
"from": [
0.0,
10.0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"to": [
10.0,
10.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
127,
153,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
159,
176,
0
]
},
"from": [
10.0,
0.0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"to": [
0.0,
0.0
],
"type": "ToPoint"
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"__meta": []
},
"start": {
"from": [
0.0,
0.0
],
"to": [
0.0,
0.0
],
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
35,
60,
0
]
}
},
"tags": {
"thing": {
"type": "TagIdentifier",
"value": "thing",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
83,
89,
0
]
}
]
},
"thing1": {
"type": "TagIdentifier",
"value": "thing1",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
96,
121,
0
]
},
"from": [
0.0,
10.0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"to": [
10.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
96,
121,
0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
113,
120,
0
]
}
]
},
"thing2": {
"type": "TagIdentifier",
"value": "thing2",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
127,
153,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
127,
153,
0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
145,
152,
0
]
}
]
},
"thing3": {
"type": "TagIdentifier",
"value": "thing3",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
159,
176,
0
]
},
"from": [
10.0,
0.0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"to": [
0.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
159,
176,
0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
168,
175,
0
]
}
]
}
},
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"height": 10.0,
"startCapId": "[uuid]",
"endCapId": "[uuid]",
"edgeCuts": [
{
"type": "fillet",
"id": "[uuid]",
"radius": 2.0,
"edgeId": "[uuid]",
"tag": null
}
],
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"thing": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
83,
89,
0
]
}
]
},
"thing1": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing1",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
96,
121,
0
]
},
"from": [
0.0,
10.0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"to": [
10.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
96,
121,
0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
113,
120,
0
]
}
]
},
"thing2": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing2",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
127,
153,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
127,
153,
0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
145,
152,
0
]
}
]
},
"thing3": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing3",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
159,
176,
0
]
},
"from": [
10.0,
0.0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"to": [
0.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
159,
176,
0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
168,
175,
0
]
}
]
}
},
"parent": null
}
],
"currentEnv": 0,
"return": null
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

View File

@ -0,0 +1,795 @@
---
source: kcl/src/simulation_tests.rs
description: Result of tokenizing basic_fillet_cube_next_adjacent.kcl
snapshot_kind: text
---
{
"Ok": [
{
"type": "word",
"start": 0,
"end": 7,
"value": "part001"
},
{
"type": "whitespace",
"start": 7,
"end": 8,
"value": " "
},
{
"type": "operator",
"start": 8,
"end": 9,
"value": "="
},
{
"type": "whitespace",
"start": 9,
"end": 10,
"value": " "
},
{
"type": "word",
"start": 10,
"end": 23,
"value": "startSketchOn"
},
{
"type": "brace",
"start": 23,
"end": 24,
"value": "("
},
{
"type": "string",
"start": 24,
"end": 28,
"value": "'XY'"
},
{
"type": "brace",
"start": 28,
"end": 29,
"value": ")"
},
{
"type": "whitespace",
"start": 29,
"end": 32,
"value": "\n "
},
{
"type": "operator",
"start": 32,
"end": 34,
"value": "|>"
},
{
"type": "whitespace",
"start": 34,
"end": 35,
"value": " "
},
{
"type": "word",
"start": 35,
"end": 49,
"value": "startProfileAt"
},
{
"type": "brace",
"start": 49,
"end": 50,
"value": "("
},
{
"type": "brace",
"start": 50,
"end": 51,
"value": "["
},
{
"type": "number",
"start": 51,
"end": 52,
"value": "0"
},
{
"type": "comma",
"start": 52,
"end": 53,
"value": ","
},
{
"type": "whitespace",
"start": 53,
"end": 54,
"value": " "
},
{
"type": "number",
"start": 54,
"end": 55,
"value": "0"
},
{
"type": "brace",
"start": 55,
"end": 56,
"value": "]"
},
{
"type": "comma",
"start": 56,
"end": 57,
"value": ","
},
{
"type": "whitespace",
"start": 57,
"end": 58,
"value": " "
},
{
"type": "operator",
"start": 58,
"end": 59,
"value": "%"
},
{
"type": "brace",
"start": 59,
"end": 60,
"value": ")"
},
{
"type": "whitespace",
"start": 60,
"end": 63,
"value": "\n "
},
{
"type": "operator",
"start": 63,
"end": 65,
"value": "|>"
},
{
"type": "whitespace",
"start": 65,
"end": 66,
"value": " "
},
{
"type": "word",
"start": 66,
"end": 70,
"value": "line"
},
{
"type": "brace",
"start": 70,
"end": 71,
"value": "("
},
{
"type": "brace",
"start": 71,
"end": 72,
"value": "["
},
{
"type": "number",
"start": 72,
"end": 73,
"value": "0"
},
{
"type": "comma",
"start": 73,
"end": 74,
"value": ","
},
{
"type": "whitespace",
"start": 74,
"end": 75,
"value": " "
},
{
"type": "number",
"start": 75,
"end": 77,
"value": "10"
},
{
"type": "brace",
"start": 77,
"end": 78,
"value": "]"
},
{
"type": "comma",
"start": 78,
"end": 79,
"value": ","
},
{
"type": "whitespace",
"start": 79,
"end": 80,
"value": " "
},
{
"type": "operator",
"start": 80,
"end": 81,
"value": "%"
},
{
"type": "comma",
"start": 81,
"end": 82,
"value": ","
},
{
"type": "whitespace",
"start": 82,
"end": 83,
"value": " "
},
{
"type": "dollar",
"start": 83,
"end": 84,
"value": "$"
},
{
"type": "word",
"start": 84,
"end": 89,
"value": "thing"
},
{
"type": "brace",
"start": 89,
"end": 90,
"value": ")"
},
{
"type": "whitespace",
"start": 90,
"end": 93,
"value": "\n "
},
{
"type": "operator",
"start": 93,
"end": 95,
"value": "|>"
},
{
"type": "whitespace",
"start": 95,
"end": 96,
"value": " "
},
{
"type": "word",
"start": 96,
"end": 100,
"value": "line"
},
{
"type": "brace",
"start": 100,
"end": 101,
"value": "("
},
{
"type": "brace",
"start": 101,
"end": 102,
"value": "["
},
{
"type": "number",
"start": 102,
"end": 104,
"value": "10"
},
{
"type": "comma",
"start": 104,
"end": 105,
"value": ","
},
{
"type": "whitespace",
"start": 105,
"end": 106,
"value": " "
},
{
"type": "number",
"start": 106,
"end": 107,
"value": "0"
},
{
"type": "brace",
"start": 107,
"end": 108,
"value": "]"
},
{
"type": "comma",
"start": 108,
"end": 109,
"value": ","
},
{
"type": "whitespace",
"start": 109,
"end": 110,
"value": " "
},
{
"type": "operator",
"start": 110,
"end": 111,
"value": "%"
},
{
"type": "comma",
"start": 111,
"end": 112,
"value": ","
},
{
"type": "whitespace",
"start": 112,
"end": 113,
"value": " "
},
{
"type": "dollar",
"start": 113,
"end": 114,
"value": "$"
},
{
"type": "word",
"start": 114,
"end": 120,
"value": "thing1"
},
{
"type": "brace",
"start": 120,
"end": 121,
"value": ")"
},
{
"type": "whitespace",
"start": 121,
"end": 124,
"value": "\n "
},
{
"type": "operator",
"start": 124,
"end": 126,
"value": "|>"
},
{
"type": "whitespace",
"start": 126,
"end": 127,
"value": " "
},
{
"type": "word",
"start": 127,
"end": 131,
"value": "line"
},
{
"type": "brace",
"start": 131,
"end": 132,
"value": "("
},
{
"type": "brace",
"start": 132,
"end": 133,
"value": "["
},
{
"type": "number",
"start": 133,
"end": 134,
"value": "0"
},
{
"type": "comma",
"start": 134,
"end": 135,
"value": ","
},
{
"type": "whitespace",
"start": 135,
"end": 136,
"value": " "
},
{
"type": "operator",
"start": 136,
"end": 137,
"value": "-"
},
{
"type": "number",
"start": 137,
"end": 139,
"value": "10"
},
{
"type": "brace",
"start": 139,
"end": 140,
"value": "]"
},
{
"type": "comma",
"start": 140,
"end": 141,
"value": ","
},
{
"type": "whitespace",
"start": 141,
"end": 142,
"value": " "
},
{
"type": "operator",
"start": 142,
"end": 143,
"value": "%"
},
{
"type": "comma",
"start": 143,
"end": 144,
"value": ","
},
{
"type": "whitespace",
"start": 144,
"end": 145,
"value": " "
},
{
"type": "dollar",
"start": 145,
"end": 146,
"value": "$"
},
{
"type": "word",
"start": 146,
"end": 152,
"value": "thing2"
},
{
"type": "brace",
"start": 152,
"end": 153,
"value": ")"
},
{
"type": "whitespace",
"start": 153,
"end": 156,
"value": "\n "
},
{
"type": "operator",
"start": 156,
"end": 158,
"value": "|>"
},
{
"type": "whitespace",
"start": 158,
"end": 159,
"value": " "
},
{
"type": "word",
"start": 159,
"end": 164,
"value": "close"
},
{
"type": "brace",
"start": 164,
"end": 165,
"value": "("
},
{
"type": "operator",
"start": 165,
"end": 166,
"value": "%"
},
{
"type": "comma",
"start": 166,
"end": 167,
"value": ","
},
{
"type": "whitespace",
"start": 167,
"end": 168,
"value": " "
},
{
"type": "dollar",
"start": 168,
"end": 169,
"value": "$"
},
{
"type": "word",
"start": 169,
"end": 175,
"value": "thing3"
},
{
"type": "brace",
"start": 175,
"end": 176,
"value": ")"
},
{
"type": "whitespace",
"start": 176,
"end": 179,
"value": "\n "
},
{
"type": "operator",
"start": 179,
"end": 181,
"value": "|>"
},
{
"type": "whitespace",
"start": 181,
"end": 182,
"value": " "
},
{
"type": "word",
"start": 182,
"end": 189,
"value": "extrude"
},
{
"type": "brace",
"start": 189,
"end": 190,
"value": "("
},
{
"type": "number",
"start": 190,
"end": 192,
"value": "10"
},
{
"type": "comma",
"start": 192,
"end": 193,
"value": ","
},
{
"type": "whitespace",
"start": 193,
"end": 194,
"value": " "
},
{
"type": "operator",
"start": 194,
"end": 195,
"value": "%"
},
{
"type": "brace",
"start": 195,
"end": 196,
"value": ")"
},
{
"type": "whitespace",
"start": 196,
"end": 199,
"value": "\n "
},
{
"type": "operator",
"start": 199,
"end": 201,
"value": "|>"
},
{
"type": "whitespace",
"start": 201,
"end": 202,
"value": " "
},
{
"type": "word",
"start": 202,
"end": 208,
"value": "fillet"
},
{
"type": "brace",
"start": 208,
"end": 209,
"value": "("
},
{
"type": "brace",
"start": 209,
"end": 210,
"value": "{"
},
{
"type": "whitespace",
"start": 210,
"end": 218,
"value": "\n "
},
{
"type": "word",
"start": 218,
"end": 224,
"value": "radius"
},
{
"type": "colon",
"start": 224,
"end": 225,
"value": ":"
},
{
"type": "whitespace",
"start": 225,
"end": 226,
"value": " "
},
{
"type": "number",
"start": 226,
"end": 227,
"value": "2"
},
{
"type": "comma",
"start": 227,
"end": 228,
"value": ","
},
{
"type": "whitespace",
"start": 228,
"end": 236,
"value": "\n "
},
{
"type": "word",
"start": 236,
"end": 240,
"value": "tags"
},
{
"type": "colon",
"start": 240,
"end": 241,
"value": ":"
},
{
"type": "whitespace",
"start": 241,
"end": 242,
"value": " "
},
{
"type": "brace",
"start": 242,
"end": 243,
"value": "["
},
{
"type": "word",
"start": 243,
"end": 262,
"value": "getNextAdjacentEdge"
},
{
"type": "brace",
"start": 262,
"end": 263,
"value": "("
},
{
"type": "word",
"start": 263,
"end": 269,
"value": "thing3"
},
{
"type": "brace",
"start": 269,
"end": 270,
"value": ")"
},
{
"type": "brace",
"start": 270,
"end": 271,
"value": "]"
},
{
"type": "whitespace",
"start": 271,
"end": 277,
"value": "\n "
},
{
"type": "brace",
"start": 277,
"end": 278,
"value": "}"
},
{
"type": "comma",
"start": 278,
"end": 279,
"value": ","
},
{
"type": "whitespace",
"start": 279,
"end": 280,
"value": " "
},
{
"type": "operator",
"start": 280,
"end": 281,
"value": "%"
},
{
"type": "brace",
"start": 281,
"end": 282,
"value": ")"
},
{
"type": "whitespace",
"start": 282,
"end": 283,
"value": "\n"
}
]
}

View File

@ -0,0 +1,418 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing basic_fillet_cube_previous_adjacent.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 286,
"id": {
"end": 7,
"name": "part001",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 28,
"raw": "'XY'",
"start": 24,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"end": 23,
"name": "startSketchOn",
"start": 10,
"type": "Identifier"
},
"end": 29,
"optional": false,
"start": 10,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 52,
"raw": "0",
"start": 51,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 55,
"raw": "0",
"start": 54,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 56,
"start": 50,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 59,
"start": 58,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 49,
"name": "startProfileAt",
"start": 35,
"type": "Identifier"
},
"end": 60,
"optional": false,
"start": 35,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 73,
"raw": "0",
"start": 72,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 77,
"raw": "10",
"start": 75,
"type": "Literal",
"type": "Literal",
"value": 10
}
],
"end": 78,
"start": 71,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 81,
"start": 80,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 89,
"start": 83,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing"
}
],
"callee": {
"end": 70,
"name": "line",
"start": 66,
"type": "Identifier"
},
"end": 90,
"optional": false,
"start": 66,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 104,
"raw": "10",
"start": 102,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 107,
"raw": "0",
"start": 106,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 108,
"start": 101,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 111,
"start": 110,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 120,
"start": 113,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing1"
}
],
"callee": {
"end": 100,
"name": "line",
"start": 96,
"type": "Identifier"
},
"end": 121,
"optional": false,
"start": 96,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 134,
"raw": "0",
"start": 133,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"argument": {
"end": 139,
"raw": "10",
"start": 137,
"type": "Literal",
"type": "Literal",
"value": 10
},
"end": 139,
"operator": "-",
"start": 136,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 140,
"start": 132,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 143,
"start": 142,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 152,
"start": 145,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing2"
}
],
"callee": {
"end": 131,
"name": "line",
"start": 127,
"type": "Identifier"
},
"end": 153,
"optional": false,
"start": 127,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 166,
"start": 165,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 175,
"start": 168,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing3"
}
],
"callee": {
"end": 164,
"name": "close",
"start": 159,
"type": "Identifier"
},
"end": 176,
"optional": false,
"start": 159,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 192,
"raw": "10",
"start": 190,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 195,
"start": 194,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 189,
"name": "extrude",
"start": 182,
"type": "Identifier"
},
"end": 196,
"optional": false,
"start": 182,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 282,
"properties": [
{
"end": 227,
"key": {
"end": 224,
"name": "radius",
"start": 218,
"type": "Identifier"
},
"start": 218,
"type": "ObjectProperty",
"value": {
"end": 227,
"raw": "2",
"start": 226,
"type": "Literal",
"type": "Literal",
"value": 2
}
},
{
"end": 275,
"key": {
"end": 240,
"name": "tags",
"start": 236,
"type": "Identifier"
},
"start": 236,
"type": "ObjectProperty",
"value": {
"elements": [
{
"arguments": [
{
"end": 273,
"name": "thing3",
"start": 267,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"end": 266,
"name": "getPreviousAdjacentEdge",
"start": 243,
"type": "Identifier"
},
"end": 274,
"optional": false,
"start": 243,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 275,
"start": 242,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"start": 209,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 285,
"start": 284,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 208,
"name": "fillet",
"start": 202,
"type": "Identifier"
},
"end": 286,
"optional": false,
"start": 202,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 286,
"start": 10,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
}
],
"end": 286,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 287,
"start": 0
}
}

View File

@ -0,0 +1,11 @@
part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([0, 10], %, $thing)
|> line([10, 0], %, $thing1)
|> line([0, -10], %, $thing2)
|> close(%, $thing3)
|> extrude(10, %)
|> fillet({
radius: 2,
tags: [getPreviousAdjacentEdge(thing3)]
}, %)

View File

@ -0,0 +1,766 @@
---
source: kcl/src/simulation_tests.rs
description: Program memory after executing basic_fillet_cube_previous_adjacent.kcl
snapshot_kind: text
---
{
"environments": [
{
"bindings": {
"HALF_TURN": {
"type": "Number",
"value": 180.0,
"__meta": []
},
"QUARTER_TURN": {
"type": "Number",
"value": 90.0,
"__meta": []
},
"THREE_QUARTER_TURN": {
"type": "Number",
"value": 270.0,
"__meta": []
},
"ZERO": {
"type": "Number",
"value": 0.0,
"__meta": []
},
"part001": {
"type": "Solid",
"type": "Solid",
"id": "[uuid]",
"value": [
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
96,
121,
0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
127,
153,
0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
159,
176,
0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"type": "extrudePlane"
}
],
"sketch": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
96,
121,
0
]
},
"from": [
0.0,
10.0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"to": [
10.0,
10.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
127,
153,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
159,
176,
0
]
},
"from": [
10.0,
0.0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"to": [
0.0,
0.0
],
"type": "ToPoint"
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"__meta": []
},
"start": {
"from": [
0.0,
0.0
],
"to": [
0.0,
0.0
],
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
35,
60,
0
]
}
},
"tags": {
"thing": {
"type": "TagIdentifier",
"value": "thing",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
83,
89,
0
]
}
]
},
"thing1": {
"type": "TagIdentifier",
"value": "thing1",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
96,
121,
0
]
},
"from": [
0.0,
10.0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"to": [
10.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
96,
121,
0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
113,
120,
0
]
}
]
},
"thing2": {
"type": "TagIdentifier",
"value": "thing2",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
127,
153,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
127,
153,
0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
145,
152,
0
]
}
]
},
"thing3": {
"type": "TagIdentifier",
"value": "thing3",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
159,
176,
0
]
},
"from": [
10.0,
0.0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"to": [
0.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
159,
176,
0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
168,
175,
0
]
}
]
}
},
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"height": 10.0,
"startCapId": "[uuid]",
"endCapId": "[uuid]",
"edgeCuts": [
{
"type": "fillet",
"id": "[uuid]",
"radius": 2.0,
"edgeId": "[uuid]",
"tag": null
}
],
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"thing": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
83,
89,
0
]
}
]
},
"thing1": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing1",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
96,
121,
0
]
},
"from": [
0.0,
10.0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"to": [
10.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
96,
121,
0
],
"tag": {
"end": 120,
"start": 113,
"type": "TagDeclarator",
"value": "thing1"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
113,
120,
0
]
}
]
},
"thing2": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing2",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
127,
153,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
127,
153,
0
],
"tag": {
"end": 152,
"start": 145,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
145,
152,
0
]
}
]
},
"thing3": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing3",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
159,
176,
0
]
},
"from": [
10.0,
0.0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"to": [
0.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
159,
176,
0
],
"tag": {
"end": 175,
"start": 168,
"type": "TagDeclarator",
"value": "thing3"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
168,
175,
0
]
}
]
}
},
"parent": null
}
],
"currentEnv": 0,
"return": null
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

View File

@ -0,0 +1,795 @@
---
source: kcl/src/simulation_tests.rs
description: Result of tokenizing basic_fillet_cube_previous_adjacent.kcl
snapshot_kind: text
---
{
"Ok": [
{
"type": "word",
"start": 0,
"end": 7,
"value": "part001"
},
{
"type": "whitespace",
"start": 7,
"end": 8,
"value": " "
},
{
"type": "operator",
"start": 8,
"end": 9,
"value": "="
},
{
"type": "whitespace",
"start": 9,
"end": 10,
"value": " "
},
{
"type": "word",
"start": 10,
"end": 23,
"value": "startSketchOn"
},
{
"type": "brace",
"start": 23,
"end": 24,
"value": "("
},
{
"type": "string",
"start": 24,
"end": 28,
"value": "'XY'"
},
{
"type": "brace",
"start": 28,
"end": 29,
"value": ")"
},
{
"type": "whitespace",
"start": 29,
"end": 32,
"value": "\n "
},
{
"type": "operator",
"start": 32,
"end": 34,
"value": "|>"
},
{
"type": "whitespace",
"start": 34,
"end": 35,
"value": " "
},
{
"type": "word",
"start": 35,
"end": 49,
"value": "startProfileAt"
},
{
"type": "brace",
"start": 49,
"end": 50,
"value": "("
},
{
"type": "brace",
"start": 50,
"end": 51,
"value": "["
},
{
"type": "number",
"start": 51,
"end": 52,
"value": "0"
},
{
"type": "comma",
"start": 52,
"end": 53,
"value": ","
},
{
"type": "whitespace",
"start": 53,
"end": 54,
"value": " "
},
{
"type": "number",
"start": 54,
"end": 55,
"value": "0"
},
{
"type": "brace",
"start": 55,
"end": 56,
"value": "]"
},
{
"type": "comma",
"start": 56,
"end": 57,
"value": ","
},
{
"type": "whitespace",
"start": 57,
"end": 58,
"value": " "
},
{
"type": "operator",
"start": 58,
"end": 59,
"value": "%"
},
{
"type": "brace",
"start": 59,
"end": 60,
"value": ")"
},
{
"type": "whitespace",
"start": 60,
"end": 63,
"value": "\n "
},
{
"type": "operator",
"start": 63,
"end": 65,
"value": "|>"
},
{
"type": "whitespace",
"start": 65,
"end": 66,
"value": " "
},
{
"type": "word",
"start": 66,
"end": 70,
"value": "line"
},
{
"type": "brace",
"start": 70,
"end": 71,
"value": "("
},
{
"type": "brace",
"start": 71,
"end": 72,
"value": "["
},
{
"type": "number",
"start": 72,
"end": 73,
"value": "0"
},
{
"type": "comma",
"start": 73,
"end": 74,
"value": ","
},
{
"type": "whitespace",
"start": 74,
"end": 75,
"value": " "
},
{
"type": "number",
"start": 75,
"end": 77,
"value": "10"
},
{
"type": "brace",
"start": 77,
"end": 78,
"value": "]"
},
{
"type": "comma",
"start": 78,
"end": 79,
"value": ","
},
{
"type": "whitespace",
"start": 79,
"end": 80,
"value": " "
},
{
"type": "operator",
"start": 80,
"end": 81,
"value": "%"
},
{
"type": "comma",
"start": 81,
"end": 82,
"value": ","
},
{
"type": "whitespace",
"start": 82,
"end": 83,
"value": " "
},
{
"type": "dollar",
"start": 83,
"end": 84,
"value": "$"
},
{
"type": "word",
"start": 84,
"end": 89,
"value": "thing"
},
{
"type": "brace",
"start": 89,
"end": 90,
"value": ")"
},
{
"type": "whitespace",
"start": 90,
"end": 93,
"value": "\n "
},
{
"type": "operator",
"start": 93,
"end": 95,
"value": "|>"
},
{
"type": "whitespace",
"start": 95,
"end": 96,
"value": " "
},
{
"type": "word",
"start": 96,
"end": 100,
"value": "line"
},
{
"type": "brace",
"start": 100,
"end": 101,
"value": "("
},
{
"type": "brace",
"start": 101,
"end": 102,
"value": "["
},
{
"type": "number",
"start": 102,
"end": 104,
"value": "10"
},
{
"type": "comma",
"start": 104,
"end": 105,
"value": ","
},
{
"type": "whitespace",
"start": 105,
"end": 106,
"value": " "
},
{
"type": "number",
"start": 106,
"end": 107,
"value": "0"
},
{
"type": "brace",
"start": 107,
"end": 108,
"value": "]"
},
{
"type": "comma",
"start": 108,
"end": 109,
"value": ","
},
{
"type": "whitespace",
"start": 109,
"end": 110,
"value": " "
},
{
"type": "operator",
"start": 110,
"end": 111,
"value": "%"
},
{
"type": "comma",
"start": 111,
"end": 112,
"value": ","
},
{
"type": "whitespace",
"start": 112,
"end": 113,
"value": " "
},
{
"type": "dollar",
"start": 113,
"end": 114,
"value": "$"
},
{
"type": "word",
"start": 114,
"end": 120,
"value": "thing1"
},
{
"type": "brace",
"start": 120,
"end": 121,
"value": ")"
},
{
"type": "whitespace",
"start": 121,
"end": 124,
"value": "\n "
},
{
"type": "operator",
"start": 124,
"end": 126,
"value": "|>"
},
{
"type": "whitespace",
"start": 126,
"end": 127,
"value": " "
},
{
"type": "word",
"start": 127,
"end": 131,
"value": "line"
},
{
"type": "brace",
"start": 131,
"end": 132,
"value": "("
},
{
"type": "brace",
"start": 132,
"end": 133,
"value": "["
},
{
"type": "number",
"start": 133,
"end": 134,
"value": "0"
},
{
"type": "comma",
"start": 134,
"end": 135,
"value": ","
},
{
"type": "whitespace",
"start": 135,
"end": 136,
"value": " "
},
{
"type": "operator",
"start": 136,
"end": 137,
"value": "-"
},
{
"type": "number",
"start": 137,
"end": 139,
"value": "10"
},
{
"type": "brace",
"start": 139,
"end": 140,
"value": "]"
},
{
"type": "comma",
"start": 140,
"end": 141,
"value": ","
},
{
"type": "whitespace",
"start": 141,
"end": 142,
"value": " "
},
{
"type": "operator",
"start": 142,
"end": 143,
"value": "%"
},
{
"type": "comma",
"start": 143,
"end": 144,
"value": ","
},
{
"type": "whitespace",
"start": 144,
"end": 145,
"value": " "
},
{
"type": "dollar",
"start": 145,
"end": 146,
"value": "$"
},
{
"type": "word",
"start": 146,
"end": 152,
"value": "thing2"
},
{
"type": "brace",
"start": 152,
"end": 153,
"value": ")"
},
{
"type": "whitespace",
"start": 153,
"end": 156,
"value": "\n "
},
{
"type": "operator",
"start": 156,
"end": 158,
"value": "|>"
},
{
"type": "whitespace",
"start": 158,
"end": 159,
"value": " "
},
{
"type": "word",
"start": 159,
"end": 164,
"value": "close"
},
{
"type": "brace",
"start": 164,
"end": 165,
"value": "("
},
{
"type": "operator",
"start": 165,
"end": 166,
"value": "%"
},
{
"type": "comma",
"start": 166,
"end": 167,
"value": ","
},
{
"type": "whitespace",
"start": 167,
"end": 168,
"value": " "
},
{
"type": "dollar",
"start": 168,
"end": 169,
"value": "$"
},
{
"type": "word",
"start": 169,
"end": 175,
"value": "thing3"
},
{
"type": "brace",
"start": 175,
"end": 176,
"value": ")"
},
{
"type": "whitespace",
"start": 176,
"end": 179,
"value": "\n "
},
{
"type": "operator",
"start": 179,
"end": 181,
"value": "|>"
},
{
"type": "whitespace",
"start": 181,
"end": 182,
"value": " "
},
{
"type": "word",
"start": 182,
"end": 189,
"value": "extrude"
},
{
"type": "brace",
"start": 189,
"end": 190,
"value": "("
},
{
"type": "number",
"start": 190,
"end": 192,
"value": "10"
},
{
"type": "comma",
"start": 192,
"end": 193,
"value": ","
},
{
"type": "whitespace",
"start": 193,
"end": 194,
"value": " "
},
{
"type": "operator",
"start": 194,
"end": 195,
"value": "%"
},
{
"type": "brace",
"start": 195,
"end": 196,
"value": ")"
},
{
"type": "whitespace",
"start": 196,
"end": 199,
"value": "\n "
},
{
"type": "operator",
"start": 199,
"end": 201,
"value": "|>"
},
{
"type": "whitespace",
"start": 201,
"end": 202,
"value": " "
},
{
"type": "word",
"start": 202,
"end": 208,
"value": "fillet"
},
{
"type": "brace",
"start": 208,
"end": 209,
"value": "("
},
{
"type": "brace",
"start": 209,
"end": 210,
"value": "{"
},
{
"type": "whitespace",
"start": 210,
"end": 218,
"value": "\n "
},
{
"type": "word",
"start": 218,
"end": 224,
"value": "radius"
},
{
"type": "colon",
"start": 224,
"end": 225,
"value": ":"
},
{
"type": "whitespace",
"start": 225,
"end": 226,
"value": " "
},
{
"type": "number",
"start": 226,
"end": 227,
"value": "2"
},
{
"type": "comma",
"start": 227,
"end": 228,
"value": ","
},
{
"type": "whitespace",
"start": 228,
"end": 236,
"value": "\n "
},
{
"type": "word",
"start": 236,
"end": 240,
"value": "tags"
},
{
"type": "colon",
"start": 240,
"end": 241,
"value": ":"
},
{
"type": "whitespace",
"start": 241,
"end": 242,
"value": " "
},
{
"type": "brace",
"start": 242,
"end": 243,
"value": "["
},
{
"type": "word",
"start": 243,
"end": 266,
"value": "getPreviousAdjacentEdge"
},
{
"type": "brace",
"start": 266,
"end": 267,
"value": "("
},
{
"type": "word",
"start": 267,
"end": 273,
"value": "thing3"
},
{
"type": "brace",
"start": 273,
"end": 274,
"value": ")"
},
{
"type": "brace",
"start": 274,
"end": 275,
"value": "]"
},
{
"type": "whitespace",
"start": 275,
"end": 281,
"value": "\n "
},
{
"type": "brace",
"start": 281,
"end": 282,
"value": "}"
},
{
"type": "comma",
"start": 282,
"end": 283,
"value": ","
},
{
"type": "whitespace",
"start": 283,
"end": 284,
"value": " "
},
{
"type": "operator",
"start": 284,
"end": 285,
"value": "%"
},
{
"type": "brace",
"start": 285,
"end": 286,
"value": ")"
},
{
"type": "whitespace",
"start": 286,
"end": 287,
"value": "\n"
}
]
}

View File

@ -0,0 +1,396 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing basic_fillet_cube_start.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 231,
"id": {
"end": 7,
"name": "part001",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 28,
"raw": "'XY'",
"start": 24,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"end": 23,
"name": "startSketchOn",
"start": 10,
"type": "Identifier"
},
"end": 29,
"optional": false,
"start": 10,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 52,
"raw": "0",
"start": 51,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 55,
"raw": "0",
"start": 54,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 56,
"start": 50,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 59,
"start": 58,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 49,
"name": "startProfileAt",
"start": 35,
"type": "Identifier"
},
"end": 60,
"optional": false,
"start": 35,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 73,
"raw": "0",
"start": 72,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 77,
"raw": "10",
"start": 75,
"type": "Literal",
"type": "Literal",
"value": 10
}
],
"end": 78,
"start": 71,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 81,
"start": 80,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 89,
"start": 83,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing"
}
],
"callee": {
"end": 70,
"name": "line",
"start": 66,
"type": "Identifier"
},
"end": 90,
"optional": false,
"start": 66,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 104,
"raw": "10",
"start": 102,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 107,
"raw": "0",
"start": 106,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 108,
"start": 101,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 111,
"start": 110,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 100,
"name": "line",
"start": 96,
"type": "Identifier"
},
"end": 112,
"optional": false,
"start": 96,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 125,
"raw": "0",
"start": 124,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"argument": {
"end": 130,
"raw": "10",
"start": 128,
"type": "Literal",
"type": "Literal",
"value": 10
},
"end": 130,
"operator": "-",
"start": 127,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 131,
"start": 123,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 134,
"start": 133,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 143,
"start": 136,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "thing2"
}
],
"callee": {
"end": 122,
"name": "line",
"start": 118,
"type": "Identifier"
},
"end": 144,
"optional": false,
"start": 118,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 157,
"start": 156,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 155,
"name": "close",
"start": 150,
"type": "Identifier"
},
"end": 158,
"optional": false,
"start": 150,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 174,
"raw": "10",
"start": 172,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 177,
"start": 176,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 171,
"name": "extrude",
"start": 164,
"type": "Identifier"
},
"end": 178,
"optional": false,
"start": 164,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 227,
"properties": [
{
"end": 202,
"key": {
"end": 199,
"name": "radius",
"start": 193,
"type": "Identifier"
},
"start": 193,
"type": "ObjectProperty",
"value": {
"end": 202,
"raw": "2",
"start": 201,
"type": "Literal",
"type": "Literal",
"value": 2
}
},
{
"end": 225,
"key": {
"end": 208,
"name": "tags",
"start": 204,
"type": "Identifier"
},
"start": 204,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 216,
"name": "thing",
"start": 211,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 224,
"name": "thing2",
"start": 218,
"type": "Identifier",
"type": "Identifier"
}
],
"end": 225,
"start": 210,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
}
],
"start": 191,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 230,
"start": 229,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 190,
"name": "fillet",
"start": 184,
"type": "Identifier"
},
"end": 231,
"optional": false,
"start": 184,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 231,
"start": 10,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
}
],
"end": 231,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 232,
"start": 0
}
}

View File

@ -0,0 +1,8 @@
part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([0, 10], %, $thing)
|> line([10, 0], %)
|> line([0, -10], %, $thing2)
|> close(%)
|> extrude(10, %)
|> fillet({ radius: 2, tags: [thing, thing2] }, %)

View File

@ -0,0 +1,515 @@
---
source: kcl/src/simulation_tests.rs
description: Program memory after executing basic_fillet_cube_start.kcl
snapshot_kind: text
---
{
"environments": [
{
"bindings": {
"HALF_TURN": {
"type": "Number",
"value": 180.0,
"__meta": []
},
"QUARTER_TURN": {
"type": "Number",
"value": 90.0,
"__meta": []
},
"THREE_QUARTER_TURN": {
"type": "Number",
"value": 270.0,
"__meta": []
},
"ZERO": {
"type": "Number",
"value": 0.0,
"__meta": []
},
"part001": {
"type": "Solid",
"type": "Solid",
"id": "[uuid]",
"value": [
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
96,
112,
0
],
"tag": null,
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
118,
144,
0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
150,
158,
0
],
"tag": null,
"type": "extrudePlane"
}
],
"sketch": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
96,
112,
0
]
},
"from": [
0.0,
10.0
],
"tag": null,
"to": [
10.0,
10.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
118,
144,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
150,
158,
0
]
},
"from": [
10.0,
0.0
],
"tag": null,
"to": [
0.0,
0.0
],
"type": "ToPoint"
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"__meta": []
},
"start": {
"from": [
0.0,
0.0
],
"to": [
0.0,
0.0
],
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
35,
60,
0
]
}
},
"tags": {
"thing": {
"type": "TagIdentifier",
"value": "thing",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
83,
89,
0
]
}
]
},
"thing2": {
"type": "TagIdentifier",
"value": "thing2",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
118,
144,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
118,
144,
0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
136,
143,
0
]
}
]
}
},
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"height": 10.0,
"startCapId": "[uuid]",
"endCapId": "[uuid]",
"edgeCuts": [
{
"type": "fillet",
"id": "[uuid]",
"radius": 2.0,
"edgeId": "[uuid]",
"tag": null
},
{
"type": "fillet",
"id": "[uuid]",
"radius": 2.0,
"edgeId": "[uuid]",
"tag": null
}
],
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"thing": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
90,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"to": [
0.0,
10.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
90,
0
],
"tag": {
"end": 89,
"start": 83,
"type": "TagDeclarator",
"value": "thing"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
83,
89,
0
]
}
]
},
"thing2": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "thing2",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
118,
144,
0
]
},
"from": [
10.0,
10.0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"to": [
10.0,
0.0
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
118,
144,
0
],
"tag": {
"end": 143,
"start": 136,
"type": "TagDeclarator",
"value": "thing2"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
136,
143,
0
]
}
]
}
},
"parent": null
}
],
"currentEnv": 0,
"return": null
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

View File

@ -0,0 +1,747 @@
---
source: kcl/src/simulation_tests.rs
description: Result of tokenizing basic_fillet_cube_start.kcl
snapshot_kind: text
---
{
"Ok": [
{
"type": "word",
"start": 0,
"end": 7,
"value": "part001"
},
{
"type": "whitespace",
"start": 7,
"end": 8,
"value": " "
},
{
"type": "operator",
"start": 8,
"end": 9,
"value": "="
},
{
"type": "whitespace",
"start": 9,
"end": 10,
"value": " "
},
{
"type": "word",
"start": 10,
"end": 23,
"value": "startSketchOn"
},
{
"type": "brace",
"start": 23,
"end": 24,
"value": "("
},
{
"type": "string",
"start": 24,
"end": 28,
"value": "'XY'"
},
{
"type": "brace",
"start": 28,
"end": 29,
"value": ")"
},
{
"type": "whitespace",
"start": 29,
"end": 32,
"value": "\n "
},
{
"type": "operator",
"start": 32,
"end": 34,
"value": "|>"
},
{
"type": "whitespace",
"start": 34,
"end": 35,
"value": " "
},
{
"type": "word",
"start": 35,
"end": 49,
"value": "startProfileAt"
},
{
"type": "brace",
"start": 49,
"end": 50,
"value": "("
},
{
"type": "brace",
"start": 50,
"end": 51,
"value": "["
},
{
"type": "number",
"start": 51,
"end": 52,
"value": "0"
},
{
"type": "comma",
"start": 52,
"end": 53,
"value": ","
},
{
"type": "whitespace",
"start": 53,
"end": 54,
"value": " "
},
{
"type": "number",
"start": 54,
"end": 55,
"value": "0"
},
{
"type": "brace",
"start": 55,
"end": 56,
"value": "]"
},
{
"type": "comma",
"start": 56,
"end": 57,
"value": ","
},
{
"type": "whitespace",
"start": 57,
"end": 58,
"value": " "
},
{
"type": "operator",
"start": 58,
"end": 59,
"value": "%"
},
{
"type": "brace",
"start": 59,
"end": 60,
"value": ")"
},
{
"type": "whitespace",
"start": 60,
"end": 63,
"value": "\n "
},
{
"type": "operator",
"start": 63,
"end": 65,
"value": "|>"
},
{
"type": "whitespace",
"start": 65,
"end": 66,
"value": " "
},
{
"type": "word",
"start": 66,
"end": 70,
"value": "line"
},
{
"type": "brace",
"start": 70,
"end": 71,
"value": "("
},
{
"type": "brace",
"start": 71,
"end": 72,
"value": "["
},
{
"type": "number",
"start": 72,
"end": 73,
"value": "0"
},
{
"type": "comma",
"start": 73,
"end": 74,
"value": ","
},
{
"type": "whitespace",
"start": 74,
"end": 75,
"value": " "
},
{
"type": "number",
"start": 75,
"end": 77,
"value": "10"
},
{
"type": "brace",
"start": 77,
"end": 78,
"value": "]"
},
{
"type": "comma",
"start": 78,
"end": 79,
"value": ","
},
{
"type": "whitespace",
"start": 79,
"end": 80,
"value": " "
},
{
"type": "operator",
"start": 80,
"end": 81,
"value": "%"
},
{
"type": "comma",
"start": 81,
"end": 82,
"value": ","
},
{
"type": "whitespace",
"start": 82,
"end": 83,
"value": " "
},
{
"type": "dollar",
"start": 83,
"end": 84,
"value": "$"
},
{
"type": "word",
"start": 84,
"end": 89,
"value": "thing"
},
{
"type": "brace",
"start": 89,
"end": 90,
"value": ")"
},
{
"type": "whitespace",
"start": 90,
"end": 93,
"value": "\n "
},
{
"type": "operator",
"start": 93,
"end": 95,
"value": "|>"
},
{
"type": "whitespace",
"start": 95,
"end": 96,
"value": " "
},
{
"type": "word",
"start": 96,
"end": 100,
"value": "line"
},
{
"type": "brace",
"start": 100,
"end": 101,
"value": "("
},
{
"type": "brace",
"start": 101,
"end": 102,
"value": "["
},
{
"type": "number",
"start": 102,
"end": 104,
"value": "10"
},
{
"type": "comma",
"start": 104,
"end": 105,
"value": ","
},
{
"type": "whitespace",
"start": 105,
"end": 106,
"value": " "
},
{
"type": "number",
"start": 106,
"end": 107,
"value": "0"
},
{
"type": "brace",
"start": 107,
"end": 108,
"value": "]"
},
{
"type": "comma",
"start": 108,
"end": 109,
"value": ","
},
{
"type": "whitespace",
"start": 109,
"end": 110,
"value": " "
},
{
"type": "operator",
"start": 110,
"end": 111,
"value": "%"
},
{
"type": "brace",
"start": 111,
"end": 112,
"value": ")"
},
{
"type": "whitespace",
"start": 112,
"end": 115,
"value": "\n "
},
{
"type": "operator",
"start": 115,
"end": 117,
"value": "|>"
},
{
"type": "whitespace",
"start": 117,
"end": 118,
"value": " "
},
{
"type": "word",
"start": 118,
"end": 122,
"value": "line"
},
{
"type": "brace",
"start": 122,
"end": 123,
"value": "("
},
{
"type": "brace",
"start": 123,
"end": 124,
"value": "["
},
{
"type": "number",
"start": 124,
"end": 125,
"value": "0"
},
{
"type": "comma",
"start": 125,
"end": 126,
"value": ","
},
{
"type": "whitespace",
"start": 126,
"end": 127,
"value": " "
},
{
"type": "operator",
"start": 127,
"end": 128,
"value": "-"
},
{
"type": "number",
"start": 128,
"end": 130,
"value": "10"
},
{
"type": "brace",
"start": 130,
"end": 131,
"value": "]"
},
{
"type": "comma",
"start": 131,
"end": 132,
"value": ","
},
{
"type": "whitespace",
"start": 132,
"end": 133,
"value": " "
},
{
"type": "operator",
"start": 133,
"end": 134,
"value": "%"
},
{
"type": "comma",
"start": 134,
"end": 135,
"value": ","
},
{
"type": "whitespace",
"start": 135,
"end": 136,
"value": " "
},
{
"type": "dollar",
"start": 136,
"end": 137,
"value": "$"
},
{
"type": "word",
"start": 137,
"end": 143,
"value": "thing2"
},
{
"type": "brace",
"start": 143,
"end": 144,
"value": ")"
},
{
"type": "whitespace",
"start": 144,
"end": 147,
"value": "\n "
},
{
"type": "operator",
"start": 147,
"end": 149,
"value": "|>"
},
{
"type": "whitespace",
"start": 149,
"end": 150,
"value": " "
},
{
"type": "word",
"start": 150,
"end": 155,
"value": "close"
},
{
"type": "brace",
"start": 155,
"end": 156,
"value": "("
},
{
"type": "operator",
"start": 156,
"end": 157,
"value": "%"
},
{
"type": "brace",
"start": 157,
"end": 158,
"value": ")"
},
{
"type": "whitespace",
"start": 158,
"end": 161,
"value": "\n "
},
{
"type": "operator",
"start": 161,
"end": 163,
"value": "|>"
},
{
"type": "whitespace",
"start": 163,
"end": 164,
"value": " "
},
{
"type": "word",
"start": 164,
"end": 171,
"value": "extrude"
},
{
"type": "brace",
"start": 171,
"end": 172,
"value": "("
},
{
"type": "number",
"start": 172,
"end": 174,
"value": "10"
},
{
"type": "comma",
"start": 174,
"end": 175,
"value": ","
},
{
"type": "whitespace",
"start": 175,
"end": 176,
"value": " "
},
{
"type": "operator",
"start": 176,
"end": 177,
"value": "%"
},
{
"type": "brace",
"start": 177,
"end": 178,
"value": ")"
},
{
"type": "whitespace",
"start": 178,
"end": 181,
"value": "\n "
},
{
"type": "operator",
"start": 181,
"end": 183,
"value": "|>"
},
{
"type": "whitespace",
"start": 183,
"end": 184,
"value": " "
},
{
"type": "word",
"start": 184,
"end": 190,
"value": "fillet"
},
{
"type": "brace",
"start": 190,
"end": 191,
"value": "("
},
{
"type": "brace",
"start": 191,
"end": 192,
"value": "{"
},
{
"type": "whitespace",
"start": 192,
"end": 193,
"value": " "
},
{
"type": "word",
"start": 193,
"end": 199,
"value": "radius"
},
{
"type": "colon",
"start": 199,
"end": 200,
"value": ":"
},
{
"type": "whitespace",
"start": 200,
"end": 201,
"value": " "
},
{
"type": "number",
"start": 201,
"end": 202,
"value": "2"
},
{
"type": "comma",
"start": 202,
"end": 203,
"value": ","
},
{
"type": "whitespace",
"start": 203,
"end": 204,
"value": " "
},
{
"type": "word",
"start": 204,
"end": 208,
"value": "tags"
},
{
"type": "colon",
"start": 208,
"end": 209,
"value": ":"
},
{
"type": "whitespace",
"start": 209,
"end": 210,
"value": " "
},
{
"type": "brace",
"start": 210,
"end": 211,
"value": "["
},
{
"type": "word",
"start": 211,
"end": 216,
"value": "thing"
},
{
"type": "comma",
"start": 216,
"end": 217,
"value": ","
},
{
"type": "whitespace",
"start": 217,
"end": 218,
"value": " "
},
{
"type": "word",
"start": 218,
"end": 224,
"value": "thing2"
},
{
"type": "brace",
"start": 224,
"end": 225,
"value": "]"
},
{
"type": "whitespace",
"start": 225,
"end": 226,
"value": " "
},
{
"type": "brace",
"start": 226,
"end": 227,
"value": "}"
},
{
"type": "comma",
"start": 227,
"end": 228,
"value": ","
},
{
"type": "whitespace",
"start": 228,
"end": 229,
"value": " "
},
{
"type": "operator",
"start": 229,
"end": 230,
"value": "%"
},
{
"type": "brace",
"start": 230,
"end": 231,
"value": ")"
},
{
"type": "whitespace",
"start": 231,
"end": 232,
"value": "\n"
}
]
}

View File

@ -0,0 +1,291 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing big_number_angle_to_match_length_x.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 188,
"id": {
"end": 7,
"name": "part001",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 28,
"raw": "'XY'",
"start": 24,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"end": 23,
"name": "startSketchOn",
"start": 10,
"type": "Identifier"
},
"end": 29,
"optional": false,
"start": 10,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 52,
"raw": "0",
"start": 51,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 55,
"raw": "0",
"start": 54,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 56,
"start": 50,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 59,
"start": 58,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 49,
"name": "startProfileAt",
"start": 35,
"type": "Identifier"
},
"end": 60,
"optional": false,
"start": 35,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 73,
"raw": "1",
"start": 72,
"type": "Literal",
"type": "Literal",
"value": 1
},
{
"end": 79,
"raw": "3.82",
"start": 75,
"type": "Literal",
"type": "Literal",
"value": 3.82
}
],
"end": 80,
"start": 71,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 83,
"start": 82,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 91,
"start": 85,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "seg01"
}
],
"callee": {
"end": 70,
"name": "line",
"start": 66,
"type": "Identifier"
},
"end": 92,
"optional": false,
"start": 66,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"argument": {
"arguments": [
{
"end": 139,
"name": "seg01",
"start": 134,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 142,
"raw": "3",
"start": 141,
"type": "Literal",
"type": "Literal",
"value": 3
},
{
"end": 145,
"start": 144,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 133,
"name": "angleToMatchLengthX",
"start": 114,
"type": "Identifier"
},
"end": 146,
"optional": false,
"start": 114,
"type": "CallExpression",
"type": "CallExpression"
},
"end": 146,
"operator": "-",
"start": 113,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"end": 149,
"raw": "3",
"start": 148,
"type": "Literal",
"type": "Literal",
"value": 3
}
],
"end": 150,
"start": 112,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 153,
"start": 152,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 111,
"name": "angledLineToX",
"start": 98,
"type": "Identifier"
},
"end": 154,
"optional": false,
"start": 98,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 167,
"start": 166,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 165,
"name": "close",
"start": 160,
"type": "Identifier"
},
"end": 168,
"optional": false,
"start": 160,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 184,
"raw": "10",
"start": 182,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 187,
"start": 186,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 181,
"name": "extrude",
"start": 174,
"type": "Identifier"
},
"end": 188,
"optional": false,
"start": 174,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 188,
"start": 10,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
}
],
"end": 188,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 189,
"start": 0
}
}

View File

@ -0,0 +1,6 @@
part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([1, 3.82], %, $seg01)
|> angledLineToX([-angleToMatchLengthX(seg01, 3, %), 3], %)
|> close(%)
|> extrude(10, %)

View File

@ -0,0 +1,339 @@
---
source: kcl/src/simulation_tests.rs
description: Program memory after executing big_number_angle_to_match_length_x.kcl
snapshot_kind: text
---
{
"environments": [
{
"bindings": {
"HALF_TURN": {
"type": "Number",
"value": 180.0,
"__meta": []
},
"QUARTER_TURN": {
"type": "Number",
"value": 90.0,
"__meta": []
},
"THREE_QUARTER_TURN": {
"type": "Number",
"value": 270.0,
"__meta": []
},
"ZERO": {
"type": "Number",
"value": 0.0,
"__meta": []
},
"part001": {
"type": "Solid",
"type": "Solid",
"id": "[uuid]",
"value": [
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
92,
0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
98,
154,
0
],
"tag": null,
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
160,
168,
0
],
"tag": null,
"type": "extrudePlane"
}
],
"sketch": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
92,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"to": [
1.0,
3.82
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
98,
154,
0
]
},
"from": [
1.0,
3.82
],
"tag": null,
"to": [
3.0,
0.4152
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
160,
168,
0
]
},
"from": [
3.0,
0.4152
],
"tag": null,
"to": [
0.0,
0.0
],
"type": "ToPoint"
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"__meta": []
},
"start": {
"from": [
0.0,
0.0
],
"to": [
0.0,
0.0
],
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
35,
60,
0
]
}
},
"tags": {
"seg01": {
"type": "TagIdentifier",
"value": "seg01",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
92,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"to": [
1.0,
3.82
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
92,
0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
85,
91,
0
]
}
]
}
},
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"height": 10.0,
"startCapId": "[uuid]",
"endCapId": "[uuid]",
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"seg01": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "seg01",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
92,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"to": [
1.0,
3.82
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
92,
0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
85,
91,
0
]
}
]
}
},
"parent": null
}
],
"currentEnv": 0,
"return": null
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -0,0 +1,519 @@
---
source: kcl/src/simulation_tests.rs
description: Result of tokenizing big_number_angle_to_match_length_x.kcl
snapshot_kind: text
---
{
"Ok": [
{
"type": "word",
"start": 0,
"end": 7,
"value": "part001"
},
{
"type": "whitespace",
"start": 7,
"end": 8,
"value": " "
},
{
"type": "operator",
"start": 8,
"end": 9,
"value": "="
},
{
"type": "whitespace",
"start": 9,
"end": 10,
"value": " "
},
{
"type": "word",
"start": 10,
"end": 23,
"value": "startSketchOn"
},
{
"type": "brace",
"start": 23,
"end": 24,
"value": "("
},
{
"type": "string",
"start": 24,
"end": 28,
"value": "'XY'"
},
{
"type": "brace",
"start": 28,
"end": 29,
"value": ")"
},
{
"type": "whitespace",
"start": 29,
"end": 32,
"value": "\n "
},
{
"type": "operator",
"start": 32,
"end": 34,
"value": "|>"
},
{
"type": "whitespace",
"start": 34,
"end": 35,
"value": " "
},
{
"type": "word",
"start": 35,
"end": 49,
"value": "startProfileAt"
},
{
"type": "brace",
"start": 49,
"end": 50,
"value": "("
},
{
"type": "brace",
"start": 50,
"end": 51,
"value": "["
},
{
"type": "number",
"start": 51,
"end": 52,
"value": "0"
},
{
"type": "comma",
"start": 52,
"end": 53,
"value": ","
},
{
"type": "whitespace",
"start": 53,
"end": 54,
"value": " "
},
{
"type": "number",
"start": 54,
"end": 55,
"value": "0"
},
{
"type": "brace",
"start": 55,
"end": 56,
"value": "]"
},
{
"type": "comma",
"start": 56,
"end": 57,
"value": ","
},
{
"type": "whitespace",
"start": 57,
"end": 58,
"value": " "
},
{
"type": "operator",
"start": 58,
"end": 59,
"value": "%"
},
{
"type": "brace",
"start": 59,
"end": 60,
"value": ")"
},
{
"type": "whitespace",
"start": 60,
"end": 63,
"value": "\n "
},
{
"type": "operator",
"start": 63,
"end": 65,
"value": "|>"
},
{
"type": "whitespace",
"start": 65,
"end": 66,
"value": " "
},
{
"type": "word",
"start": 66,
"end": 70,
"value": "line"
},
{
"type": "brace",
"start": 70,
"end": 71,
"value": "("
},
{
"type": "brace",
"start": 71,
"end": 72,
"value": "["
},
{
"type": "number",
"start": 72,
"end": 73,
"value": "1"
},
{
"type": "comma",
"start": 73,
"end": 74,
"value": ","
},
{
"type": "whitespace",
"start": 74,
"end": 75,
"value": " "
},
{
"type": "number",
"start": 75,
"end": 79,
"value": "3.82"
},
{
"type": "brace",
"start": 79,
"end": 80,
"value": "]"
},
{
"type": "comma",
"start": 80,
"end": 81,
"value": ","
},
{
"type": "whitespace",
"start": 81,
"end": 82,
"value": " "
},
{
"type": "operator",
"start": 82,
"end": 83,
"value": "%"
},
{
"type": "comma",
"start": 83,
"end": 84,
"value": ","
},
{
"type": "whitespace",
"start": 84,
"end": 85,
"value": " "
},
{
"type": "dollar",
"start": 85,
"end": 86,
"value": "$"
},
{
"type": "word",
"start": 86,
"end": 91,
"value": "seg01"
},
{
"type": "brace",
"start": 91,
"end": 92,
"value": ")"
},
{
"type": "whitespace",
"start": 92,
"end": 95,
"value": "\n "
},
{
"type": "operator",
"start": 95,
"end": 97,
"value": "|>"
},
{
"type": "whitespace",
"start": 97,
"end": 98,
"value": " "
},
{
"type": "word",
"start": 98,
"end": 111,
"value": "angledLineToX"
},
{
"type": "brace",
"start": 111,
"end": 112,
"value": "("
},
{
"type": "brace",
"start": 112,
"end": 113,
"value": "["
},
{
"type": "operator",
"start": 113,
"end": 114,
"value": "-"
},
{
"type": "word",
"start": 114,
"end": 133,
"value": "angleToMatchLengthX"
},
{
"type": "brace",
"start": 133,
"end": 134,
"value": "("
},
{
"type": "word",
"start": 134,
"end": 139,
"value": "seg01"
},
{
"type": "comma",
"start": 139,
"end": 140,
"value": ","
},
{
"type": "whitespace",
"start": 140,
"end": 141,
"value": " "
},
{
"type": "number",
"start": 141,
"end": 142,
"value": "3"
},
{
"type": "comma",
"start": 142,
"end": 143,
"value": ","
},
{
"type": "whitespace",
"start": 143,
"end": 144,
"value": " "
},
{
"type": "operator",
"start": 144,
"end": 145,
"value": "%"
},
{
"type": "brace",
"start": 145,
"end": 146,
"value": ")"
},
{
"type": "comma",
"start": 146,
"end": 147,
"value": ","
},
{
"type": "whitespace",
"start": 147,
"end": 148,
"value": " "
},
{
"type": "number",
"start": 148,
"end": 149,
"value": "3"
},
{
"type": "brace",
"start": 149,
"end": 150,
"value": "]"
},
{
"type": "comma",
"start": 150,
"end": 151,
"value": ","
},
{
"type": "whitespace",
"start": 151,
"end": 152,
"value": " "
},
{
"type": "operator",
"start": 152,
"end": 153,
"value": "%"
},
{
"type": "brace",
"start": 153,
"end": 154,
"value": ")"
},
{
"type": "whitespace",
"start": 154,
"end": 157,
"value": "\n "
},
{
"type": "operator",
"start": 157,
"end": 159,
"value": "|>"
},
{
"type": "whitespace",
"start": 159,
"end": 160,
"value": " "
},
{
"type": "word",
"start": 160,
"end": 165,
"value": "close"
},
{
"type": "brace",
"start": 165,
"end": 166,
"value": "("
},
{
"type": "operator",
"start": 166,
"end": 167,
"value": "%"
},
{
"type": "brace",
"start": 167,
"end": 168,
"value": ")"
},
{
"type": "whitespace",
"start": 168,
"end": 171,
"value": "\n "
},
{
"type": "operator",
"start": 171,
"end": 173,
"value": "|>"
},
{
"type": "whitespace",
"start": 173,
"end": 174,
"value": " "
},
{
"type": "word",
"start": 174,
"end": 181,
"value": "extrude"
},
{
"type": "brace",
"start": 181,
"end": 182,
"value": "("
},
{
"type": "number",
"start": 182,
"end": 184,
"value": "10"
},
{
"type": "comma",
"start": 184,
"end": 185,
"value": ","
},
{
"type": "whitespace",
"start": 185,
"end": 186,
"value": " "
},
{
"type": "operator",
"start": 186,
"end": 187,
"value": "%"
},
{
"type": "brace",
"start": 187,
"end": 188,
"value": ")"
},
{
"type": "whitespace",
"start": 188,
"end": 189,
"value": "\n"
}
]
}

View File

@ -0,0 +1,291 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing big_number_angle_to_match_length_y.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 188,
"id": {
"end": 7,
"name": "part001",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 28,
"raw": "'XY'",
"start": 24,
"type": "Literal",
"type": "Literal",
"value": "XY"
}
],
"callee": {
"end": 23,
"name": "startSketchOn",
"start": 10,
"type": "Identifier"
},
"end": 29,
"optional": false,
"start": 10,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 52,
"raw": "0",
"start": 51,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 55,
"raw": "0",
"start": 54,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 56,
"start": 50,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 59,
"start": 58,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 49,
"name": "startProfileAt",
"start": 35,
"type": "Identifier"
},
"end": 60,
"optional": false,
"start": 35,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 73,
"raw": "1",
"start": 72,
"type": "Literal",
"type": "Literal",
"value": 1
},
{
"end": 79,
"raw": "3.82",
"start": 75,
"type": "Literal",
"type": "Literal",
"value": 3.82
}
],
"end": 80,
"start": 71,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 83,
"start": 82,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
},
{
"end": 91,
"start": 85,
"type": "TagDeclarator",
"type": "TagDeclarator",
"value": "seg01"
}
],
"callee": {
"end": 70,
"name": "line",
"start": 66,
"type": "Identifier"
},
"end": 92,
"optional": false,
"start": 66,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"argument": {
"arguments": [
{
"end": 139,
"name": "seg01",
"start": 134,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 142,
"raw": "3",
"start": 141,
"type": "Literal",
"type": "Literal",
"value": 3
},
{
"end": 145,
"start": 144,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 133,
"name": "angleToMatchLengthY",
"start": 114,
"type": "Identifier"
},
"end": 146,
"optional": false,
"start": 114,
"type": "CallExpression",
"type": "CallExpression"
},
"end": 146,
"operator": "-",
"start": 113,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"end": 149,
"raw": "3",
"start": 148,
"type": "Literal",
"type": "Literal",
"value": 3
}
],
"end": 150,
"start": 112,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 153,
"start": 152,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 111,
"name": "angledLineToX",
"start": 98,
"type": "Identifier"
},
"end": 154,
"optional": false,
"start": 98,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 167,
"start": 166,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 165,
"name": "close",
"start": 160,
"type": "Identifier"
},
"end": 168,
"optional": false,
"start": 160,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 184,
"raw": "10",
"start": 182,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 187,
"start": 186,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 181,
"name": "extrude",
"start": 174,
"type": "Identifier"
},
"end": 188,
"optional": false,
"start": 174,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 188,
"start": 10,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
}
],
"end": 188,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 189,
"start": 0
}
}

View File

@ -0,0 +1,6 @@
part001 = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([1, 3.82], %, $seg01)
|> angledLineToX([-angleToMatchLengthY(seg01, 3, %), 3], %)
|> close(%)
|> extrude(10, %)

View File

@ -0,0 +1,339 @@
---
source: kcl/src/simulation_tests.rs
description: Program memory after executing big_number_angle_to_match_length_y.kcl
snapshot_kind: text
---
{
"environments": [
{
"bindings": {
"HALF_TURN": {
"type": "Number",
"value": 180.0,
"__meta": []
},
"QUARTER_TURN": {
"type": "Number",
"value": 90.0,
"__meta": []
},
"THREE_QUARTER_TURN": {
"type": "Number",
"value": 270.0,
"__meta": []
},
"ZERO": {
"type": "Number",
"value": 0.0,
"__meta": []
},
"part001": {
"type": "Solid",
"type": "Solid",
"id": "[uuid]",
"value": [
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
92,
0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
98,
154,
0
],
"tag": null,
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
160,
168,
0
],
"tag": null,
"type": "extrudePlane"
}
],
"sketch": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
92,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"to": [
1.0,
3.82
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
98,
154,
0
]
},
"from": [
1.0,
3.82
],
"tag": null,
"to": [
3.0,
3.3954
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
160,
168,
0
]
},
"from": [
3.0,
3.3954
],
"tag": null,
"to": [
0.0,
0.0
],
"type": "ToPoint"
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"__meta": []
},
"start": {
"from": [
0.0,
0.0
],
"to": [
0.0,
0.0
],
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
35,
60,
0
]
}
},
"tags": {
"seg01": {
"type": "TagIdentifier",
"value": "seg01",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
92,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"to": [
1.0,
3.82
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
92,
0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
85,
91,
0
]
}
]
}
},
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"height": 10.0,
"startCapId": "[uuid]",
"endCapId": "[uuid]",
"__meta": [
{
"sourceRange": [
35,
60,
0
]
}
]
},
"seg01": {
"type": "TagIdentifier",
"type": "TagIdentifier",
"value": "seg01",
"info": {
"type": "TagEngineInfo",
"id": "[uuid]",
"sketch": "[uuid]",
"path": {
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
66,
92,
0
]
},
"from": [
0.0,
0.0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"to": [
1.0,
3.82
],
"type": "ToPoint"
},
"surface": {
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
66,
92,
0
],
"tag": {
"end": 91,
"start": 85,
"type": "TagDeclarator",
"value": "seg01"
},
"type": "extrudePlane"
}
},
"__meta": [
{
"sourceRange": [
85,
91,
0
]
}
]
}
},
"parent": null
}
],
"currentEnv": 0,
"return": null
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -0,0 +1,519 @@
---
source: kcl/src/simulation_tests.rs
description: Result of tokenizing big_number_angle_to_match_length_y.kcl
snapshot_kind: text
---
{
"Ok": [
{
"type": "word",
"start": 0,
"end": 7,
"value": "part001"
},
{
"type": "whitespace",
"start": 7,
"end": 8,
"value": " "
},
{
"type": "operator",
"start": 8,
"end": 9,
"value": "="
},
{
"type": "whitespace",
"start": 9,
"end": 10,
"value": " "
},
{
"type": "word",
"start": 10,
"end": 23,
"value": "startSketchOn"
},
{
"type": "brace",
"start": 23,
"end": 24,
"value": "("
},
{
"type": "string",
"start": 24,
"end": 28,
"value": "'XY'"
},
{
"type": "brace",
"start": 28,
"end": 29,
"value": ")"
},
{
"type": "whitespace",
"start": 29,
"end": 32,
"value": "\n "
},
{
"type": "operator",
"start": 32,
"end": 34,
"value": "|>"
},
{
"type": "whitespace",
"start": 34,
"end": 35,
"value": " "
},
{
"type": "word",
"start": 35,
"end": 49,
"value": "startProfileAt"
},
{
"type": "brace",
"start": 49,
"end": 50,
"value": "("
},
{
"type": "brace",
"start": 50,
"end": 51,
"value": "["
},
{
"type": "number",
"start": 51,
"end": 52,
"value": "0"
},
{
"type": "comma",
"start": 52,
"end": 53,
"value": ","
},
{
"type": "whitespace",
"start": 53,
"end": 54,
"value": " "
},
{
"type": "number",
"start": 54,
"end": 55,
"value": "0"
},
{
"type": "brace",
"start": 55,
"end": 56,
"value": "]"
},
{
"type": "comma",
"start": 56,
"end": 57,
"value": ","
},
{
"type": "whitespace",
"start": 57,
"end": 58,
"value": " "
},
{
"type": "operator",
"start": 58,
"end": 59,
"value": "%"
},
{
"type": "brace",
"start": 59,
"end": 60,
"value": ")"
},
{
"type": "whitespace",
"start": 60,
"end": 63,
"value": "\n "
},
{
"type": "operator",
"start": 63,
"end": 65,
"value": "|>"
},
{
"type": "whitespace",
"start": 65,
"end": 66,
"value": " "
},
{
"type": "word",
"start": 66,
"end": 70,
"value": "line"
},
{
"type": "brace",
"start": 70,
"end": 71,
"value": "("
},
{
"type": "brace",
"start": 71,
"end": 72,
"value": "["
},
{
"type": "number",
"start": 72,
"end": 73,
"value": "1"
},
{
"type": "comma",
"start": 73,
"end": 74,
"value": ","
},
{
"type": "whitespace",
"start": 74,
"end": 75,
"value": " "
},
{
"type": "number",
"start": 75,
"end": 79,
"value": "3.82"
},
{
"type": "brace",
"start": 79,
"end": 80,
"value": "]"
},
{
"type": "comma",
"start": 80,
"end": 81,
"value": ","
},
{
"type": "whitespace",
"start": 81,
"end": 82,
"value": " "
},
{
"type": "operator",
"start": 82,
"end": 83,
"value": "%"
},
{
"type": "comma",
"start": 83,
"end": 84,
"value": ","
},
{
"type": "whitespace",
"start": 84,
"end": 85,
"value": " "
},
{
"type": "dollar",
"start": 85,
"end": 86,
"value": "$"
},
{
"type": "word",
"start": 86,
"end": 91,
"value": "seg01"
},
{
"type": "brace",
"start": 91,
"end": 92,
"value": ")"
},
{
"type": "whitespace",
"start": 92,
"end": 95,
"value": "\n "
},
{
"type": "operator",
"start": 95,
"end": 97,
"value": "|>"
},
{
"type": "whitespace",
"start": 97,
"end": 98,
"value": " "
},
{
"type": "word",
"start": 98,
"end": 111,
"value": "angledLineToX"
},
{
"type": "brace",
"start": 111,
"end": 112,
"value": "("
},
{
"type": "brace",
"start": 112,
"end": 113,
"value": "["
},
{
"type": "operator",
"start": 113,
"end": 114,
"value": "-"
},
{
"type": "word",
"start": 114,
"end": 133,
"value": "angleToMatchLengthY"
},
{
"type": "brace",
"start": 133,
"end": 134,
"value": "("
},
{
"type": "word",
"start": 134,
"end": 139,
"value": "seg01"
},
{
"type": "comma",
"start": 139,
"end": 140,
"value": ","
},
{
"type": "whitespace",
"start": 140,
"end": 141,
"value": " "
},
{
"type": "number",
"start": 141,
"end": 142,
"value": "3"
},
{
"type": "comma",
"start": 142,
"end": 143,
"value": ","
},
{
"type": "whitespace",
"start": 143,
"end": 144,
"value": " "
},
{
"type": "operator",
"start": 144,
"end": 145,
"value": "%"
},
{
"type": "brace",
"start": 145,
"end": 146,
"value": ")"
},
{
"type": "comma",
"start": 146,
"end": 147,
"value": ","
},
{
"type": "whitespace",
"start": 147,
"end": 148,
"value": " "
},
{
"type": "number",
"start": 148,
"end": 149,
"value": "3"
},
{
"type": "brace",
"start": 149,
"end": 150,
"value": "]"
},
{
"type": "comma",
"start": 150,
"end": 151,
"value": ","
},
{
"type": "whitespace",
"start": 151,
"end": 152,
"value": " "
},
{
"type": "operator",
"start": 152,
"end": 153,
"value": "%"
},
{
"type": "brace",
"start": 153,
"end": 154,
"value": ")"
},
{
"type": "whitespace",
"start": 154,
"end": 157,
"value": "\n "
},
{
"type": "operator",
"start": 157,
"end": 159,
"value": "|>"
},
{
"type": "whitespace",
"start": 159,
"end": 160,
"value": " "
},
{
"type": "word",
"start": 160,
"end": 165,
"value": "close"
},
{
"type": "brace",
"start": 165,
"end": 166,
"value": "("
},
{
"type": "operator",
"start": 166,
"end": 167,
"value": "%"
},
{
"type": "brace",
"start": 167,
"end": 168,
"value": ")"
},
{
"type": "whitespace",
"start": 168,
"end": 171,
"value": "\n "
},
{
"type": "operator",
"start": 171,
"end": 173,
"value": "|>"
},
{
"type": "whitespace",
"start": 173,
"end": 174,
"value": " "
},
{
"type": "word",
"start": 174,
"end": 181,
"value": "extrude"
},
{
"type": "brace",
"start": 181,
"end": 182,
"value": "("
},
{
"type": "number",
"start": 182,
"end": 184,
"value": "10"
},
{
"type": "comma",
"start": 184,
"end": 185,
"value": ","
},
{
"type": "whitespace",
"start": 185,
"end": 186,
"value": " "
},
{
"type": "operator",
"start": 186,
"end": 187,
"value": "%"
},
{
"type": "brace",
"start": 187,
"end": 188,
"value": ")"
},
{
"type": "whitespace",
"start": 188,
"end": 189,
"value": "\n"
}
]
}

View File

@ -0,0 +1,671 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing circular_pattern3d_a_pattern.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 163,
"id": {
"end": 13,
"name": "exampleSketch",
"start": 0,
"type": "Identifier"
},
"init": {
"body": [
{
"arguments": [
{
"end": 34,
"raw": "'XZ'",
"start": 30,
"type": "Literal",
"type": "Literal",
"value": "XZ"
}
],
"callee": {
"end": 29,
"name": "startSketchOn",
"start": 16,
"type": "Identifier"
},
"end": 35,
"optional": false,
"start": 16,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 58,
"raw": "0",
"start": 57,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 61,
"raw": "0",
"start": 60,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 62,
"start": 56,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 65,
"start": 64,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 55,
"name": "startProfileAt",
"start": 41,
"type": "Identifier"
},
"end": 66,
"optional": false,
"start": 41,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 79,
"raw": "0",
"start": 78,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 82,
"raw": "2",
"start": 81,
"type": "Literal",
"type": "Literal",
"value": 2
}
],
"end": 83,
"start": 77,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 86,
"start": 85,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 76,
"name": "line",
"start": 72,
"type": "Identifier"
},
"end": 87,
"optional": false,
"start": 72,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 100,
"raw": "3",
"start": 99,
"type": "Literal",
"type": "Literal",
"value": 3
},
{
"end": 103,
"raw": "1",
"start": 102,
"type": "Literal",
"type": "Literal",
"value": 1
}
],
"end": 104,
"start": 98,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 107,
"start": 106,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 97,
"name": "line",
"start": 93,
"type": "Identifier"
},
"end": 108,
"optional": false,
"start": 93,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"elements": [
{
"end": 121,
"raw": "0",
"start": 120,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"argument": {
"end": 125,
"raw": "4",
"start": 124,
"type": "Literal",
"type": "Literal",
"value": 4
},
"end": 125,
"operator": "-",
"start": 123,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 126,
"start": 119,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
{
"end": 129,
"start": 128,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 118,
"name": "line",
"start": 114,
"type": "Identifier"
},
"end": 130,
"optional": false,
"start": 114,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 143,
"start": 142,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 141,
"name": "close",
"start": 136,
"type": "Identifier"
},
"end": 144,
"optional": false,
"start": 136,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 159,
"raw": "1",
"start": 158,
"type": "Literal",
"type": "Literal",
"value": 1
},
{
"end": 162,
"start": 161,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 157,
"name": "extrude",
"start": 150,
"type": "Identifier"
},
"end": 163,
"optional": false,
"start": 150,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 163,
"start": 16,
"type": "PipeExpression",
"type": "PipeExpression"
},
"start": 0,
"type": "VariableDeclarator"
}
],
"end": 163,
"kind": "const",
"start": 0,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 258,
"id": {
"end": 171,
"name": "pattn1",
"start": 165,
"type": "Identifier"
},
"init": {
"arguments": [
{
"end": 242,
"properties": [
{
"end": 209,
"key": {
"end": 198,
"name": "axis",
"start": 194,
"type": "Identifier"
},
"start": 194,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 202,
"raw": "1",
"start": 201,
"type": "Literal",
"type": "Literal",
"value": 1
},
{
"end": 205,
"raw": "0",
"start": 204,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 208,
"raw": "0",
"start": 207,
"type": "Literal",
"type": "Literal",
"value": 0
}
],
"end": 209,
"start": 200,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 225,
"key": {
"end": 222,
"name": "instances",
"start": 213,
"type": "Identifier"
},
"start": 213,
"type": "ObjectProperty",
"value": {
"end": 225,
"raw": "7",
"start": 224,
"type": "Literal",
"type": "Literal",
"value": 7
}
},
{
"end": 240,
"key": {
"end": 237,
"name": "distance",
"start": 229,
"type": "Identifier"
},
"start": 229,
"type": "ObjectProperty",
"value": {
"end": 240,
"raw": "6",
"start": 239,
"type": "Literal",
"type": "Literal",
"value": 6
}
}
],
"start": 190,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 257,
"name": "exampleSketch",
"start": 244,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"end": 189,
"name": "patternLinear3d",
"start": 174,
"type": "Identifier"
},
"end": 258,
"optional": false,
"start": 174,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 165,
"type": "VariableDeclarator"
}
],
"end": 258,
"kind": "const",
"start": 165,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 407,
"id": {
"end": 266,
"name": "pattn2",
"start": 260,
"type": "Identifier"
},
"init": {
"arguments": [
{
"end": 398,
"properties": [
{
"end": 306,
"key": {
"end": 295,
"name": "axis",
"start": 291,
"type": "Identifier"
},
"start": 291,
"type": "ObjectProperty",
"value": {
"elements": [
{
"end": 299,
"raw": "0",
"start": 298,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 302,
"raw": "0",
"start": 301,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 305,
"raw": "1",
"start": 304,
"type": "Literal",
"type": "Literal",
"value": 1
}
],
"end": 306,
"start": 297,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 333,
"key": {
"end": 316,
"name": "center",
"start": 310,
"type": "Identifier"
},
"start": 310,
"type": "ObjectProperty",
"value": {
"elements": [
{
"argument": {
"end": 322,
"raw": "20",
"start": 320,
"type": "Literal",
"type": "Literal",
"value": 20
},
"end": 322,
"operator": "-",
"start": 319,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"argument": {
"end": 327,
"raw": "20",
"start": 325,
"type": "Literal",
"type": "Literal",
"value": 20
},
"end": 327,
"operator": "-",
"start": 324,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
{
"argument": {
"end": 332,
"raw": "20",
"start": 330,
"type": "Literal",
"type": "Literal",
"value": 20
},
"end": 332,
"operator": "-",
"start": 329,
"type": "UnaryExpression",
"type": "UnaryExpression"
}
],
"end": 333,
"start": 318,
"type": "ArrayExpression",
"type": "ArrayExpression"
}
},
{
"end": 350,
"key": {
"end": 346,
"name": "instances",
"start": 337,
"type": "Identifier"
},
"start": 337,
"type": "ObjectProperty",
"value": {
"end": 350,
"raw": "41",
"start": 348,
"type": "Literal",
"type": "Literal",
"value": 41
}
},
{
"end": 369,
"key": {
"end": 364,
"name": "arcDegrees",
"start": 354,
"type": "Identifier"
},
"start": 354,
"type": "ObjectProperty",
"value": {
"end": 369,
"raw": "360",
"start": 366,
"type": "Literal",
"type": "Literal",
"value": 360
}
},
{
"end": 396,
"key": {
"end": 389,
"name": "rotateDuplicates",
"start": 373,
"type": "Identifier"
},
"start": 373,
"type": "ObjectProperty",
"value": {
"end": 396,
"raw": "false",
"start": 391,
"type": "Literal",
"type": "Literal",
"value": false
}
}
],
"start": 287,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
{
"end": 406,
"name": "pattn1",
"start": 400,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"end": 286,
"name": "patternCircular3d",
"start": 269,
"type": "Identifier"
},
"end": 407,
"optional": false,
"start": 269,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 260,
"type": "VariableDeclarator"
}
],
"end": 407,
"kind": "const",
"start": 260,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
}
],
"end": 408,
"nonCodeMeta": {
"nonCodeNodes": {
"0": [
{
"end": 165,
"start": 163,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"1": [
{
"end": 260,
"start": 258,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": []
},
"start": 0
}
}

View File

@ -0,0 +1,21 @@
exampleSketch = startSketchOn('XZ')
|> startProfileAt([0, 0], %)
|> line([0, 2], %)
|> line([3, 1], %)
|> line([0, -4], %)
|> close(%)
|> extrude(1, %)
pattn1 = patternLinear3d({
axis: [1, 0, 0],
instances: 7,
distance: 6
}, exampleSketch)
pattn2 = patternCircular3d({
axis: [0, 0, 1],
center: [-20, -20, -20],
instances: 41,
arcDegrees: 360,
rotateDuplicates: false
}, pattn1)

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,80 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing comparisons_multiple.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"end": 46,
"expression": {
"arguments": [
{
"end": 18,
"left": {
"end": 13,
"left": {
"end": 8,
"raw": "3",
"start": 7,
"type": "Literal",
"type": "Literal",
"value": 3
},
"operator": "==",
"right": {
"end": 13,
"raw": "3",
"start": 12,
"type": "Literal",
"type": "Literal",
"value": 3
},
"start": 7,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"operator": "==",
"right": {
"end": 18,
"raw": "3",
"start": 17,
"type": "Literal",
"type": "Literal",
"value": 3
},
"start": 7,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"end": 45,
"raw": "\"this should not compile\"",
"start": 20,
"type": "Literal",
"type": "Literal",
"value": "this should not compile"
}
],
"callee": {
"end": 6,
"name": "assert",
"start": 0,
"type": "Identifier"
},
"end": 46,
"optional": false,
"start": 0,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 0,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 47,
"start": 0
}
}

View File

@ -0,0 +1,6 @@
---
source: kcl/src/simulation_tests.rs
description: Error from executing comparisons_multiple.kcl
snapshot_kind: text
---
semantic: KclErrorDetails { source_ranges: [SourceRange([7, 13, 0])], message: "Expected a number, but found a boolean (true/false value)" }

View File

@ -0,0 +1 @@
assert(3 == 3 == 3, "this should not compile")

View File

@ -0,0 +1,105 @@
---
source: kcl/src/simulation_tests.rs
description: Result of tokenizing comparisons_multiple.kcl
snapshot_kind: text
---
{
"Ok": [
{
"type": "word",
"start": 0,
"end": 6,
"value": "assert"
},
{
"type": "brace",
"start": 6,
"end": 7,
"value": "("
},
{
"type": "number",
"start": 7,
"end": 8,
"value": "3"
},
{
"type": "whitespace",
"start": 8,
"end": 9,
"value": " "
},
{
"type": "operator",
"start": 9,
"end": 11,
"value": "=="
},
{
"type": "whitespace",
"start": 11,
"end": 12,
"value": " "
},
{
"type": "number",
"start": 12,
"end": 13,
"value": "3"
},
{
"type": "whitespace",
"start": 13,
"end": 14,
"value": " "
},
{
"type": "operator",
"start": 14,
"end": 16,
"value": "=="
},
{
"type": "whitespace",
"start": 16,
"end": 17,
"value": " "
},
{
"type": "number",
"start": 17,
"end": 18,
"value": "3"
},
{
"type": "comma",
"start": 18,
"end": 19,
"value": ","
},
{
"type": "whitespace",
"start": 19,
"end": 20,
"value": " "
},
{
"type": "string",
"start": 20,
"end": 45,
"value": "\"this should not compile\""
},
{
"type": "brace",
"start": 45,
"end": 46,
"value": ")"
},
{
"type": "whitespace",
"start": 46,
"end": 47,
"value": "\n"
}
]
}

View File

@ -0,0 +1,435 @@
---
source: kcl/src/simulation_tests.rs
description: Result of parsing computed_var.kcl
snapshot_kind: text
---
{
"Ok": {
"body": [
{
"declarations": [
{
"end": 56,
"id": {
"end": 40,
"name": "arr",
"start": 37,
"type": "Identifier"
},
"init": {
"elements": [
{
"end": 45,
"raw": "0",
"start": 44,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 48,
"raw": "0",
"start": 47,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 51,
"raw": "0",
"start": 50,
"type": "Literal",
"type": "Literal",
"value": 0
},
{
"end": 55,
"raw": "10",
"start": 53,
"type": "Literal",
"type": "Literal",
"value": 10
}
],
"end": 56,
"start": 43,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 37,
"type": "VariableDeclarator"
}
],
"end": 56,
"kind": "const",
"start": 37,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 62,
"id": {
"end": 58,
"name": "i",
"start": 57,
"type": "Identifier"
},
"init": {
"end": 62,
"raw": "3",
"start": 61,
"type": "Literal",
"type": "Literal",
"value": 3
},
"start": 57,
"type": "VariableDeclarator"
}
],
"end": 62,
"kind": "const",
"start": 57,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 75,
"id": {
"end": 66,
"name": "ten",
"start": 63,
"type": "Identifier"
},
"init": {
"computed": true,
"end": 75,
"object": {
"end": 72,
"name": "arr",
"start": 69,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 74,
"name": "i",
"start": 73,
"type": "Identifier",
"type": "Identifier"
},
"start": 69,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 63,
"type": "VariableDeclarator"
}
],
"end": 75,
"kind": "const",
"start": 63,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 115,
"expression": {
"arguments": [
{
"end": 92,
"name": "ten",
"start": 89,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 96,
"raw": "10",
"start": 94,
"type": "Literal",
"type": "Literal",
"value": 10
},
{
"end": 106,
"raw": "0.000001",
"start": 98,
"type": "Literal",
"type": "Literal",
"value": 0.000001
},
{
"end": 114,
"raw": "\"oops\"",
"start": 108,
"type": "Literal",
"type": "Literal",
"value": "oops"
}
],
"callee": {
"end": 88,
"name": "assertEqual",
"start": 77,
"type": "Identifier"
},
"end": 115,
"optional": false,
"start": 77,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 77,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
},
{
"declarations": [
{
"end": 126,
"id": {
"end": 118,
"name": "p",
"start": 117,
"type": "Identifier"
},
"init": {
"end": 126,
"raw": "\"foo\"",
"start": 121,
"type": "Literal",
"type": "Literal",
"value": "foo"
},
"start": 117,
"type": "VariableDeclarator"
}
],
"end": 126,
"kind": "const",
"start": 117,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 151,
"id": {
"end": 130,
"name": "obj",
"start": 127,
"type": "Identifier"
},
"init": {
"end": 151,
"properties": [
{
"end": 141,
"key": {
"end": 138,
"name": "foo",
"start": 135,
"type": "Identifier"
},
"start": 135,
"type": "ObjectProperty",
"value": {
"end": 141,
"raw": "1",
"start": 140,
"type": "Literal",
"type": "Literal",
"value": 1
}
},
{
"end": 149,
"key": {
"end": 146,
"name": "bar",
"start": 143,
"type": "Identifier"
},
"start": 143,
"type": "ObjectProperty",
"value": {
"end": 149,
"raw": "0",
"start": 148,
"type": "Literal",
"type": "Literal",
"value": 0
}
}
],
"start": 133,
"type": "ObjectExpression",
"type": "ObjectExpression"
},
"start": 127,
"type": "VariableDeclarator"
}
],
"end": 151,
"kind": "const",
"start": 127,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 164,
"id": {
"end": 155,
"name": "one",
"start": 152,
"type": "Identifier"
},
"init": {
"computed": true,
"end": 164,
"object": {
"end": 161,
"name": "obj",
"start": 158,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 163,
"name": "p",
"start": 162,
"type": "Identifier",
"type": "Identifier"
},
"start": 158,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 152,
"type": "VariableDeclarator"
}
],
"end": 164,
"kind": "const",
"start": 152,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"end": 204,
"expression": {
"arguments": [
{
"end": 181,
"name": "one",
"start": 178,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 184,
"raw": "1",
"start": 183,
"type": "Literal",
"type": "Literal",
"value": 1
},
{
"end": 195,
"raw": "0.0000001",
"start": 186,
"type": "Literal",
"type": "Literal",
"value": 0.0000001
},
{
"end": 203,
"raw": "\"oops\"",
"start": 197,
"type": "Literal",
"type": "Literal",
"value": "oops"
}
],
"callee": {
"end": 177,
"name": "assertEqual",
"start": 166,
"type": "Identifier"
},
"end": 204,
"optional": false,
"start": 166,
"type": "CallExpression",
"type": "CallExpression"
},
"start": 166,
"type": "ExpressionStatement",
"type": "ExpressionStatement"
}
],
"end": 205,
"nonCodeMeta": {
"nonCodeNodes": {
"2": [
{
"end": 77,
"start": 75,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"3": [
{
"end": 117,
"start": 115,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
],
"6": [
{
"end": 166,
"start": 164,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": [
{
"end": 34,
"start": 0,
"type": "NonCodeNode",
"value": {
"type": "blockComment",
"value": "This tests computed properties.",
"style": "line"
}
},
{
"end": 37,
"start": 34,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"start": 0
}
}

View File

@ -0,0 +1,14 @@
// This tests computed properties.
arr = [0, 0, 0, 10]
i = 3
ten = arr[i]
assertEqual(ten, 10, 0.000001, "oops")
p = "foo"
obj = { foo: 1, bar: 0 }
one = obj[p]
assertEqual(one, 1, 0.0000001, "oops")

Some files were not shown because too many files have changed in this diff Show More