Compare commits

..

6 Commits

Author SHA1 Message Date
dec538590a Tests for recasting literals 2023-11-01 11:22:34 -05:00
9523eef52c Fix some more 2023-11-01 10:30:58 -05:00
20ae39dec3 Trying to make tests pass again 2023-11-01 10:30:57 -05:00
8ebba16796 Remove unsigned integer type for now 2023-11-01 10:30:57 -05:00
038de47e5d Frontend should never cast LiteralValue directly to string
Instead, it should cast the LiteralValue's `.data` field.
2023-11-01 10:30:57 -05:00
61563bee97 KCL literals have their own type system instead of reusing JSON.
We now distinguish between KCL literals of:
- String
- f64
- i64
- u64

instead of reusing JSON values as the only KCL literal.
2023-11-01 10:30:57 -05:00
122 changed files with 597 additions and 27319 deletions

View File

@ -1,3 +0,0 @@
[codespell]
ignore-words-list: crate,everytime
skip: **/target,node_modules,build

View File

@ -12,13 +12,9 @@ on:
# Daily at 04:00 AM UTC
# Will checkout the last commit from the default branch (main as of 2023-10-04)
env:
BUILD_RELEASE: ${{ github.event_name == 'release' || github.event_name == 'schedule' || github.event_name == 'pull_request' && contains(github.event.pull_request.title, 'Cut release v') }}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
check-format:
runs-on: 'ubuntu-latest'
@ -50,20 +46,6 @@ jobs:
- run: yarn tsc
check-typos:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
- name: Install codespell
run: |
python -m pip install codespell
- name: Run codespell
run: codespell --config .codespellrc # Edit this file to tweak the typo list and other configuration.
build-test-web:
runs-on: ubuntu-latest
steps:
@ -120,7 +102,7 @@ jobs:
build-test-apps:
needs: [prepare-json-files]
needs: [check-format, build-test-web, prepare-json-files, check-types]
runs-on: ${{ matrix.os }}
strategy:
matrix:
@ -137,7 +119,7 @@ jobs:
cp artifact/package.json package.json
cp artifact/src-tauri/tauri.conf.json src-tauri/tauri.conf.json
- name: Install ubuntu system dependencies
- name: install ubuntu system dependencies
if: matrix.os == 'ubuntu-latest'
run: >
sudo apt-get update &&
@ -157,10 +139,10 @@ jobs:
- run: yarn install
- name: Setup Rust
- name: Rust setup
uses: dtolnay/rust-toolchain@stable
- name: Setup Rust cache
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
@ -169,27 +151,24 @@ jobs:
with:
workspaces: './src/wasm-lib'
- name: Run build:wasm manually
- name: wasm prep
shell: bash
env:
MODE: ${{ env.BUILD_RELEASE == 'true' && '--release' || '--debug' }}
run: |
mkdir src/wasm-lib/pkg; cd src/wasm-lib
echo "building with ${{ env.MODE }}"
npx wasm-pack build --target web --out-dir pkg ${{ env.MODE }}
npx wasm-pack build --target web --out-dir pkg
cd ../../
cp src/wasm-lib/pkg/wasm_lib_bg.wasm public
- name: Fix format
run: yarn fmt
- name: Install Universal target (MacOS only)
- name: install apple silicon target mac
if: matrix.os == 'macos-latest'
run: |
rustup target add aarch64-apple-darwin
- name: Prepare certificate and variables (Windows only)
if: ${{ matrix.os == 'windows-latest' && env.BUILD_RELEASE == 'true' }}
- name: Prepare Windows certificate and variables
if: matrix.os == 'windows-latest'
run: |
echo "${{secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12
cat /d/Certificate_pkcs12.p12
@ -203,8 +182,8 @@ jobs:
echo "C:\Program Files\DigiCert\DigiCert One Signing Manager Tools" >> $GITHUB_PATH
shell: bash
- name: Setup certicate with SSM KSP (Windows only)
if: ${{ matrix.os == 'windows-latest' && env.BUILD_RELEASE == 'true' }}
- name: Setup Windows certicate with SSM KSP
if: matrix.os == 'windows-latest'
run: |
curl -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:%SM_API_KEY%" -o smtools-windows-x64.msi
msiexec /i smtools-windows-x64.msi /quiet /qn
@ -214,17 +193,8 @@ jobs:
smksp_cert_sync.exe
shell: cmd
- name: Build the app (debug)
- name: Build and sign the app for the current platform
uses: tauri-apps/tauri-action@v0
if: ${{ env.BUILD_RELEASE == 'false' }}
with:
includeRelease: false
includeDebug: true
args: ${{ matrix.os == 'macos-latest' && '--target universal-apple-darwin' || '' }}
- name: Build the app (release) and sign
uses: tauri-apps/tauri-action@v0
if: ${{ env.BUILD_RELEASE == 'true' }}
env:
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
@ -234,35 +204,29 @@ jobs:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
TAURI_CONF_ARGS: "--config ${{ matrix.os == 'windows-latest' && 'src-tauri\\tauri.release.conf.json' || 'src-tauri/tauri.release.conf.json' }}"
with:
args: "${{ matrix.os == 'macos-latest' && '--target universal-apple-darwin' || '' }} ${{ env.TAURI_CONF_ARGS }}"
args: ${{ matrix.os == 'macos-latest' && '--target universal-apple-darwin' || '' }}
- uses: actions/upload-artifact@v3
env:
PREFIX: ${{ matrix.os == 'macos-latest' && 'src-tauri/target/universal-apple-darwin' || 'src-tauri/target' }}
MODE: ${{ env.BUILD_RELEASE == 'true' && 'release' || 'debug' }}
with:
path: "${{ env.PREFIX }}/${{ env.MODE }}/bundle/*/*"
path: ${{ matrix.os == 'macos-latest' && 'src-tauri/target/universal-apple-darwin/release/bundle/*/*' || 'src-tauri/target/release/bundle/*/*' }}
- name: Install tauri-driver for e2e tests (linux only)
- name: Install tauri-driver for e2e tests
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: install
args: tauri-driver
- name: Run e2e tests (linux only)
- name: Run e2e tests
if: matrix.os == 'ubuntu-latest'
run: xvfb-run yarn test:e2e
env:
MODE: ${{ env.BUILD_RELEASE == 'true' && 'release' || 'debug' }}
publish-apps-release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' || github.event_name == 'schedule' }}
needs: [check-format, check-types, check-typos, build-test-web, prepare-json-files, build-test-apps]
needs: [build-test-web, prepare-json-files, build-test-apps]
env:
VERSION_NO_V: ${{ needs.prepare-json-files.outputs.version }}
VERSION: ${{ github.event_name == 'release' && format('v{0}', needs.prepare-json-files.outputs.version) || needs.prepare-json-files.outputs.version }}

View File

@ -104,7 +104,7 @@ To spin up up tauri dev, `yarn install` and `yarn build:wasm-dev` need to have b
yarn tauri dev
```
Will spin up the web app before opening up the tauri dev desktop app. Note that it's probably a good idea to close the browser tab that gets opened since at the time of writing they can conflict.
Will spin up the web app before opening up the tauri dev desktop app. Note that it's probably a good idea to close the browser tab that gets opened since at the time of writting they can conflict.
The dev instance automatically opens up the browser devtools which can be disabled by [commenting it out](https://github.com/KittyCAD/modeling-app/blob/main/src-tauri/src/main.rs#L92.)

View File

@ -1,6 +1,6 @@
{
"name": "untitled-app",
"version": "0.11.2",
"version": "0.11.1",
"private": true,
"dependencies": {
"@codemirror/autocomplete": "^6.10.2",

View File

@ -68,7 +68,7 @@ async fn login(app: tauri::AppHandle, host: &str) -> Result<String, InvokeError>
};
// Open the system browser with the auth_uri.
// We do this in the browser and not a separate window because we want 1password and
// We do this in the browser and not a seperate window because we want 1password and
// other crap to work well.
tauri::api::shell::open(&app.shell_scope(), auth_uri.secret(), None)
.map_err(|e| InvokeError::from_anyhow(e.into()))?;

View File

@ -8,7 +8,7 @@
},
"package": {
"productName": "kittycad-modeling",
"version": "0.11.2"
"version": "0.11.1"
},
"tauri": {
"allowlist": {
@ -72,13 +72,23 @@
},
"resources": [],
"shortDescription": "",
"targets": "all"
"targets": "all",
"windows": {
"certificateThumbprint": "F4C9A52FF7BC26EE5E054946F6B11DEEA94C748D",
"digestAlgorithm": "sha256",
"timestampUrl": "http://timestamp.digicert.com"
}
},
"security": {
"csp": null
},
"updater": {
"active": false
"active": true,
"endpoints": [
"https://dl.kittycad.io/releases/modeling-app/last_update.json"
],
"dialog": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEUzNzA4MjBEQjFBRTY4NzYKUldSMmFLNnhEWUp3NCtsT21Jd05wQktOaGVkOVp6MUFma0hNTDRDSnI2RkJJTEZOWG1ncFhqcU8K"
},
"windows": [
{

View File

@ -1,22 +0,0 @@
{
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
"tauri": {
"updater": {
"active": true,
"endpoints": [
"https://dl.kittycad.io/releases/modeling-app/last_update.json"
],
"dialog": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEUzNzA4MjBEQjFBRTY4NzYKUldSMmFLNnhEWUp3NCtsT21Jd05wQktOaGVkOVp6MUFma0hNTDRDSnI2RkJJTEZOWG1ncFhqcU8K"
},
"bundle": {
"identifier": "io.kittycad.modeling-app",
"windows": {
"certificateThumbprint": "F4C9A52FF7BC26EE5E054946F6B11DEEA94C748D",
"digestAlgorithm": "sha256",
"timestampUrl": "http://timestamp.digicert.com"
}
}
}
}

View File

@ -1,4 +1,4 @@
import { useCallback, MouseEventHandler } from 'react'
import { useEffect, useCallback, MouseEventHandler } from 'react'
import { DebugPanel } from './components/DebugPanel'
import { v4 as uuidv4 } from 'uuid'
import { PaneType, useStore } from './useStore'
@ -19,6 +19,7 @@ import {
} from '@fortawesome/free-solid-svg-icons'
import { useHotkeys } from 'react-hotkeys-hook'
import { getNormalisedCoordinates } from './lib/utils'
import { isTauri } from './lib/isTauri'
import { useLoaderData } from 'react-router-dom'
import { IndexLoaderData } from './Router'
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
@ -30,10 +31,11 @@ import { TextEditor } from 'components/TextEditor'
import { Themes, getSystemTheme } from 'lib/theme'
import { useEngineConnectionSubscriptions } from 'hooks/useEngineConnectionSubscriptions'
import { engineCommandManager } from './lang/std/engineConnection'
import { kclManager } from 'lang/KclSinglton'
import { useModelingContext } from 'hooks/useModelingContext'
export function App() {
const { project, file } = useLoaderData() as IndexLoaderData
const { code: loadedCode, project, file } = useLoaderData() as IndexLoaderData
useHotKeyListener()
const {
@ -80,6 +82,26 @@ export function App() {
? 'opacity-40'
: ''
// Use file code loaded from disk
// on mount, and overwrite any locally-stored code
useEffect(() => {
if (isTauri() && loadedCode !== null) {
if (kclManager.engineCommandManager.engineConnection?.isReady()) {
// If the engine is ready, promptly execute the loaded code
kclManager.setCodeAndExecute(loadedCode)
} else {
// Otherwise, just set the code and wait for the connection to complete
kclManager.setCode(loadedCode)
}
}
return () => {
// Clear code on unmount if in desktop app
if (isTauri()) {
kclManager.setCode('')
}
}
}, [loadedCode])
useEngineConnectionSubscriptions()
const debounceSocketSend = throttle<EngineCommand>((message) => {
@ -226,7 +248,7 @@ export function App() {
<Stream className="absolute inset-0 z-0" />
{showDebugPanel && (
<DebugPanel
title="Debug (AST Explorer)"
title="Debug"
className={
'transition-opacity transition-duration-75 ' +
paneOpacity +

View File

@ -42,7 +42,7 @@ import CommandBarProvider from 'components/CommandBar'
import { TEST, VITE_KC_SENTRY_DSN } from './env'
import * as Sentry from '@sentry/react'
import ModelingMachineProvider from 'components/ModelingMachineProvider'
import { KclContextProvider, kclManager } from 'lang/KclSinglton'
import { KclContextProvider } from 'lang/KclSinglton'
import FileMachineProvider from 'components/FileMachineProvider'
import { sep } from '@tauri-apps/api/path'
@ -207,7 +207,6 @@ const router = createBrowserRouter(
projectPath + sep + PROJECT_ENTRYPOINT
)
const children = await readDir(projectPath, { recursive: true })
kclManager.setCodeAndExecute(code, false)
return {
code,

View File

@ -1,5 +1,5 @@
import { useEffect, useState, useRef } from 'react'
import { parse, BinaryPart, Value } from '../lang/wasm'
import { parse, BinaryPart, Value, executor } from '../lang/wasm'
import {
createIdentifier,
createLiteral,
@ -10,7 +10,6 @@ import { findAllPreviousVariables, PrevVariable } from '../lang/queryAst'
import { engineCommandManager } from '../lang/std/engineConnection'
import { kclManager, useKclContext } from 'lang/KclSinglton'
import { useModelingContext } from 'hooks/useModelingContext'
import { executeAst } from 'useStore'
export const AvailableVars = ({
onVarClick,
@ -131,29 +130,27 @@ export function useCalc({
if (!programMemory || !selectionRange) return
const varInfo = findAllPreviousVariables(
kclManager.ast,
kclManager.programMemory,
programMemory,
selectionRange
)
setAvailableVarInfo(varInfo)
}, [kclManager.ast, kclManager.programMemory, selectionRange])
}, [kclManager.ast, programMemory, selectionRange])
useEffect(() => {
try {
const code = `const __result__ = ${value}`
const code = `const __result__ = ${value}\nshow(__result__)`
const ast = parse(code)
const _programMem: any = { root: {}, return: null }
availableVarInfo.variables.forEach(({ key, value }) => {
_programMem.root[key] = { type: 'userVal', value, __meta: [] }
})
executeAst({
executor(
ast,
_programMem,
engineCommandManager,
defaultPlanes: kclManager.defaultPlanes,
useFakeExecutor: true,
programMemoryOverride: JSON.parse(
JSON.stringify(kclManager.programMemory)
),
}).then(({ programMemory }) => {
kclManager.defaultPlanes
).then((programMemory) => {
const resultDeclaration = ast.body.find(
(a) =>
a.type === 'VariableDeclaration' &&
@ -170,7 +167,7 @@ export function useCalc({
setCalcResult('NAN')
setValueNode(null)
}
}, [value, availableVarInfo])
}, [value])
return {
valueNode,
@ -215,10 +212,7 @@ export const CreateNewVariable = ({
}) => {
return (
<>
<label
htmlFor="create-new-variable"
className="block mt-3 font-mono text-gray-900"
>
<label htmlFor="create-new-variable" className="block mt-3 font-mono">
Create new variable
</label>
<div className="mt-1 flex gap-2 items-center">
@ -229,7 +223,6 @@ export const CreateNewVariable = ({
onChange={(e) => {
setShouldCreateVariable(e.target.checked)
}}
className="bg-white text-gray-900"
/>
)}
<input

View File

@ -1,7 +1,29 @@
import { CollapsiblePanel, CollapsiblePanelProps } from './CollapsiblePanel'
import { v4 as uuidv4 } from 'uuid'
import { EngineCommand } from '../lang/std/engineConnection'
import { useState } from 'react'
import { ActionButton } from '../components/ActionButton'
import { faCheck } from '@fortawesome/free-solid-svg-icons'
import { isReducedMotion } from 'lang/util'
import { AstExplorer } from './AstExplorer'
import { engineCommandManager } from '../lang/std/engineConnection'
type SketchModeCmd = Extract<
Extract<EngineCommand, { type: 'modeling_cmd_req' }>['cmd'],
{ type: 'default_camera_enable_sketch_mode' }
>
export const DebugPanel = ({ className, ...props }: CollapsiblePanelProps) => {
const [sketchModeCmd, setSketchModeCmd] = useState<SketchModeCmd>({
type: 'default_camera_enable_sketch_mode',
origin: { x: 0, y: 0, z: 0 },
x_axis: { x: 1, y: 0, z: 0 },
y_axis: { x: 0, y: 1, z: 0 },
distance_to_plane: 100,
ortho: true,
animated: !isReducedMotion(),
})
if (!sketchModeCmd) return null
return (
<CollapsiblePanel
{...props}
@ -12,6 +34,67 @@ export const DebugPanel = ({ className, ...props }: CollapsiblePanelProps) => {
style={{ maxHeight: 'calc(100% - 3rem - 1.25rem - 1.25rem)' }}
>
<section className="p-4 flex flex-col gap-4">
<Xyz
onChange={setSketchModeCmd}
pointKey="origin"
data={sketchModeCmd}
/>
<Xyz
onChange={setSketchModeCmd}
pointKey="x_axis"
data={sketchModeCmd}
/>
<Xyz
onChange={setSketchModeCmd}
pointKey="y_axis"
data={sketchModeCmd}
/>
<div className="flex">
<div className="pr-4">distance_to_plane</div>
<input
className="w-16 dark:bg-chalkboard-90"
type="number"
value={sketchModeCmd.distance_to_plane}
onChange={({ target }) => {
setSketchModeCmd({
...sketchModeCmd,
distance_to_plane: Number(target.value),
})
}}
/>
<div className="pr-4">ortho</div>
<input
className="w-16"
type="checkbox"
checked={sketchModeCmd.ortho}
onChange={(a) =>
setSketchModeCmd({
...sketchModeCmd,
ortho: a.target.checked,
})
}
/>
</div>
<ActionButton
Element="button"
onClick={() => {
engineCommandManager.sendSceneCommand({
type: 'modeling_cmd_req',
cmd: sketchModeCmd,
cmd_id: uuidv4(),
})
}}
className="hover:border-succeed-50"
icon={{
icon: faCheck,
bgClassName:
'bg-succeed-80 group-hover:bg-succeed-70 hover:bg-succeed-70',
iconClassName:
'text-succeed-20 group-hover:text-succeed-10 hover:text-succeed-10',
}}
>
Send sketch mode command
</ActionButton>
<div style={{ height: '400px' }} className="overflow-y-auto">
<AstExplorer />
</div>
@ -19,3 +102,41 @@ export const DebugPanel = ({ className, ...props }: CollapsiblePanelProps) => {
</CollapsiblePanel>
)
}
const Xyz = ({
pointKey,
data,
onChange,
}: {
pointKey: 'origin' | 'y_axis' | 'x_axis'
data: SketchModeCmd
onChange: (a: SketchModeCmd) => void
}) => {
if (!data) return null
return (
<div className="flex">
<div className="pr-4">{pointKey}</div>
{Object.entries(data[pointKey]).map(([axis, val]) => {
return (
<div key={axis} className="flex">
<div className="w-4">{axis}</div>
<input
className="w-16 dark:bg-chalkboard-90"
type="number"
value={val}
onChange={({ target }) => {
onChange({
...data,
[pointKey]: {
...data[pointKey],
[axis]: Number(target.value),
},
})
}}
/>
</div>
)
})}
</div>
)
}

View File

@ -163,6 +163,7 @@ const FileTreeItem = ({
function openFile() {
if (fileOrDir.children !== undefined) return // Don't open directories
kclManager.setCode('')
navigate(`${paths.FILE}/${encodeURIComponent(fileOrDir.path)}`)
closePanel()
}

View File

@ -147,7 +147,7 @@ export const ModelingMachineProvider = ({
engineCommandManager.artifactMap[sketchEnginePathId] = {
type: 'result',
range: [startProfileAtCallExp.start, startProfileAtCallExp.end],
commandType: 'start_path',
commandType: 'extend_path',
data: null,
raw: {} as any,
}

View File

@ -108,7 +108,7 @@ export const SetAngleLengthModal = ({
</label>
<div className="mt-1 flex">
<button
className="border border-gray-300 px-2 text-gray-900"
className="border border-gray-300 px-2"
onClick={() => setSign(-sign)}
>
{sign > 0 ? '+' : '-'}
@ -118,7 +118,7 @@ export const SetAngleLengthModal = ({
type="text"
name="val"
id="val"
className="shadow-sm focus:ring-blue-500 focus:border-blue-500 block w-full sm:text-sm border-gray-300 rounded-md font-mono pl-1 text-gray-900"
className="shadow-sm focus:ring-blue-500 focus:border-blue-500 block w-full sm:text-sm border-gray-300 rounded-md font-mono pl-1"
value={value}
onChange={(e) => {
setValue(e.target.value)

View File

@ -87,7 +87,7 @@ export const GetInfoModal = ({
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<Dialog.Panel className="w-full max-w-md transform overflow-hidden rounded-2xl bg-white/90 p-6 text-left align-middle shadow-xl transition-all">
<Dialog.Panel className="w-full max-w-md transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all">
<Dialog.Title
as="h3"
className="text-lg font-medium leading-6 text-gray-900"
@ -109,7 +109,7 @@ export const GetInfoModal = ({
</label>
<div className="mt-1 flex">
<button
className="border border-gray-400 px-2 mr-1 text-gray-900"
className="border border-gray-300 px-2 mr-1"
onClick={() => setSign(-sign)}
>
{sign > 0 ? '+' : '-'}
@ -119,7 +119,7 @@ export const GetInfoModal = ({
name="val"
id="val"
ref={inputRef}
className="shadow-sm focus:ring-blue-500 focus:border-blue-500 block w-full sm:text-sm text-gray-900 border-gray-300 rounded-md font-mono"
className="shadow-sm focus:ring-blue-500 focus:border-blue-500 block w-full sm:text-sm border-gray-300 rounded-md font-mono"
value={value}
onChange={(e) => {
setValue(e.target.value)
@ -139,7 +139,7 @@ export const GetInfoModal = ({
name="segName"
id="segName"
disabled={!isSegNameEditable}
className="shadow-sm focus:ring-blue-500 focus:border-blue-500 block w-full sm:text-sm text-gray-900 border-gray-300 rounded-md font-mono"
className="shadow-sm focus:ring-blue-500 focus:border-blue-500 block w-full sm:text-sm border-gray-300 rounded-md font-mono"
value={segName}
onChange={(e) => {
setSegName(e.target.value)

View File

@ -14,7 +14,7 @@ import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
import { CameraDragInteractionType_type } from '@kittycad/lib/dist/types/src/models'
import { Models } from '@kittycad/lib'
import { getNodeFromPath } from 'lang/queryAst'
import { VariableDeclarator, recast, CallExpression } from 'lang/wasm'
import { VariableDeclarator, recast, parse, CallExpression } from 'lang/wasm'
import { engineCommandManager } from '../lang/std/engineConnection'
import { useModelingContext } from 'hooks/useModelingContext'
import { kclManager, useKclContext } from 'lang/KclSinglton'
@ -342,8 +342,7 @@ export const Stream = ({ className = '' }) => {
// update artifact map ranges now that we have updated the ast.
code = recast(modded.modifiedAst)
const astWithCurrentRanges = kclManager.safeParse(code)
if (!astWithCurrentRanges) return
const astWithCurrentRanges = parse(code)
const updateNode = getNodeFromPath<CallExpression>(
astWithCurrentRanges,
modded.pathToNode

View File

@ -17,7 +17,15 @@ import { useStore } from 'useStore'
import { processCodeMirrorRanges } from 'lib/selections'
import { LanguageServerClient } from 'editor/lsp'
import kclLanguage from 'editor/lsp/language'
import { EditorView, lineHighlightField } from 'editor/highlightextension'
import { isTauri } from 'lib/isTauri'
import { useParams } from 'react-router-dom'
import { writeTextFile } from '@tauri-apps/api/fs'
import { toast } from 'react-hot-toast'
import {
EditorView,
addLineHighlight,
lineHighlightField,
} from 'editor/highlightextension'
import { roundOff } from 'lib/utils'
import { kclErrToDiagnostic } from 'lang/errors'
import { CSSRuleObject } from 'tailwindcss/types/config'
@ -42,6 +50,7 @@ export const TextEditor = ({
}: {
theme: Themes.Light | Themes.Dark
}) => {
const pathParams = useParams()
const { editorView, isLSPServerReady, setEditorView, setIsLSPServerReady } =
useStore((s) => ({
editorView: s.editorView,
@ -83,7 +92,7 @@ export const TextEditor = ({
// Here we initialize the plugin which will start the client.
// When we have multi-file support the name of the file will be a dep of
// this use memo, as well as the directory structure, which I think is
// a good setup because it will restart the client but not the server :)
// a good setup becuase it will restart the client but not the server :)
// We do not want to restart the server, its just wasteful.
const kclLSP = useMemo(() => {
let plugin = null
@ -104,6 +113,18 @@ export const TextEditor = ({
// const onChange = React.useCallback((value: string, viewUpdate: ViewUpdate) => {
const onChange = (newCode: string) => {
kclManager.setCodeAndExecute(newCode)
if (isTauri() && pathParams.id) {
// Save the file to disk
// Note that PROJECT_ENTRYPOINT is hardcoded until we support multiple files
writeTextFile(pathParams.id, newCode).catch((err) => {
// TODO: add Sentry per GH issue #254 (https://github.com/KittyCAD/modeling-app/issues/254)
console.error('error saving file', err)
toast.error('Error saving file, please check file permissions')
})
}
if (editorView) {
editorView?.dispatch({ effects: addLineHighlight.of([0, 0]) })
}
} //, []);
const onUpdate = (viewUpdate: ViewUpdate) => {
if (!editorView) {

View File

@ -26,7 +26,7 @@ export class Codec {
}
}
// FIXME: tracing efficiency
// FIXME: tracing effiency
export class IntoServer
extends Queue<Uint8Array>
implements AsyncGenerator<Uint8Array, never, void>

View File

@ -32,7 +32,6 @@ export function useEngineConnectionSubscriptions() {
const unSubClick = engineCommandManager.subscribeTo({
event: 'select_with_point',
callback: async (engineEvent) => {
if (!context.sketchEnginePathId) return
const event = await getEventForSelectWithPoint(engineEvent, {
sketchEnginePathId: context.sketchEnginePathId,
})

View File

@ -26,6 +26,10 @@ export function useSetupEngineManager(
const hasSetNonZeroDimensions = useRef<boolean>(false)
useEffect(() => {
kclManager.executeCode()
}, [])
useLayoutEffect(() => {
// Load the engine command manager once with the initial width and height,
// then we do not want to reload it.

View File

@ -18,11 +18,7 @@ import { bracket } from 'lib/exampleKcl'
import { createContext, useContext, useEffect, useState } from 'react'
import { getNodeFromPath } from './queryAst'
import { IndexLoaderData } from 'Router'
import { Params, useLoaderData } from 'react-router-dom'
import { isTauri } from 'lib/isTauri'
import { writeTextFile } from '@tauri-apps/api/fs'
import { toast } from 'react-hot-toast'
import { useParams } from 'react-router-dom'
import { useLoaderData } from 'react-router-dom'
const PERSIST_CODE_TOKEN = 'persistCode'
@ -45,20 +41,10 @@ class KclManager {
private _kclErrors: KCLError[] = []
private _isExecuting = false
private _wasmInitFailed = true
private _params: Params<string> = {}
engineCommandManager: EngineCommandManager
private _defferer = deferExecution((code: string) => {
const ast = this.safeParse(code)
if (!ast) return
try {
const fmtAndStringify = (ast: Program) =>
JSON.stringify(parse(recast(ast)))
const isAstTheSame = fmtAndStringify(ast) === fmtAndStringify(this._ast)
if (isAstTheSame) return
} catch (e) {
console.error(e)
}
const ast = parse(code)
this.executeAst(ast)
}, 600)
@ -85,21 +71,6 @@ class KclManager {
set code(code) {
this._code = code
this._codeCallBack(code)
if (isTauri()) {
setTimeout(() => {
// Wait one event loop to give a chance for params to be set
// Save the file to disk
// Note that PROJECT_ENTRYPOINT is hardcoded until we support multiple files
this._params.id &&
writeTextFile(this._params.id, code).catch((err) => {
// TODO: add Sentry per GH issue #254 (https://github.com/KittyCAD/modeling-app/issues/254)
console.error('error saving file', err)
toast.error('Error saving file, please check file permissions')
})
})
} else {
localStorage.setItem(PERSIST_CODE_TOKEN, code)
}
}
get programMemory() {
@ -146,19 +117,10 @@ class KclManager {
this._wasmInitFailedCallback(wasmInitFailed)
}
setParams(params: Params<string>) {
this._params = params
}
constructor(engineCommandManager: EngineCommandManager) {
this.engineCommandManager = engineCommandManager
if (isTauri()) {
this.code = ''
return
}
const storedCode = localStorage.getItem(PERSIST_CODE_TOKEN)
// TODO #819 remove zustand persistence logic in a few months
// TODO #819 remove zustand persistance logic in a few months
// short term migration, shouldn't make a difference for tauri app users
// anyway since that's filesystem based.
const zustandStore = JSON.parse(localStorage.getItem('store') || '{}')
@ -168,7 +130,6 @@ class KclManager {
zustandStore.state.code = ''
localStorage.setItem('store', JSON.stringify(zustandStore))
} else if (storedCode === null) {
console.log('stored brack thing')
this.code = bracket
} else {
this.code = storedCode
@ -203,21 +164,6 @@ class KclManager {
this._executeCallback = callback
}
safeParse(code: string): Program | null {
try {
const ast = parse(code)
this.kclErrors = []
return ast
} catch (e) {
console.error('error parsing code', e)
if (e instanceof KCLError) {
this.kclErrors = [e]
if (e.msg === 'file is empty') engineCommandManager.endSession()
}
return null
}
}
async ensureWasmInit() {
try {
await initPromise
@ -243,15 +189,15 @@ class KclManager {
this._programMemory = programMemory
this._ast = { ...ast }
if (updateCode) {
this.code = recast(ast)
this._code = recast(ast)
this._codeCallBack(this._code)
}
this._executeCallback()
}
async executeAstMock(ast: Program = this._ast, updateCode = false) {
await this.ensureWasmInit()
const newCode = recast(ast)
const newAst = this.safeParse(newCode)
if (!newAst) return
const newAst = parse(newCode)
await this?.engineCommandManager?.waitForReady
if (updateCode) {
this.setCode(recast(ast))
@ -287,17 +233,13 @@ class KclManager {
this.ast = ast
if (code) this.code = code
}
setCode(code: string, shouldWriteFile = true) {
if (shouldWriteFile) {
// use the normal code setter
this.code = code
return
}
setCode(code: string) {
this._code = code
this._codeCallBack(code)
localStorage.setItem(PERSIST_CODE_TOKEN, code)
}
setCodeAndExecute(code: string, shouldWriteFile = true) {
this.setCode(code, shouldWriteFile)
setCodeAndExecute(code: string) {
this.setCode(code)
if (code.trim()) {
this._defferer(code)
return
@ -318,11 +260,9 @@ class KclManager {
this.engineCommandManager.endSession()
}
format() {
const ast = this.safeParse(this.code)
if (!ast) return
this.code = recast(ast)
this.code = recast(parse(kclManager.code))
}
// There's overlapping responsibility between updateAst and executeAst.
// There's overlapping resposibility between updateAst and executeAst.
// updateAst was added as it was used a lot before xState migration so makes the port easier.
// but should probably have think about which of the function to keep
async updateAst(
@ -330,13 +270,15 @@ class KclManager {
execute: boolean,
optionalParams?: {
focusPath?: PathToNode
callBack?: (ast: Program) => void
}
): Promise<Selections | null> {
const newCode = recast(ast)
const astWithUpdatedSource = this.safeParse(newCode)
if (!astWithUpdatedSource) return null
const astWithUpdatedSource = parse(newCode)
optionalParams?.callBack?.(astWithUpdatedSource)
let returnVal: Selections | null = null
this.code = newCode
if (optionalParams?.focusPath) {
const { node } = getNodeFromPath<any>(
astWithUpdatedSource,
@ -357,12 +299,12 @@ class KclManager {
if (execute) {
// Call execute on the set ast.
await this.executeAst(astWithUpdatedSource, true)
await this.executeAst(astWithUpdatedSource)
} else {
// When we don't re-execute, we still want to update the program
// memory with the new ast. So we will hit the mock executor
// instead.
await this.executeAstMock(astWithUpdatedSource, true)
await this.executeAstMock(astWithUpdatedSource)
}
return returnVal
}
@ -427,11 +369,6 @@ export function KclContextProvider({
setWasmInitFailed,
})
}, [])
const params = useParams()
useEffect(() => {
kclManager.setParams(params)
}, [params])
return (
<KclContext.Provider
value={{

View File

@ -20,7 +20,7 @@ describe('testing AST', () => {
type: 'Literal',
start: 0,
end: 1,
value: 5,
value: { type: 'i_integer', data: 5 },
raw: '5',
},
operator: '+',
@ -28,7 +28,7 @@ describe('testing AST', () => {
type: 'Literal',
start: 3,
end: 4,
value: 6,
value: { type: 'i_integer', data: 6 },
raw: '6',
},
},
@ -58,7 +58,7 @@ describe('testing AST', () => {
type: 'Literal',
start: 14,
end: 15,
value: 5,
value: { type: 'i_integer', data: 5 },
raw: '5',
},
},
@ -92,7 +92,7 @@ const newVar = myVar + 1
type: 'Literal',
start: 14,
end: 15,
value: 5,
value: { type: 'i_integer', data: 5 },
raw: '5',
},
},
@ -129,7 +129,7 @@ const newVar = myVar + 1
type: 'Literal',
start: 39,
end: 40,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
},
@ -320,14 +320,14 @@ const myVar = funcN(1, 2)`
type: 'Literal',
start: 58,
end: 59,
value: 1,
value: { data: 1, type: 'i_integer' },
raw: '1',
},
{
type: 'Literal',
start: 61,
end: 62,
value: 2,
value: { data: 2, type: 'i_integer' },
raw: '2',
},
],
@ -390,14 +390,14 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 32,
end: 33,
value: 0,
value: { type: 'i_integer', data: 0 },
raw: '0',
},
{
type: 'Literal',
start: 35,
end: 36,
value: 0,
value: { type: 'i_integer', data: 0 },
raw: '0',
},
],
@ -426,14 +426,14 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 52,
end: 53,
value: 2,
value: { type: 'i_integer', data: 2 },
raw: '2',
},
{
type: 'Literal',
start: 55,
end: 56,
value: 3,
value: { type: 'i_integer', data: 3 },
raw: '3',
},
],
@ -478,14 +478,14 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 81,
end: 82,
value: 0,
value: { type: 'i_integer', data: 0 },
raw: '0',
},
{
type: 'Literal',
start: 84,
end: 85,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
],
@ -505,7 +505,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 93,
end: 101,
value: 'myPath',
value: { type: 'string', data: 'myPath' },
raw: '"myPath"',
},
},
@ -536,14 +536,14 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 121,
end: 122,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
{
type: 'Literal',
start: 124,
end: 125,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
],
@ -568,7 +568,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 139,
end: 141,
value: 45,
value: { type: 'i_integer', data: 45 },
raw: '45',
},
{ type: 'PipeSubstitution', start: 143, end: 144 },
@ -619,7 +619,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 14,
end: 15,
value: 5,
value: { type: 'i_integer', data: 5 },
raw: '5',
},
operator: '+',
@ -627,7 +627,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 18,
end: 19,
value: 6,
value: { type: 'i_integer', data: 6 },
raw: '6',
},
},
@ -646,7 +646,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 30,
end: 32,
value: 45,
value: { type: 'i_integer', data: 45 },
raw: '45',
},
{
@ -696,14 +696,14 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 12,
end: 13,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
{
type: 'Literal',
start: 15,
end: 18,
value: '2',
value: { type: 'string', data: '2' },
raw: "'2'",
},
{
@ -720,7 +720,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 27,
end: 28,
value: 4,
value: { type: 'i_integer', data: 4 },
raw: '4',
},
operator: '+',
@ -728,7 +728,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 31,
end: 32,
value: 5,
value: { type: 'i_integer', data: 5 },
raw: '5',
},
},
@ -766,7 +766,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 14,
end: 15,
value: 3,
value: { type: 'i_integer', data: 3 },
raw: '3',
},
},
@ -807,7 +807,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 34,
end: 39,
value: 'str',
value: { type: 'string', data: 'str' },
raw: "'str'",
},
},
@ -825,7 +825,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 47,
end: 48,
value: 2,
value: { type: 'i_integer', data: 2 },
raw: '2',
},
},
@ -864,7 +864,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 77,
end: 78,
value: 4,
value: { type: 'i_integer', data: 4 },
raw: '4',
},
operator: '+',
@ -872,7 +872,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 81,
end: 82,
value: 5,
value: { type: 'i_integer', data: 5 },
raw: '5',
},
},
@ -940,7 +940,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 27,
end: 34,
value: 'value',
value: { type: 'string', data: 'value' },
raw: "'value'",
},
},
@ -998,14 +998,14 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 18,
end: 19,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
{
type: 'Literal',
start: 21,
end: 24,
value: '2',
value: { type: 'string', data: '2' },
raw: "'2'",
},
],
@ -1120,7 +1120,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 20,
end: 25,
value: 'two',
value: { type: 'string', data: 'two' },
raw: '"two"',
},
},
@ -1169,7 +1169,7 @@ describe('testing pipe operator special', () => {
type: 'Literal',
start: 16,
end: 21,
value: 'one',
value: { type: 'string', data: 'one' },
raw: '"one"',
},
},
@ -1215,7 +1215,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 11,
end: 12,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
operator: '+',
@ -1223,7 +1223,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 15,
end: 16,
value: 2,
value: { type: 'i_integer', data: 2 },
raw: '2',
},
},
@ -1263,7 +1263,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 11,
end: 12,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
operator: '*',
@ -1271,7 +1271,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 15,
end: 16,
value: 2,
value: { type: 'i_integer', data: 2 },
raw: '2',
},
},
@ -1280,7 +1280,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 19,
end: 20,
value: 3,
value: { type: 'i_integer', data: 3 },
raw: '3',
},
},
@ -1316,7 +1316,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 11,
end: 12,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
operator: '+',
@ -1328,7 +1328,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 15,
end: 16,
value: 2,
value: { type: 'i_integer', data: 2 },
raw: '2',
},
operator: '*',
@ -1336,7 +1336,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 19,
end: 20,
value: 3,
value: { type: 'i_integer', data: 3 },
raw: '3',
},
},
@ -1345,7 +1345,7 @@ describe('nests binary expressions correctly', () => {
],
})
})
it('should nest properly with two operators of equal precedence', () => {
it('should nest properly with two opperators of equal precedence', () => {
const code = `const yo = 1 + 2 - 3`
const { body } = parse(code)
expect((body[0] as any).declarations[0].init).toEqual({
@ -1360,7 +1360,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 11,
end: 12,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
operator: '+',
@ -1368,7 +1368,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 15,
end: 16,
value: 2,
value: { type: 'i_integer', data: 2 },
raw: '2',
},
},
@ -1377,12 +1377,12 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 19,
end: 20,
value: 3,
value: { type: 'i_integer', data: 3 },
raw: '3',
},
})
})
it('should nest properly with two operators of equal (but higher) precedence', () => {
it('should nest properly with two opperators of equal (but higher) precedence', () => {
const code = `const yo = 1 * 2 / 3`
const { body } = parse(code)
expect((body[0] as any).declarations[0].init).toEqual({
@ -1397,7 +1397,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 11,
end: 12,
value: 1,
value: { type: 'i_integer', data: 1 },
raw: '1',
},
operator: '*',
@ -1405,7 +1405,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 15,
end: 16,
value: 2,
value: { type: 'i_integer', data: 2 },
raw: '2',
},
},
@ -1414,7 +1414,7 @@ describe('nests binary expressions correctly', () => {
type: 'Literal',
start: 19,
end: 20,
value: 3,
value: { type: 'i_integer', data: 3 },
raw: '3',
},
})
@ -1433,7 +1433,13 @@ describe('nests binary expressions correctly', () => {
operator: '+',
start: 11,
end: 30,
left: { type: 'Literal', value: 1, raw: '1', start: 11, end: 12 },
left: {
type: 'Literal',
value: { type: 'i_integer', data: 1 },
raw: '1',
start: 11,
end: 12,
},
right: {
type: 'BinaryExpression',
operator: '/',
@ -1444,26 +1450,50 @@ describe('nests binary expressions correctly', () => {
operator: '*',
start: 15,
end: 25,
left: { type: 'Literal', value: 2, raw: '2', start: 15, end: 16 },
left: {
type: 'Literal',
value: { type: 'i_integer', data: 2 },
raw: '2',
start: 15,
end: 16,
},
right: {
type: 'BinaryExpression',
operator: '-',
start: 20,
end: 25,
left: { type: 'Literal', value: 3, raw: '3', start: 20, end: 21 },
left: {
type: 'Literal',
value: { type: 'i_integer', data: 3 },
raw: '3',
start: 20,
end: 21,
},
right: {
type: 'Literal',
value: 4,
value: { type: 'i_integer', data: 4 },
raw: '4',
start: 24,
end: 25,
},
},
},
right: { type: 'Literal', value: 5, raw: '5', start: 29, end: 30 },
right: {
type: 'Literal',
value: { type: 'i_integer', data: 5 },
raw: '5',
start: 29,
end: 30,
},
},
},
right: { type: 'Literal', value: 6, raw: '6', start: 33, end: 34 },
right: {
type: 'Literal',
value: { type: 'i_integer', data: 6 },
raw: '6',
start: 33,
end: 34,
},
})
})
})
@ -1481,7 +1511,7 @@ const key = 'c'`
value: {
type: 'blockComment',
style: 'line',
value: 'this is a comment',
value: { type: 'string', data: 'this is a comment' },
},
}
const { nonCodeMeta } = parse(code)
@ -1564,8 +1594,20 @@ describe('test UnaryExpression', () => {
end: 26,
callee: { type: 'Identifier', start: 15, end: 18, name: 'min' },
arguments: [
{ type: 'Literal', start: 19, end: 20, value: 4, raw: '4' },
{ type: 'Literal', start: 22, end: 25, value: 100, raw: '100' },
{
type: 'Literal',
start: 19,
end: 20,
value: { type: 'i_integer', data: 4 },
raw: '4',
},
{
type: 'Literal',
start: 22,
end: 25,
value: { type: 'i_integer', data: 100 },
raw: '100',
},
],
function: expect.any(Object),
optional: false,
@ -1585,21 +1627,45 @@ describe('testing nested call expressions', () => {
end: 40,
callee: { type: 'Identifier', start: 14, end: 17, name: 'min' },
arguments: [
{ type: 'Literal', start: 18, end: 21, value: 100, raw: '100' },
{
type: 'Literal',
start: 18,
end: 21,
value: { type: 'i_integer', data: 100 },
raw: '100',
},
{
type: 'BinaryExpression',
operator: '+',
start: 23,
end: 39,
left: { type: 'Literal', value: 1, raw: '1', start: 23, end: 24 },
left: {
type: 'Literal',
value: { type: 'i_integer', data: 1 },
raw: '1',
start: 23,
end: 24,
},
right: {
type: 'CallExpression',
start: 27,
end: 39,
callee: { type: 'Identifier', start: 27, end: 33, name: 'legLen' },
arguments: [
{ type: 'Literal', start: 34, end: 35, value: 5, raw: '5' },
{ type: 'Literal', start: 37, end: 38, value: 3, raw: '3' },
{
type: 'Literal',
start: 34,
end: 35,
value: { type: 'i_integer', data: 5 },
raw: '5',
},
{
type: 'Literal',
start: 37,
end: 38,
value: { type: 'i_integer', data: 3 },
raw: '3',
},
],
function: expect.any(Object),
optional: false,
@ -1633,7 +1699,7 @@ describe('should recognise callExpresions in binaryExpressions', () => {
type: 'Literal',
start: 16,
end: 23,
value: 'seg02',
value: { type: 'string', data: 'seg02' },
raw: "'seg02'",
},
{ type: 'PipeSubstitution', start: 25, end: 26 },
@ -1641,7 +1707,13 @@ describe('should recognise callExpresions in binaryExpressions', () => {
function: expect.any(Object),
optional: false,
},
right: { type: 'Literal', value: 1, raw: '1', start: 30, end: 31 },
right: {
type: 'Literal',
value: { type: 'i_integer', data: 1 },
raw: '1',
start: 30,
end: 31,
},
},
{ type: 'PipeSubstitution', start: 33, end: 34 },
])

View File

@ -18,20 +18,6 @@ export class KCLError {
}
}
export class KCLLexicalError extends KCLError {
constructor(msg: string, sourceRanges: [number, number][]) {
super('lexical', msg, sourceRanges)
Object.setPrototypeOf(this, KCLSyntaxError.prototype)
}
}
export class KCLInternalError extends KCLError {
constructor(msg: string, sourceRanges: [number, number][]) {
super('internal', msg, sourceRanges)
Object.setPrototypeOf(this, KCLSyntaxError.prototype)
}
}
export class KCLSyntaxError extends KCLError {
constructor(msg: string, sourceRanges: [number, number][]) {
super('syntax', msg, sourceRanges)

View File

@ -21,7 +21,7 @@ describe('Testing createLiteral', () => {
it('should create a literal', () => {
const result = createLiteral(5)
expect(result.type).toBe('Literal')
expect(result.value).toBe(5)
expect(result.value.data).toBe(5)
})
})
describe('Testing createIdentifier', () => {
@ -38,7 +38,7 @@ describe('Testing createCallExpression', () => {
expect(result.callee.type).toBe('Identifier')
expect(result.callee.name).toBe('myFunc')
expect(result.arguments[0].type).toBe('Literal')
expect((result.arguments[0] as any).value).toBe(5)
expect((result.arguments[0] as any).value.data).toBe(5)
})
})
describe('Testing createObjectExpression', () => {
@ -50,7 +50,7 @@ describe('Testing createObjectExpression', () => {
expect(result.properties[0].type).toBe('ObjectProperty')
expect(result.properties[0].key.name).toBe('myProp')
expect(result.properties[0].value.type).toBe('Literal')
expect((result.properties[0].value as any).value).toBe(5)
expect((result.properties[0].value as any).value.data).toBe(5)
})
})
describe('Testing createArrayExpression', () => {
@ -58,7 +58,7 @@ describe('Testing createArrayExpression', () => {
const result = createArrayExpression([createLiteral(5)])
expect(result.type).toBe('ArrayExpression')
expect(result.elements[0].type).toBe('Literal')
expect((result.elements[0] as any).value).toBe(5)
expect((result.elements[0] as any).value.data).toBe(5)
})
})
describe('Testing createPipeSubstitution', () => {
@ -75,7 +75,7 @@ describe('Testing createVariableDeclaration', () => {
expect(result.declarations[0].id.type).toBe('Identifier')
expect(result.declarations[0].id.name).toBe('myVar')
expect(result.declarations[0].init.type).toBe('Literal')
expect((result.declarations[0].init as any).value).toBe(5)
expect((result.declarations[0].init as any).value.data).toBe(5)
})
})
describe('Testing createPipeExpression', () => {
@ -83,7 +83,7 @@ describe('Testing createPipeExpression', () => {
const result = createPipeExpression([createLiteral(5)])
expect(result.type).toBe('PipeExpression')
expect(result.body[0].type).toBe('Literal')
expect((result.body[0] as any).value).toBe(5)
expect((result.body[0] as any).value.data).toBe(5)
})
})

View File

@ -440,11 +440,15 @@ export function splitPathAtPipeExpression(pathToNode: PathToNode): {
}
export function createLiteral(value: string | number): Literal {
const literalValue =
typeof value === 'string'
? ({ type: 'string', data: value } as const)
: ({ type: 'fractional', data: value } as const)
return {
type: 'Literal',
start: 0,
end: 0,
value,
value: literalValue,
raw: `${value}`,
}
}
@ -641,7 +645,7 @@ export function giveSketchFnCallTag(
const isTagExisting = !!firstArg.tag
const tagValue = (firstArg.tag ||
createLiteral(tag || findUniqueName(ast, 'seg', 2))) as Literal
const tagStr = String(tagValue.value)
const tagStr = String(tagValue.value.data)
const newFirstArg = createFirstArg(
primaryCallExp.callee.name as ToolTip,
firstArg.val,

View File

@ -2,5 +2,5 @@ The std is as expected, tools that are provided with the language.
For this language that means functions.
However because programmatically changing the source code is a first class citizen in this lang, there needs to be helpers for adding and modifying these function calls,
However because programatically changing the source code is a first class citizen in this lang, there needs to be helpes for adding and modifying these function calls,
So it makes sense to group some of these together.

View File

@ -664,7 +664,7 @@ export class EngineCommandManager {
},
})
// Initialize the planes.
// Inisialize the planes.
this.initPlanes().then(() => {
// We execute the code here to make sure if the stream was to
// restart in a session, we want to make sure to execute the code.
@ -887,9 +887,8 @@ export class EngineCommandManager {
}
endSession() {
// TODO: instead of sending a single command with `object_ids: Object.keys(this.artifactMap)`
// we need to loop over them each individually because if the engine doesn't recognise a single
// we need to loop over them each individualy because if the engine doesn't recognise a single
// id the whole command fails.
const artifactsToDelete: any = {}
Object.entries(this.artifactMap).forEach(([id, artifact]) => {
const artifactTypesToDelete: ArtifactMap[string]['commandType'][] = [
// 'start_path' creates a new scene object for the path, which is why it needs to be deleted,
@ -899,9 +898,7 @@ export class EngineCommandManager {
'start_path',
]
if (!artifactTypesToDelete.includes(artifact.commandType)) return
artifactsToDelete[id] = artifact
})
Object.keys(artifactsToDelete).forEach((id) => {
const deletCmd: EngineCommand = {
type: 'modeling_cmd_req',
cmd_id: uuidv4(),

View File

@ -50,7 +50,7 @@ async function testingSwapSketchFnCall({
}
}
describe('testing swapping out sketch calls with xLine/xLineTo', () => {
describe('testing swaping out sketch calls with xLine/xLineTo', () => {
const bigExampleArr = [
`const part001 = startSketchOn('XY')`,
` |> startProfileAt([0, 0], %)`,
@ -178,7 +178,7 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
constraintType: 'horizontal',
})
const expectedLine = "xLine({ length: -0.86, tag: 'abc4' }, %)"
// hmm "-0.86" is correct since the angle is 104, but need to make sure this is compatible `-myVar`
// hmm "-0.86" is correct since the angle is 104, but need to make sure this is compatiable `-myVar`
expect(newCode).toContain(expectedLine)
// new line should start at the same place as the old line
expect(originalRange[0]).toBe(newCode.indexOf(expectedLine))
@ -268,7 +268,7 @@ describe('testing swapping out sketch calls with xLine/xLineTo', () => {
})
})
describe('testing swapping out sketch calls with xLine/xLineTo while keeping variable/identifiers intact', () => {
describe('testing swaping out sketch calls with xLine/xLineTo while keeping variable/identifiers intact', () => {
// Enable rotations #152
const variablesExampleArr = [
`const lineX = -1`,

View File

@ -108,7 +108,7 @@ const part001 = startSketchOn('XY')
|> line([myVar, 1], %) // ln-should use legLen for y
|> line([myVar, -1], %) // ln-legLen but negative
|> line([-0.62, -1.54], %) // ln-should become angledLine
|> angledLine([myVar, 1.04], %) // ln-use segLen for second arg
|> angledLine([myVar, 1.04], %) // ln-use segLen for secound arg
|> angledLine([45, 1.04], %) // ln-segLen again
|> angledLineOfXLength([54, 2.35], %) // ln-should be transformed to angledLine
|> angledLineOfXLength([50, myVar], %) // ln-should use legAngX to calculate angle
@ -163,7 +163,7 @@ const part001 = startSketchOn('XY')
-legLen(segLen('seg01', %), myVar)
], %) // ln-legLen but negative
|> angledLine([-112, segLen('seg01', %)], %) // ln-should become angledLine
|> angledLine([myVar, segLen('seg01', %)], %) // ln-use segLen for second arg
|> angledLine([myVar, segLen('seg01', %)], %) // ln-use segLen for secound arg
|> angledLine([45, segLen('seg01', %)], %) // ln-segLen again
|> angledLine([54, segLen('seg01', %)], %) // ln-should be transformed to angledLine
|> angledLineOfXLength([
@ -471,7 +471,7 @@ async function helperThing(
}
describe('testing getConstraintLevelFromSourceRange', () => {
it('should divide up lines into free, partial and fully contrained', () => {
it('should devide up lines into free, partial and fully contrained', () => {
const code = `const baseLength = 3
const baseThick = 1
const armThick = 0.5

View File

@ -1426,7 +1426,7 @@ export function transformAstSketchLines({
referenceSegName ||
(_referencedSegmentNameVal &&
_referencedSegmentNameVal.type === 'Literal' &&
String(_referencedSegmentNameVal.value)) ||
String(_referencedSegmentNameVal.value.data)) ||
''
const [varValA, varValB] = Array.isArray(val) ? val : [val, val]

View File

@ -26,4 +26,5 @@ const bracket = startSketchOn('XY')
|> close(%)
|> extrude(width, %)
show(bracket)
`

View File

@ -15,7 +15,7 @@ app needs these selections to be based on cursors, therefore the app must
be in control of selections. On top of that because we need to set cursor
positions in code-mirror for selections, both from app logic, and still
allow the user to add multiple cursors like a normal editor, it's best to
let code mirror control cursor positions and associate those source ranges
let code mirror control cursor positions and assosiate those source ranges
with entity ids from code-mirror events later.
So it's a lot of back and forth. conceptually the back and forth is:
@ -43,7 +43,7 @@ In detail:
1) Click commands are mostly sent in stream.tsx search for
"select_with_point"
2) The handler for when the engine sends back entity ids calls
2) The handler for when the engine sends back entitiy ids calls
getEventForSelectWithPoint, it fires an XState event to update our
selections is xstate context
3 and 4) The XState handler for the above uses handleSelectionBatch and
@ -303,7 +303,7 @@ export function resetAndSetEngineEntitySelectionCmds(
selections: SelectionToEngine[]
): Models['WebSocketRequest_type'][] {
if (!engineCommandManager.engineConnection?.isReady()) {
console.log('engine connection is not ready')
console.log('engine connection isnt ready')
return []
}
return [

View File

@ -9,6 +9,7 @@ import { documentDir, homeDir, sep } from '@tauri-apps/api/path'
import { isTauri } from './isTauri'
import { ProjectWithEntryPointMetadata } from '../Router'
import { metadata } from 'tauri-plugin-fs-extra-api'
import { bracket } from './exampleKcl'
const PROJECT_FOLDER = 'kittycad-modeling-projects'
export const FILE_EXT = '.kcl'
@ -210,8 +211,7 @@ export function sortProject(project: FileEntry[]): FileEntry[] {
// Creates a new file in the default directory with the default project name
// Returns the path to the new file
export async function createNewProject(
path: string,
initCode = ''
path: string
): Promise<ProjectWithEntryPointMetadata> {
if (!isTauri) {
throw new Error('createNewProject() can only be called from a Tauri app')
@ -225,12 +225,10 @@ export async function createNewProject(
})
}
await writeTextFile(path + sep + PROJECT_ENTRYPOINT, initCode).catch(
(err) => {
console.error('Error creating new file:', err)
throw err
}
)
await writeTextFile(path + sep + PROJECT_ENTRYPOINT, bracket).catch((err) => {
console.error('Error creating new file:', err)
throw err
})
const m = await metadata(path)

View File

@ -664,8 +664,8 @@ export const modelingMachine = createMachine(
on: {
Cancel: {
target: 'idle',
// TODO what if we're existing extrude equipped, should these actions still be fired?
// maybe cancel needs to have a guard for if else logic?
// TODO what if we're existing extrude equiped, should these actions still be fired?
// mabye cancel needs to have a guard for if else logic?
actions: [
'edit_mode_exit',
'default_camera_disable_sketch_mode',

View File

@ -43,10 +43,7 @@ function OnboardingWithNewFile() {
ONBOARDING_PROJECT_NAME,
nextIndex
)
const newFile = await createNewProject(
defaultDirectory + sep + name,
bracket
)
const newFile = await createNewProject(defaultDirectory + sep + name)
navigate(
`${paths.FILE}/${encodeURIComponent(
newFile.path + sep + PROJECT_ENTRYPOINT
@ -82,7 +79,7 @@ function OnboardingWithNewFile() {
<ActionButton
Element="button"
onClick={() => {
kclManager.setCodeAndExecute(bracket)
kclManager.setCode(bracket)
next()
}}
icon={{ icon: faArrowRight }}
@ -121,7 +118,7 @@ function OnboardingWithNewFile() {
Element="button"
onClick={() => {
createAndOpenNewProject()
kclManager.setCode(bracket, false)
kclManager.setCode(bracket)
dismiss()
}}
icon={{ icon: faArrowRight }}

View File

@ -32,7 +32,6 @@ import {
} from 'lib/tauriFS'
import { ONBOARDING_PROJECT_NAME } from './Onboarding'
import { sep } from '@tauri-apps/api/path'
import { bracket } from 'lib/exampleKcl'
export const Settings = () => {
const loaderData =
@ -97,10 +96,7 @@ export const Settings = () => {
ONBOARDING_PROJECT_NAME,
nextIndex
)
const newFile = await createNewProject(
defaultDirectory + sep + name,
bracket
)
const newFile = await createNewProject(defaultDirectory + sep + name)
navigate(`${paths.FILE}/${encodeURIComponent(newFile.path)}`)
}

View File

@ -253,13 +253,11 @@ export async function executeAst({
engineCommandManager,
defaultPlanes,
useFakeExecutor = false,
programMemoryOverride,
}: {
ast: Program
engineCommandManager: EngineCommandManager
defaultPlanes: DefaultPlanes
useFakeExecutor?: boolean
programMemoryOverride?: ProgramMemory
}): Promise<{
logs: string[]
errors: KCLError[]
@ -271,13 +269,10 @@ export async function executeAst({
engineCommandManager.startNewSession()
}
const programMemory = await (useFakeExecutor
? enginelessExecutor(
ast,
programMemoryOverride || {
root: defaultProgramMemory,
return: null,
}
)
? enginelessExecutor(ast, {
root: defaultProgramMemory,
return: null,
})
: _executor(
ast,
{

View File

@ -1305,20 +1305,6 @@ dependencies = [
"serde",
]
[[package]]
name = "insta"
version = "1.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d64600be34b2fcfc267740a243fa7744441bb4947a619ac4e5bb6507f35fbfc"
dependencies = [
"console",
"lazy_static",
"linked-hash-map",
"serde",
"similar",
"yaml-rust",
]
[[package]]
name = "instant"
version = "0.1.12"
@ -1415,7 +1401,6 @@ dependencies = [
"derive-docs 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"expectorate",
"futures",
"insta",
"itertools 0.11.0",
"js-sys",
"kittycad",

View File

@ -57,7 +57,6 @@ debug = true # Flamegraphs of benchmarks require accurate debug symbols
[dev-dependencies]
criterion = "0.5.1"
expectorate = "1.1.0"
insta = { version = "1.34.0", features = ["json"] }
itertools = "0.11.0"
pretty_assertions = "1.4.0"
tokio = { version = "1.33.0", features = ["rt-multi-thread", "macros", "time"] }

View File

@ -784,7 +784,7 @@ pub enum NonCodeValue {
/// 1 + 1
/// ```
/// Now this is important. The block comment is attached to the next line.
/// This is always the case. Also the block comment doesn't have a new line above it.
/// This is always the case. Also the block comment doesnt have a new line above it.
/// If it did it would be a `NewLineBlockComment`.
BlockComment {
value: String,

View File

@ -6,7 +6,7 @@ use super::{Literal, Value};
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
#[serde(untagged, rename_all = "snake_case")]
#[serde(tag = "type", content = "data", rename_all = "snake_case")]
pub enum LiteralValue {
IInteger(i64),
Fractional(f64),

View File

@ -193,7 +193,7 @@ pub trait StdLibFn: std::fmt::Debug + Send + Sync {
}
fn to_signature_help(&self) -> SignatureHelp {
// Fill this in based on the current position of the cursor.
// Fill this in based on the current positon of the cursor.
let active_parameter = None;
SignatureHelp {

View File

@ -8,8 +8,6 @@ use crate::executor::SourceRange;
#[ts(export)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum KclError {
#[error("lexical: {0:?}")]
Lexical(KclErrorDetails),
#[error("syntax: {0:?}")]
Syntax(KclErrorDetails),
#[error("semantic: {0:?}")]
@ -28,8 +26,6 @@ pub enum KclError {
InvalidExpression(KclErrorDetails),
#[error("engine: {0:?}")]
Engine(KclErrorDetails),
#[error("internal error, please report to KittyCAD team: {0:?}")]
Internal(KclErrorDetails),
}
#[derive(Debug, Serialize, Deserialize, ts_rs::TS, Clone)]
@ -44,8 +40,20 @@ pub struct KclErrorDetails {
impl KclError {
/// Get the error message, line and column from the error and input code.
pub fn get_message_line_column(&self, input: &str) -> (String, Option<usize>, Option<usize>) {
let (type_, source_range, message) = match &self {
KclError::Syntax(e) => ("syntax", e.source_ranges.clone(), e.message.clone()),
KclError::Semantic(e) => ("semantic", e.source_ranges.clone(), e.message.clone()),
KclError::Type(e) => ("type", e.source_ranges.clone(), e.message.clone()),
KclError::Unimplemented(e) => ("unimplemented", e.source_ranges.clone(), e.message.clone()),
KclError::Unexpected(e) => ("unexpected", e.source_ranges.clone(), e.message.clone()),
KclError::ValueAlreadyDefined(e) => ("value already defined", e.source_ranges.clone(), e.message.clone()),
KclError::UndefinedValue(e) => ("undefined value", e.source_ranges.clone(), e.message.clone()),
KclError::InvalidExpression(e) => ("invalid expression", e.source_ranges.clone(), e.message.clone()),
KclError::Engine(e) => ("engine", e.source_ranges.clone(), e.message.clone()),
};
// Calculate the line and column of the error from the source range.
let (line, column) = if let Some(range) = self.source_ranges().first() {
let (line, column) = if let Some(range) = source_range.first() {
let line = input[..range.0[0]].lines().count();
let column = input[..range.0[0]].lines().last().map(|l| l.len()).unwrap_or_default();
@ -54,28 +62,11 @@ impl KclError {
(None, None)
};
(format!("{}: {}", self.error_type(), self.message()), line, column)
}
pub fn error_type(&self) -> &'static str {
match self {
KclError::Lexical(_) => "lexical",
KclError::Syntax(_) => "syntax",
KclError::Semantic(_) => "semantic",
KclError::Type(_) => "type",
KclError::Unimplemented(_) => "unimplemented",
KclError::Unexpected(_) => "unexpected",
KclError::ValueAlreadyDefined(_) => "value already defined",
KclError::UndefinedValue(_) => "undefined value",
KclError::InvalidExpression(_) => "invalid expression",
KclError::Engine(_) => "engine",
KclError::Internal(_) => "internal",
}
(format!("{}: {}", type_, message), line, column)
}
pub fn source_ranges(&self) -> Vec<SourceRange> {
match &self {
KclError::Lexical(e) => e.source_ranges.clone(),
KclError::Syntax(e) => e.source_ranges.clone(),
KclError::Semantic(e) => e.source_ranges.clone(),
KclError::Type(e) => e.source_ranges.clone(),
@ -85,14 +76,12 @@ impl KclError {
KclError::UndefinedValue(e) => e.source_ranges.clone(),
KclError::InvalidExpression(e) => e.source_ranges.clone(),
KclError::Engine(e) => e.source_ranges.clone(),
KclError::Internal(e) => e.source_ranges.clone(),
}
}
/// Get the inner error message.
pub fn message(&self) -> &str {
match &self {
KclError::Lexical(e) => &e.message,
KclError::Syntax(e) => &e.message,
KclError::Semantic(e) => &e.message,
KclError::Type(e) => &e.message,
@ -102,7 +91,6 @@ impl KclError {
KclError::UndefinedValue(e) => &e.message,
KclError::InvalidExpression(e) => &e.message,
KclError::Engine(e) => &e.message,
KclError::Internal(e) => &e.message,
}
}

View File

@ -1,10 +1,4 @@
use crate::{
ast::types::Program,
errors::KclError,
errors::KclErrorDetails,
executor::SourceRange,
token::{Token, TokenType},
};
use crate::{ast::types::Program, errors::KclError, token::Token};
mod math;
pub(crate) mod parser_impl;
@ -14,37 +8,15 @@ pub const PIPE_OPERATOR: &str = "|>";
pub struct Parser {
pub tokens: Vec<Token>,
pub unknown_tokens: Vec<Token>,
}
impl Parser {
pub fn new(tokens: Vec<Token>) -> Self {
let (tokens, unknown_tokens): (Vec<Token>, Vec<Token>) = tokens
.into_iter()
.partition(|token| token.token_type != TokenType::Unknown);
Self { tokens, unknown_tokens }
Self { tokens }
}
/// Run the parser
pub fn ast(&self) -> Result<Program, KclError> {
if self.tokens.is_empty() {
return Err(KclError::Syntax(KclErrorDetails {
source_ranges: vec![],
message: "file is empty".to_string(),
}));
}
if !self.unknown_tokens.is_empty() {
let source_ranges = self.unknown_tokens.iter().map(SourceRange::from).collect();
let token_list = self.unknown_tokens.iter().map(|t| t.value.as_str()).collect::<Vec<_>>();
let message = if token_list.len() == 1 {
format!("found unknown token '{}'", token_list[0])
} else {
format!("found unknown tokens [{}]", token_list.join(", "))
};
return Err(KclError::Lexical(KclErrorDetails { source_ranges, message }));
}
parser_impl::run_parser(&mut self.tokens.as_slice())
}
}

View File

@ -1,33 +1,20 @@
use crate::{
ast::types::{BinaryExpression, BinaryOperator, BinaryPart},
errors::{KclError, KclErrorDetails},
executor::SourceRange,
};
use crate::ast::types::{BinaryExpression, BinaryOperator, BinaryPart};
/// Parses a list of tokens (in infix order, i.e. as the user typed them)
/// into a binary expression tree.
pub fn parse(infix_tokens: Vec<BinaryExpressionToken>) -> Result<BinaryExpression, KclError> {
pub fn parse(infix_tokens: Vec<BinaryExpressionToken>) -> BinaryExpression {
let rpn = postfix(infix_tokens);
evaluate(rpn)
}
/// Parses a list of tokens (in postfix order) into a binary expression tree.
fn evaluate(rpn: Vec<BinaryExpressionToken>) -> Result<BinaryExpression, KclError> {
let source_ranges = source_range(&rpn);
let mut operand_stack: Vec<BinaryPart> = Vec::new();
let e = KclError::Internal(KclErrorDetails {
source_ranges,
message: "error parsing binary math expressions".to_owned(),
});
fn evaluate(rpn: Vec<BinaryExpressionToken>) -> BinaryExpression {
let mut operand_stack = Vec::new();
for item in rpn {
let expr = match item {
BinaryExpressionToken::Operator(operator) => {
let Some(right) = operand_stack.pop() else {
return Err(e);
};
let Some(left) = operand_stack.pop() else {
return Err(e);
};
let right: BinaryPart = operand_stack.pop().unwrap();
let left = operand_stack.pop().unwrap();
BinaryPart::BinaryExpression(Box::new(BinaryExpression {
start: left.start(),
end: right.end(),
@ -40,26 +27,10 @@ fn evaluate(rpn: Vec<BinaryExpressionToken>) -> Result<BinaryExpression, KclErro
};
operand_stack.push(expr)
}
if let Some(BinaryPart::BinaryExpression(expr)) = operand_stack.pop() {
Ok(*expr)
if let BinaryPart::BinaryExpression(expr) = operand_stack.pop().unwrap() {
*expr
} else {
// If this branch is used, the evaluation algorithm has a bug and must be fixed.
// This is a programmer error, not a user error.
Err(e)
}
}
fn source_range(tokens: &[BinaryExpressionToken]) -> Vec<SourceRange> {
let sources: Vec<_> = tokens
.iter()
.filter_map(|op| match op {
BinaryExpressionToken::Operator(_) => None,
BinaryExpressionToken::Operand(o) => Some((o.start(), o.end())),
})
.collect();
match (sources.first(), sources.last()) {
(Some((start, _)), Some((_, end))) => vec![SourceRange([*start, *end])],
_ => Vec::new(),
panic!("Last expression was not a binary expression")
}
}
@ -75,16 +46,15 @@ fn postfix(infix: Vec<BinaryExpressionToken>) -> Vec<BinaryExpressionToken> {
// there is an operator o2 at the top of the operator stack which is not a left parenthesis,
// and (o2 has greater precedence than o1 or (o1 and o2 have the same precedence and o1 is left-associative))
// )
// pop o2 from the operator stack into the output queue
while let Some(o2) = operator_stack.pop() {
if (o2.precedence() > o1.precedence())
|| o1.precedence() == o2.precedence() && o1.associativity().is_left()
{
output.push(BinaryExpressionToken::Operator(o2));
} else {
operator_stack.push(o2);
break;
}
while operator_stack
.last()
.map(|o2| {
(o2.precedence() > o1.precedence())
|| o1.precedence() == o2.precedence() && o1.associativity().is_left()
})
.unwrap_or(false)
{
output.push(BinaryExpressionToken::Operator(operator_stack.pop().unwrap()));
}
operator_stack.push(o1);
}
@ -124,7 +94,7 @@ mod tests {
#[test]
fn parse_and_evaluate() {
/// Make a literal
fn lit(n: u8) -> BinaryPart {
fn lit(n: i64) -> BinaryPart {
BinaryPart::Literal(Box::new(Literal {
start: 0,
end: 0,
@ -157,7 +127,8 @@ mod tests {
];
for infix_input in tests {
let rpn = postfix(infix_input);
let _tree = evaluate(rpn).unwrap();
let tree = evaluate(rpn);
dbg!(tree);
}
}
}

View File

@ -34,6 +34,13 @@ lazy_static::lazy_static! {
type TokenSlice<'slice, 'input> = &'slice mut &'input [Token];
pub fn run_parser(i: TokenSlice) -> Result<Program, KclError> {
if i.is_empty() {
return Err(KclError::Syntax(KclErrorDetails {
source_ranges: vec![],
message: "file is empty".to_string(),
}));
}
program.parse(i).map_err(KclError::from)
}
@ -1039,8 +1046,7 @@ fn binary_expression(i: TokenSlice) -> PResult<BinaryExpression> {
// Pass the token slice into the specialized math parser, for things like
// precedence and converting infix operations to an AST.
let expr = super::math::parse(tokens).map_err(|e| ErrMode::Backtrack(e.into()))?;
Ok(expr)
Ok(super::math::parse(tokens))
}
fn binary_expr_in_parens(i: TokenSlice) -> PResult<BinaryExpression> {
@ -1663,6 +1669,95 @@ const mySk1 = startSketchAt([0, 0])"#;
assert_eq!(inner.operator, BinaryOperator::Sub);
}
#[test]
fn check_parsers_work_the_same() {
for (i, test_program) in [
r#"const boxSketch = startSketchAt([0, 0])
|> line([0, 10], %)
|> tangentialArc([-5, 5], %)
|> line([5, -15], %)
|> extrude(10, %)
"#,
"const myVar = min(5 , -legLen(5, 4))", // Space before comma
"const myVar = min(-legLen(5, 4), 5)",
"const myVar = 5 + 6 |> myFunc(45, %)",
"let x = 1 * (3 - 4)",
r#"const x = 1 // this is an inline comment"#,
r#"fn x = () => {
return sg
return sg
}"#,
r#"const x = -leg2 + thickness"#,
r#"const obj = { a: 1, b: 2 }
const height = 1 - obj.a"#,
r#"const obj = { a: 1, b: 2 }
const height = 1 - obj["a"]"#,
r#"const obj = { a: 1, b: 2 }
const height = obj["a"] - 1"#,
r#"const obj = { a: 1, b: 2 }
const height = [1 - obj["a"], 0]"#,
r#"const obj = { a: 1, b: 2 }
const height = [obj["a"] - 1, 0]"#,
r#"const obj = { a: 1, b: 2 }
const height = [obj["a"] -1, 0]"#,
"const height = 1 - obj.a",
"const six = 1 + 2 + 3",
"const five = 3 * 1 + 2",
r#"const height = [ obj["a"], 0 ]"#,
r#"const obj = { a: 1, b: 2 }
const height = obj["a"]"#,
r#"const prop = yo["one"][two]"#,
r#"const pt1 = b1[x]"#,
"const prop = yo.one.two.three.four",
r#"const pt1 = b1[0]"#,
r#"const pt1 = b1['zero']"#,
r#"const pt1 = b1.zero"#,
"const sg = startSketchAt(pos)",
"const sg = startSketchAt(pos) |> line([0, -scale], %)",
r#"const sg = -scale"#,
"lineTo({ to: [0, -1] })",
"const myArray = [0..10]",
r#"
fn firstPrimeNumber = () => {
return 2
}
firstPrimeNumber()"#,
r#"fn thing = (param) => {
return true
}
thing(false)"#,
r#"const mySketch = startSketchAt([0,0])
|> lineTo({ to: [0, 1], tag: 'myPath' }, %)
|> lineTo([1, 1], %)
|> lineTo({ to: [1,0], tag: "rightPath" }, %)
|> close(%)"#,
"const mySketch = startSketchAt([0,0]) |> lineTo([1, 1], %) |> close(%)",
"const myBox = startSketchAt(p)",
r#"const myBox = f(1) |> g(2)"#,
r#"const myBox = startSketchAt(p) |> line([0, l], %)"#,
"lineTo({ to: [0, 1] })",
"lineTo({ to: [0, 1], from: [3, 3] })",
"lineTo({to:[0, 1]})",
"lineTo({ to: [0, 1], from: [3, 3]})",
"lineTo({ to: [0, 1],from: [3, 3] })",
"const mySketch = startSketchAt([0,0])",
"log(5, \"hello\", aIdentifier)",
r#"5 + "a""#,
"line([0, l], %)",
]
.into_iter()
.enumerate()
{
// Run the original parser
let tokens = crate::token::lexer(test_program);
// TODO: get snapshots of what this outputs.
let _actual = match program.parse(&tokens) {
Ok(x) => x,
Err(_e) => panic!("could not parse test {i}"),
};
}
}
#[test]
fn binary_expression_ignores_whitespace() {
let tests = ["1 - 2", "1- 2", "1 -2", "1-2"];
@ -2215,10 +2310,9 @@ const secondExtrude = startSketchOn('XY')
let tokens = crate::token::lexer(">!");
let parser = crate::parser::Parser::new(tokens);
let err = parser.ast().unwrap_err();
assert_eq!(
err.to_string(),
r#"lexical: KclErrorDetails { source_ranges: [SourceRange([1, 2])], message: "found unknown token '!'" }"#
);
// TODO: Better errors when program cannot tokenize.
// https://github.com/KittyCAD/modeling-app/issues/696
assert!(err.to_string().contains("file is empty"));
}
#[test]
@ -2274,9 +2368,11 @@ z(-[["#,
let parser = crate::parser::Parser::new(tokens);
let result = parser.ast();
assert!(result.is_err());
// TODO: Better errors when program cannot tokenize.
// https://github.com/KittyCAD/modeling-app/issues/696
assert_eq!(
result.err().unwrap().to_string(),
r#"lexical: KclErrorDetails { source_ranges: [SourceRange([6, 7])], message: "found unknown token '#'" }"#
r#"syntax: KclErrorDetails { source_ranges: [], message: "file is empty" }"#
);
}
@ -2286,9 +2382,11 @@ z(-[["#,
let parser = crate::parser::Parser::new(tokens);
let result = parser.ast();
assert!(result.is_err());
// TODO: Better errors when program cannot tokenize.
// https://github.com/KittyCAD/modeling-app/issues/696
assert_eq!(
result.err().unwrap().to_string(),
r#"lexical: KclErrorDetails { source_ranges: [SourceRange([25, 26]), SourceRange([26, 27])], message: "found unknown tokens [#, #]" }"#
r#"syntax: KclErrorDetails { source_ranges: [], message: "file is empty" }"#
);
}
@ -2574,23 +2672,6 @@ thing(false)
);
}
#[test]
fn random_words_fail() {
let test_program = r#"const part001 = startSketchOn('-XZ')
|> startProfileAt([8.53, 11.8], %)
asdasd asdasd
|> line([11.12, -14.82], %)
|> line([-13.27, -6.98], %)
|> line([-5.09, 12.33], %)
asdasd
"#;
let tokens = crate::token::lexer(test_program);
let parser = crate::parser::Parser::new(tokens);
let result = parser.ast();
let e = result.unwrap_err();
eprintln!("{e:?}")
}
#[test]
fn test_member_expression_sketch_group() {
let some_program_string = r#"fn cube = (pos, scale) => {
@ -2644,173 +2725,24 @@ show(myBox)"#;
let parser = crate::parser::Parser::new(tokens);
parser.ast().unwrap();
}
}
#[cfg(test)]
mod snapshot_math_tests {
use super::*;
// This macro generates a test function with the given function name.
// The macro takes a KCL program, ensures it tokenizes and parses, then compares
// its parsed AST to a snapshot (kept in this repo in a file under snapshots/ dir)
macro_rules! snapshot_test {
($func_name:ident, $test_kcl_program:expr) => {
#[test]
fn $func_name() {
let tokens = crate::token::lexer($test_kcl_program);
let actual = match binary_expression.parse(&tokens) {
Ok(x) => x,
Err(_e) => panic!("could not parse test"),
};
insta::assert_json_snapshot!(actual);
}
};
}
snapshot_test!(a, "1 + 2");
snapshot_test!(b, "1+2");
snapshot_test!(c, "1 -2");
snapshot_test!(d, "1 + 2 * 3");
snapshot_test!(e, "1 * ( 2 + 3 )");
snapshot_test!(f, "1 * ( 2 + 3 ) / 4");
snapshot_test!(g, "1 + ( 2 + 3 ) / 4");
snapshot_test!(h, "1 * (( 2 + 3 ) / 4 + 5 )");
snapshot_test!(i, "1 * ((( 2 + 3 )))");
snapshot_test!(j, "distance * p * FOS * 6 / (sigmaAllow * width)");
snapshot_test!(k, "2 + (((3)))");
}
#[cfg(test)]
mod snapshot_tests {
use super::*;
// This macro generates a test function with the given function name.
// The macro takes a KCL program, ensures it tokenizes and parses, then compares
// its parsed AST to a snapshot (kept in this repo in a file under snapshots/ dir)
macro_rules! snapshot_test {
($func_name:ident, $test_kcl_program:expr) => {
#[test]
fn $func_name() {
let tokens = crate::token::lexer($test_kcl_program);
let actual = match program.parse(&tokens) {
Ok(x) => x,
Err(_e) => panic!("could not parse test"),
};
insta::assert_json_snapshot!(actual);
}
};
}
snapshot_test!(
a,
r#"const boxSketch = startSketchAt([0, 0])
|> line([0, 10], %)
|> tangentialArc([-5, 5], %)
|> line([5, -15], %)
|> extrude(10, %)
"#
);
snapshot_test!(b, "const myVar = min(5 , -legLen(5, 4))"); // Space before comma
snapshot_test!(c, "const myVar = min(-legLen(5, 4), 5)");
snapshot_test!(d, "const myVar = 5 + 6 |> myFunc(45, %)");
snapshot_test!(e, "let x = 1 * (3 - 4)");
snapshot_test!(f, r#"const x = 1 // this is an inline comment"#);
snapshot_test!(
g,
r#"fn x = () => {
return sg
return sg
}"#
);
snapshot_test!(d2, r#"const x = -leg2 + thickness"#);
snapshot_test!(
h,
r#"const obj = { a: 1, b: 2 }
const height = 1 - obj.a"#
);
snapshot_test!(
i,
r#"const obj = { a: 1, b: 2 }
const height = 1 - obj["a"]"#
);
snapshot_test!(
j,
r#"const obj = { a: 1, b: 2 }
const height = obj["a"] - 1"#
);
snapshot_test!(
k,
r#"const obj = { a: 1, b: 2 }
const height = [1 - obj["a"], 0]"#
);
snapshot_test!(
l,
r#"const obj = { a: 1, b: 2 }
const height = [obj["a"] - 1, 0]"#
);
snapshot_test!(
m,
r#"const obj = { a: 1, b: 2 }
const height = [obj["a"] -1, 0]"#
);
snapshot_test!(n, "const height = 1 - obj.a");
snapshot_test!(o, "const six = 1 + 2 + 3");
snapshot_test!(p, "const five = 3 * 1 + 2");
snapshot_test!(q, r#"const height = [ obj["a"], 0 ]"#);
snapshot_test!(
r,
r#"const obj = { a: 1, b: 2 }
const height = obj["a"]"#
);
snapshot_test!(s, r#"const prop = yo["one"][two]"#);
snapshot_test!(t, r#"const pt1 = b1[x]"#);
snapshot_test!(u, "const prop = yo.one.two.three.four");
snapshot_test!(v, r#"const pt1 = b1[0]"#);
snapshot_test!(w, r#"const pt1 = b1['zero']"#);
snapshot_test!(x, r#"const pt1 = b1.zero"#);
snapshot_test!(y, "const sg = startSketchAt(pos)");
snapshot_test!(z, "const sg = startSketchAt(pos) |> line([0, -scale], %)");
snapshot_test!(aa, r#"const sg = -scale"#);
snapshot_test!(ab, "lineTo({ to: [0, -1] })");
snapshot_test!(ac, "const myArray = [0..10]");
snapshot_test!(
ad,
r#"
fn firstPrimeNumber = () => {
return 2
}
firstPrimeNumber()"#
);
snapshot_test!(
ae,
r#"fn thing = (param) => {
return true
}
thing(false)"#
);
snapshot_test!(
af,
r#"const mySketch = startSketchAt([0,0])
|> lineTo({ to: [0, 1], tag: 'myPath' }, %)
|> lineTo([1, 1], %)
|> lineTo({ to: [1,0], tag: "rightPath" }, %)
|> close(%)"#
);
snapshot_test!(
ag,
"const mySketch = startSketchAt([0,0]) |> lineTo([1, 1], %) |> close(%)"
);
snapshot_test!(ah, "const myBox = startSketchAt(p)");
snapshot_test!(ai, r#"const myBox = f(1) |> g(2)"#);
snapshot_test!(aj, r#"const myBox = startSketchAt(p) |> line([0, l], %)"#);
snapshot_test!(ak, "lineTo({ to: [0, 1] })");
snapshot_test!(al, "lineTo({ to: [0, 1], from: [3, 3] })");
snapshot_test!(am, "lineTo({to:[0, 1]})");
snapshot_test!(an, "lineTo({ to: [0, 1], from: [3, 3]})");
snapshot_test!(ao, "lineTo({ to: [0, 1],from: [3, 3] })");
snapshot_test!(ap, "const mySketch = startSketchAt([0,0])");
snapshot_test!(aq, "log(5, \"hello\", aIdentifier)");
snapshot_test!(ar, r#"5 + "a""#);
snapshot_test!(at, "line([0, l], %)");
#[test]
fn test_math() {
for math_expression in [
"1 + 2",
"1+2",
"1 -2",
"1 + 2 * 3",
"1 * ( 2 + 3 )",
"1 * ( 2 + 3 ) / 4",
"1 + ( 2 + 3 ) / 4",
"1 * (( 2 + 3 ) / 4 + 5 )",
"1 * ((( 2 + 3 )))",
"distance * p * FOS * 6 / (sigmaAllow * width)",
"2 + (((3)))",
] {
let tokens = crate::token::lexer(math_expression);
let _expr = binary_expression.parse(&tokens).unwrap();
}
}
}

View File

@ -1,26 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 5,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 1,
"raw": "1"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 4,
"end": 5,
"value": 2,
"raw": "2"
}
}

View File

@ -1,26 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 3,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 1,
"raw": "1"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 2,
"end": 3,
"value": 2,
"raw": "2"
}
}

View File

@ -1,26 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 4,
"operator": "-",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 1,
"raw": "1"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 3,
"end": 4,
"value": 2,
"raw": "2"
}
}

View File

@ -1,41 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 9,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 1,
"raw": "1"
},
"right": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 4,
"end": 9,
"operator": "*",
"left": {
"type": "Literal",
"type": "Literal",
"start": 4,
"end": 5,
"value": 2,
"raw": "2"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 8,
"end": 9,
"value": 3,
"raw": "3"
}
}
}

View File

@ -1,41 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 11,
"operator": "*",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 1,
"raw": "1"
},
"right": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 6,
"end": 11,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 6,
"end": 7,
"value": 2,
"raw": "2"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 10,
"end": 11,
"value": 3,
"raw": "3"
}
}
}

View File

@ -1,56 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 17,
"operator": "/",
"left": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 0,
"end": 11,
"operator": "*",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 1,
"raw": "1"
},
"right": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 6,
"end": 11,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 6,
"end": 7,
"value": 2,
"raw": "2"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 10,
"end": 11,
"value": 3,
"raw": "3"
}
}
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 16,
"end": 17,
"value": 4,
"raw": "4"
}
}

View File

@ -1,56 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 17,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 1,
"raw": "1"
},
"right": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 6,
"end": 17,
"operator": "/",
"left": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 6,
"end": 11,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 6,
"end": 7,
"value": 2,
"raw": "2"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 10,
"end": 11,
"value": 3,
"raw": "3"
}
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 16,
"end": 17,
"value": 4,
"raw": "4"
}
}
}

View File

@ -1,71 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 22,
"operator": "*",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 1,
"raw": "1"
},
"right": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 7,
"end": 22,
"operator": "+",
"left": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 7,
"end": 18,
"operator": "/",
"left": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 7,
"end": 12,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 7,
"end": 8,
"value": 2,
"raw": "2"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 11,
"end": 12,
"value": 3,
"raw": "3"
}
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 4,
"raw": "4"
}
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 21,
"end": 22,
"value": 5,
"raw": "5"
}
}
}

View File

@ -1,41 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 13,
"operator": "*",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 1,
"raw": "1"
},
"right": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 8,
"end": 13,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 8,
"end": 9,
"value": 2,
"raw": "2"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 12,
"end": 13,
"value": 3,
"raw": "3"
}
}
}

View File

@ -1,81 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 44,
"operator": "/",
"left": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 0,
"end": 22,
"operator": "*",
"left": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 0,
"end": 18,
"operator": "*",
"left": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 0,
"end": 12,
"operator": "*",
"left": {
"type": "Identifier",
"type": "Identifier",
"start": 0,
"end": 8,
"name": "distance"
},
"right": {
"type": "Identifier",
"type": "Identifier",
"start": 11,
"end": 12,
"name": "p"
}
},
"right": {
"type": "Identifier",
"type": "Identifier",
"start": 15,
"end": 18,
"name": "FOS"
}
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 21,
"end": 22,
"value": 6,
"raw": "6"
}
},
"right": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 26,
"end": 44,
"operator": "*",
"left": {
"type": "Identifier",
"type": "Identifier",
"start": 26,
"end": 36,
"name": "sigmaAllow"
},
"right": {
"type": "Identifier",
"type": "Identifier",
"start": 39,
"end": 44,
"name": "width"
}
}
}

View File

@ -1,26 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"type": "BinaryExpression",
"start": 0,
"end": 8,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 2,
"raw": "2"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 7,
"end": 8,
"value": 3,
"raw": "3"
}
}

View File

@ -1,48 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 17,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 17,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 17,
"id": {
"type": "Identifier",
"start": 6,
"end": 8,
"name": "sg"
},
"init": {
"type": "UnaryExpression",
"type": "UnaryExpression",
"start": 11,
"end": 17,
"operator": "-",
"argument": {
"type": "Identifier",
"type": "Identifier",
"start": 12,
"end": 17,
"name": "scale"
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,130 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 23,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 23,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 23,
"id": {
"type": "Identifier",
"start": 6,
"end": 13,
"name": "myArray"
},
"init": {
"type": "ArrayExpression",
"type": "ArrayExpression",
"start": 16,
"end": 23,
"elements": [
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 0,
"raw": "0"
},
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 1,
"raw": "1"
},
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 2,
"raw": "2"
},
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 3,
"raw": "3"
},
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 4,
"raw": "4"
},
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 5,
"raw": "5"
},
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 6,
"raw": "6"
},
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 7,
"raw": "7"
},
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 8,
"raw": "8"
},
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 9,
"raw": "9"
},
{
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 10,
"raw": "10"
}
]
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,88 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 80,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 5,
"end": 57,
"declarations": [
{
"type": "VariableDeclarator",
"start": 8,
"end": 57,
"id": {
"type": "Identifier",
"start": 8,
"end": 24,
"name": "firstPrimeNumber"
},
"init": {
"type": "FunctionExpression",
"type": "FunctionExpression",
"start": 27,
"end": 57,
"params": [],
"body": {
"start": 33,
"end": 57,
"body": [
{
"type": "ReturnStatement",
"type": "ReturnStatement",
"start": 43,
"end": 51,
"argument": {
"type": "Literal",
"type": "Literal",
"start": 50,
"end": 51,
"value": 2,
"raw": "2"
}
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}
}
}
],
"kind": "fn"
},
{
"type": "ExpressionStatement",
"type": "ExpressionStatement",
"start": 62,
"end": 80,
"expression": {
"type": "CallExpression",
"type": "CallExpression",
"start": 62,
"end": 80,
"callee": {
"type": "Identifier",
"start": 62,
"end": 78,
"name": "firstPrimeNumber"
},
"arguments": [],
"optional": false,
"function": {
"type": "InMemory"
}
}
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,102 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 66,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 49,
"declarations": [
{
"type": "VariableDeclarator",
"start": 3,
"end": 49,
"id": {
"type": "Identifier",
"start": 3,
"end": 8,
"name": "thing"
},
"init": {
"type": "FunctionExpression",
"type": "FunctionExpression",
"start": 11,
"end": 49,
"params": [
{
"type": "Identifier",
"start": 12,
"end": 17,
"name": "param"
}
],
"body": {
"start": 22,
"end": 49,
"body": [
{
"type": "ReturnStatement",
"type": "ReturnStatement",
"start": 32,
"end": 43,
"argument": {
"type": "Identifier",
"type": "Identifier",
"start": 39,
"end": 43,
"name": "true"
}
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}
}
}
],
"kind": "fn"
},
{
"type": "ExpressionStatement",
"type": "ExpressionStatement",
"start": 54,
"end": 66,
"expression": {
"type": "CallExpression",
"type": "CallExpression",
"start": 54,
"end": 66,
"callee": {
"type": "Identifier",
"start": 54,
"end": 59,
"name": "thing"
},
"arguments": [
{
"type": "Identifier",
"type": "Identifier",
"start": 60,
"end": 65,
"name": "false"
}
],
"optional": false,
"function": {
"type": "InMemory"
}
}
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,552 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 30,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 30,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 30,
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"name": "myBox"
},
"init": {
"type": "CallExpression",
"type": "CallExpression",
"start": 14,
"end": 30,
"callee": {
"type": "Identifier",
"start": 14,
"end": 27,
"name": "startSketchAt"
},
"arguments": [
{
"type": "Identifier",
"type": "Identifier",
"start": 28,
"end": 29,
"name": "p"
}
],
"optional": false,
"function": {
"type": "StdLib",
"func": {
"name": "startSketchAt",
"summary": "Start a sketch at a given point on the 'XY' plane.",
"description": "",
"tags": [],
"args": [
{
"name": "data",
"type": "LineData",
"schema": {
"description": "Data to draw a line.",
"anyOf": [
{
"description": "A point with a tag.",
"type": "object",
"required": [
"tag",
"to"
],
"properties": {
"tag": {
"description": "The tag.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
}
}
},
{
"description": "A point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
}
]
},
"required": true
}
],
"returnValue": {
"name": "",
"type": "SketchGroup",
"schema": {
"description": "A sketch group is a collection of paths.",
"type": "object",
"required": [
"__meta",
"id",
"position",
"rotation",
"start",
"value"
],
"properties": {
"__meta": {
"description": "Metadata.",
"type": "array",
"items": {
"description": "Metadata.",
"type": "object",
"required": [
"sourceRange"
],
"properties": {
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
}
},
"id": {
"description": "The id of the sketch group.",
"type": "string",
"format": "uuid"
},
"planeId": {
"description": "The plane id of the sketch group.",
"type": "string",
"format": "uuid",
"nullable": true
},
"position": {
"description": "The position of the sketch group.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 3,
"minItems": 3
},
"rotation": {
"description": "The rotation of the sketch group.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 4,
"minItems": 4
},
"start": {
"description": "The starting path.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
}
}
},
"value": {
"description": "The paths in the sketch group.",
"type": "array",
"items": {
"description": "A path.",
"oneOf": [
{
"description": "A path that goes to a point.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"toPoint"
]
}
}
},
{
"description": "A path that is horizontal.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type",
"x"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"horizontal"
]
},
"x": {
"description": "The x coordinate.",
"type": "number",
"format": "double"
}
}
},
{
"description": "An angled line to.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"angledLineTo"
]
},
"x": {
"description": "The x coordinate.",
"type": "number",
"format": "double",
"nullable": true
},
"y": {
"description": "The y coordinate.",
"type": "number",
"format": "double",
"nullable": true
}
}
},
{
"description": "A base path.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"base"
]
}
}
}
]
}
}
}
},
"required": true
},
"unpublished": false,
"deprecated": false
}
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,98 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 26,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 26,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 26,
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"name": "myBox"
},
"init": {
"type": "PipeExpression",
"type": "PipeExpression",
"start": 14,
"end": 26,
"body": [
{
"type": "CallExpression",
"type": "CallExpression",
"start": 14,
"end": 18,
"callee": {
"type": "Identifier",
"start": 14,
"end": 15,
"name": "f"
},
"arguments": [
{
"type": "Literal",
"type": "Literal",
"start": 16,
"end": 17,
"value": 1,
"raw": "1"
}
],
"optional": false,
"function": {
"type": "InMemory"
}
},
{
"type": "CallExpression",
"type": "CallExpression",
"start": 22,
"end": 26,
"callee": {
"type": "Identifier",
"start": 22,
"end": 23,
"name": "g"
},
"arguments": [
{
"type": "Literal",
"type": "Literal",
"start": 24,
"end": 25,
"value": 2,
"raw": "2"
}
],
"optional": false,
"function": {
"type": "InMemory"
}
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,569 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 37,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 37,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 37,
"id": {
"type": "Identifier",
"start": 6,
"end": 14,
"name": "mySketch"
},
"init": {
"type": "CallExpression",
"type": "CallExpression",
"start": 17,
"end": 37,
"callee": {
"type": "Identifier",
"start": 17,
"end": 30,
"name": "startSketchAt"
},
"arguments": [
{
"type": "ArrayExpression",
"type": "ArrayExpression",
"start": 31,
"end": 36,
"elements": [
{
"type": "Literal",
"type": "Literal",
"start": 32,
"end": 33,
"value": 0,
"raw": "0"
},
{
"type": "Literal",
"type": "Literal",
"start": 34,
"end": 35,
"value": 0,
"raw": "0"
}
]
}
],
"optional": false,
"function": {
"type": "StdLib",
"func": {
"name": "startSketchAt",
"summary": "Start a sketch at a given point on the 'XY' plane.",
"description": "",
"tags": [],
"args": [
{
"name": "data",
"type": "LineData",
"schema": {
"description": "Data to draw a line.",
"anyOf": [
{
"description": "A point with a tag.",
"type": "object",
"required": [
"tag",
"to"
],
"properties": {
"tag": {
"description": "The tag.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
}
}
},
{
"description": "A point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
}
]
},
"required": true
}
],
"returnValue": {
"name": "",
"type": "SketchGroup",
"schema": {
"description": "A sketch group is a collection of paths.",
"type": "object",
"required": [
"__meta",
"id",
"position",
"rotation",
"start",
"value"
],
"properties": {
"__meta": {
"description": "Metadata.",
"type": "array",
"items": {
"description": "Metadata.",
"type": "object",
"required": [
"sourceRange"
],
"properties": {
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
}
},
"id": {
"description": "The id of the sketch group.",
"type": "string",
"format": "uuid"
},
"planeId": {
"description": "The plane id of the sketch group.",
"type": "string",
"format": "uuid",
"nullable": true
},
"position": {
"description": "The position of the sketch group.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 3,
"minItems": 3
},
"rotation": {
"description": "The rotation of the sketch group.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 4,
"minItems": 4
},
"start": {
"description": "The starting path.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
}
}
},
"value": {
"description": "The paths in the sketch group.",
"type": "array",
"items": {
"description": "A path.",
"oneOf": [
{
"description": "A path that goes to a point.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"toPoint"
]
}
}
},
{
"description": "A path that is horizontal.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type",
"x"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"horizontal"
]
},
"x": {
"description": "The x coordinate.",
"type": "number",
"format": "double"
}
}
},
{
"description": "An angled line to.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"angledLineTo"
]
},
"x": {
"description": "The x coordinate.",
"type": "number",
"format": "double",
"nullable": true
},
"y": {
"description": "The y coordinate.",
"type": "number",
"format": "double",
"nullable": true
}
}
},
{
"description": "A base path.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"base"
]
}
}
}
]
}
}
}
},
"required": true
},
"unpublished": false,
"deprecated": false
}
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,98 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 28,
"body": [
{
"type": "ExpressionStatement",
"type": "ExpressionStatement",
"start": 0,
"end": 28,
"expression": {
"type": "CallExpression",
"type": "CallExpression",
"start": 0,
"end": 28,
"callee": {
"type": "Identifier",
"start": 0,
"end": 3,
"name": "log"
},
"arguments": [
{
"type": "Literal",
"type": "Literal",
"start": 4,
"end": 5,
"value": 5,
"raw": "5"
},
{
"type": "Literal",
"type": "Literal",
"start": 7,
"end": 14,
"value": "hello",
"raw": "\"hello\""
},
{
"type": "Identifier",
"type": "Identifier",
"start": 16,
"end": 27,
"name": "aIdentifier"
}
],
"optional": false,
"function": {
"type": "StdLib",
"func": {
"name": "log",
"summary": "Computes the logarithm of the number with respect to an arbitrary base.",
"description": "The result might not be correctly rounded owing to implementation details; `log2()` can produce more accurate results for base 2, and `log10()` can produce more accurate results for base 10.",
"tags": [],
"args": [
{
"name": "num",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
},
{
"name": "base",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
},
"unpublished": false,
"deprecated": false
}
}
}
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,43 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 7,
"body": [
{
"type": "ExpressionStatement",
"type": "ExpressionStatement",
"start": 0,
"end": 7,
"expression": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 0,
"end": 7,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 0,
"end": 1,
"value": 5,
"raw": "5"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 4,
"end": 7,
"value": "a",
"raw": "\"a\""
}
}
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,999 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 15,
"body": [
{
"type": "ExpressionStatement",
"type": "ExpressionStatement",
"start": 0,
"end": 15,
"expression": {
"type": "CallExpression",
"type": "CallExpression",
"start": 0,
"end": 15,
"callee": {
"type": "Identifier",
"start": 0,
"end": 4,
"name": "line"
},
"arguments": [
{
"type": "ArrayExpression",
"type": "ArrayExpression",
"start": 5,
"end": 11,
"elements": [
{
"type": "Literal",
"type": "Literal",
"start": 6,
"end": 7,
"value": 0,
"raw": "0"
},
{
"type": "Identifier",
"type": "Identifier",
"start": 9,
"end": 10,
"name": "l"
}
]
},
{
"type": "PipeSubstitution",
"type": "PipeSubstitution",
"start": 13,
"end": 14
}
],
"optional": false,
"function": {
"type": "StdLib",
"func": {
"name": "line",
"summary": "Draw a line.",
"description": "",
"tags": [],
"args": [
{
"name": "data",
"type": "LineData",
"schema": {
"description": "Data to draw a line.",
"anyOf": [
{
"description": "A point with a tag.",
"type": "object",
"required": [
"tag",
"to"
],
"properties": {
"tag": {
"description": "The tag.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
}
}
},
{
"description": "A point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
}
]
},
"required": true
},
{
"name": "sketch_group",
"type": "SketchGroup",
"schema": {
"description": "A sketch group is a collection of paths.",
"type": "object",
"required": [
"__meta",
"id",
"position",
"rotation",
"start",
"value"
],
"properties": {
"__meta": {
"description": "Metadata.",
"type": "array",
"items": {
"description": "Metadata.",
"type": "object",
"required": [
"sourceRange"
],
"properties": {
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
}
},
"id": {
"description": "The id of the sketch group.",
"type": "string",
"format": "uuid"
},
"planeId": {
"description": "The plane id of the sketch group.",
"type": "string",
"format": "uuid",
"nullable": true
},
"position": {
"description": "The position of the sketch group.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 3,
"minItems": 3
},
"rotation": {
"description": "The rotation of the sketch group.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 4,
"minItems": 4
},
"start": {
"description": "The starting path.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
}
}
},
"value": {
"description": "The paths in the sketch group.",
"type": "array",
"items": {
"description": "A path.",
"oneOf": [
{
"description": "A path that goes to a point.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"toPoint"
]
}
}
},
{
"description": "A path that is horizontal.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type",
"x"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"horizontal"
]
},
"x": {
"description": "The x coordinate.",
"type": "number",
"format": "double"
}
}
},
{
"description": "An angled line to.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"angledLineTo"
]
},
"x": {
"description": "The x coordinate.",
"type": "number",
"format": "double",
"nullable": true
},
"y": {
"description": "The y coordinate.",
"type": "number",
"format": "double",
"nullable": true
}
}
},
{
"description": "A base path.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"base"
]
}
}
}
]
}
}
}
},
"required": true
}
],
"returnValue": {
"name": "",
"type": "SketchGroup",
"schema": {
"description": "A sketch group is a collection of paths.",
"type": "object",
"required": [
"__meta",
"id",
"position",
"rotation",
"start",
"value"
],
"properties": {
"__meta": {
"description": "Metadata.",
"type": "array",
"items": {
"description": "Metadata.",
"type": "object",
"required": [
"sourceRange"
],
"properties": {
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
}
},
"id": {
"description": "The id of the sketch group.",
"type": "string",
"format": "uuid"
},
"planeId": {
"description": "The plane id of the sketch group.",
"type": "string",
"format": "uuid",
"nullable": true
},
"position": {
"description": "The position of the sketch group.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 3,
"minItems": 3
},
"rotation": {
"description": "The rotation of the sketch group.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 4,
"minItems": 4
},
"start": {
"description": "The starting path.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
}
}
},
"value": {
"description": "The paths in the sketch group.",
"type": "array",
"items": {
"description": "A path.",
"oneOf": [
{
"description": "A path that goes to a point.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"toPoint"
]
}
}
},
{
"description": "A path that is horizontal.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type",
"x"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"horizontal"
]
},
"x": {
"description": "The x coordinate.",
"type": "number",
"format": "double"
}
}
},
{
"description": "An angled line to.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"angledLineTo"
]
},
"x": {
"description": "The x coordinate.",
"type": "number",
"format": "double",
"nullable": true
},
"y": {
"description": "The y coordinate.",
"type": "number",
"format": "double",
"nullable": true
}
}
},
{
"description": "A base path.",
"type": "object",
"required": [
"__geoMeta",
"from",
"name",
"to",
"type"
],
"properties": {
"__geoMeta": {
"description": "Metadata.",
"type": "object",
"required": [
"id",
"sourceRange"
],
"properties": {
"id": {
"description": "The id of the geometry.",
"type": "string",
"format": "uuid"
},
"sourceRange": {
"description": "The source range.",
"type": "array",
"items": {
"type": "integer",
"format": "uint",
"minimum": 0.0
},
"maxItems": 2,
"minItems": 2
}
}
},
"from": {
"description": "The from point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"name": {
"description": "The name of the path.",
"type": "string"
},
"to": {
"description": "The to point.",
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"maxItems": 2,
"minItems": 2
},
"type": {
"type": "string",
"enum": [
"base"
]
}
}
}
]
}
}
}
},
"required": true
},
"unpublished": false,
"deprecated": false
}
}
}
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,169 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 36,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 36,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 36,
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"name": "myVar"
},
"init": {
"type": "CallExpression",
"type": "CallExpression",
"start": 14,
"end": 36,
"callee": {
"type": "Identifier",
"start": 14,
"end": 17,
"name": "min"
},
"arguments": [
{
"type": "Literal",
"type": "Literal",
"start": 18,
"end": 19,
"value": 5,
"raw": "5"
},
{
"type": "UnaryExpression",
"type": "UnaryExpression",
"start": 22,
"end": 35,
"operator": "-",
"argument": {
"type": "CallExpression",
"type": "CallExpression",
"start": 23,
"end": 35,
"callee": {
"type": "Identifier",
"start": 23,
"end": 29,
"name": "legLen"
},
"arguments": [
{
"type": "Literal",
"type": "Literal",
"start": 30,
"end": 31,
"value": 5,
"raw": "5"
},
{
"type": "Literal",
"type": "Literal",
"start": 33,
"end": 34,
"value": 4,
"raw": "4"
}
],
"optional": false,
"function": {
"type": "StdLib",
"func": {
"name": "legLen",
"summary": "Returns the length of the given leg.",
"description": "",
"tags": [],
"args": [
{
"name": "hypotenuse",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
},
{
"name": "leg",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
},
"unpublished": false,
"deprecated": false
}
}
}
}
],
"optional": false,
"function": {
"type": "StdLib",
"func": {
"name": "min",
"summary": "Computes the minimum of the given arguments.",
"description": "",
"tags": [],
"args": [
{
"name": "args",
"type": "[number]",
"schema": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
},
"required": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
},
"unpublished": false,
"deprecated": false
}
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,169 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 35,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 35,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 35,
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"name": "myVar"
},
"init": {
"type": "CallExpression",
"type": "CallExpression",
"start": 14,
"end": 35,
"callee": {
"type": "Identifier",
"start": 14,
"end": 17,
"name": "min"
},
"arguments": [
{
"type": "UnaryExpression",
"type": "UnaryExpression",
"start": 18,
"end": 31,
"operator": "-",
"argument": {
"type": "CallExpression",
"type": "CallExpression",
"start": 19,
"end": 31,
"callee": {
"type": "Identifier",
"start": 19,
"end": 25,
"name": "legLen"
},
"arguments": [
{
"type": "Literal",
"type": "Literal",
"start": 26,
"end": 27,
"value": 5,
"raw": "5"
},
{
"type": "Literal",
"type": "Literal",
"start": 29,
"end": 30,
"value": 4,
"raw": "4"
}
],
"optional": false,
"function": {
"type": "StdLib",
"func": {
"name": "legLen",
"summary": "Returns the length of the given leg.",
"description": "",
"tags": [],
"args": [
{
"name": "hypotenuse",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
},
{
"name": "leg",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
},
"unpublished": false,
"deprecated": false
}
}
}
},
{
"type": "Literal",
"type": "Literal",
"start": 33,
"end": 34,
"value": 5,
"raw": "5"
}
],
"optional": false,
"function": {
"type": "StdLib",
"func": {
"name": "min",
"summary": "Computes the minimum of the given arguments.",
"description": "",
"tags": [],
"args": [
{
"name": "args",
"type": "[number]",
"schema": {
"type": "array",
"items": {
"type": "number",
"format": "double"
}
},
"required": true
}
],
"returnValue": {
"name": "",
"type": "number",
"schema": {
"type": "number",
"format": "double"
},
"required": true
},
"unpublished": false,
"deprecated": false
}
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,101 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 36,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 36,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 36,
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"name": "myVar"
},
"init": {
"type": "PipeExpression",
"type": "PipeExpression",
"start": 14,
"end": 36,
"body": [
{
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 14,
"end": 19,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 14,
"end": 15,
"value": 5,
"raw": "5"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 18,
"end": 19,
"value": 6,
"raw": "6"
}
},
{
"type": "CallExpression",
"type": "CallExpression",
"start": 23,
"end": 36,
"callee": {
"type": "Identifier",
"start": 23,
"end": 29,
"name": "myFunc"
},
"arguments": [
{
"type": "Literal",
"type": "Literal",
"start": 30,
"end": 32,
"value": 45,
"raw": "45"
},
{
"type": "PipeSubstitution",
"type": "PipeSubstitution",
"start": 34,
"end": 35
}
],
"optional": false,
"function": {
"type": "InMemory"
}
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,62 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 27,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 27,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 27,
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"name": "x"
},
"init": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 10,
"end": 27,
"operator": "+",
"left": {
"type": "UnaryExpression",
"type": "UnaryExpression",
"start": 10,
"end": 15,
"operator": "-",
"argument": {
"type": "Identifier",
"type": "Identifier",
"start": 11,
"end": 15,
"name": "leg2"
}
},
"right": {
"type": "Identifier",
"type": "Identifier",
"start": 18,
"end": 27,
"name": "thickness"
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,72 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 18,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 18,
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 18,
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"name": "x"
},
"init": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 8,
"end": 18,
"operator": "*",
"left": {
"type": "Literal",
"type": "Literal",
"start": 8,
"end": 9,
"value": 1,
"raw": "1"
},
"right": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 13,
"end": 18,
"operator": "-",
"left": {
"type": "Literal",
"type": "Literal",
"start": 13,
"end": 14,
"value": 3,
"raw": "3"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 4,
"raw": "4"
}
}
}
}
],
"kind": "let"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,55 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 40,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 11,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 11,
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"name": "x"
},
"init": {
"type": "Literal",
"type": "Literal",
"start": 10,
"end": 11,
"value": 1,
"raw": "1"
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {
"0": [
{
"type": "NonCodeNode",
"start": 11,
"end": 40,
"value": {
"type": "inlineComment",
"value": "this is an inline comment",
"style": "line"
}
}
]
},
"start": []
}
}

View File

@ -1,77 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 58,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 58,
"declarations": [
{
"type": "VariableDeclarator",
"start": 3,
"end": 58,
"id": {
"type": "Identifier",
"start": 3,
"end": 4,
"name": "x"
},
"init": {
"type": "FunctionExpression",
"type": "FunctionExpression",
"start": 7,
"end": 58,
"params": [],
"body": {
"start": 13,
"end": 58,
"body": [
{
"type": "ReturnStatement",
"type": "ReturnStatement",
"start": 23,
"end": 32,
"argument": {
"type": "Identifier",
"type": "Identifier",
"start": 30,
"end": 32,
"name": "sg"
}
},
{
"type": "ReturnStatement",
"type": "ReturnStatement",
"start": 41,
"end": 50,
"argument": {
"type": "Identifier",
"type": "Identifier",
"start": 48,
"end": 50,
"name": "sg"
}
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}
}
}
],
"kind": "fn"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,136 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 55,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 26,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 26,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "obj"
},
"init": {
"type": "ObjectExpression",
"type": "ObjectExpression",
"start": 12,
"end": 26,
"properties": [
{
"type": "ObjectProperty",
"start": 14,
"end": 18,
"key": {
"type": "Identifier",
"start": 14,
"end": 15,
"name": "a"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 1,
"raw": "1"
}
},
{
"type": "ObjectProperty",
"start": 20,
"end": 24,
"key": {
"type": "Identifier",
"start": 20,
"end": 21,
"name": "b"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 23,
"end": 24,
"value": 2,
"raw": "2"
}
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 31,
"end": 55,
"declarations": [
{
"type": "VariableDeclarator",
"start": 37,
"end": 55,
"id": {
"type": "Identifier",
"start": 37,
"end": 43,
"name": "height"
},
"init": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 46,
"end": 55,
"operator": "-",
"left": {
"type": "Literal",
"type": "Literal",
"start": 46,
"end": 47,
"value": 1,
"raw": "1"
},
"right": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 50,
"end": 55,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 50,
"end": 53,
"name": "obj"
},
"property": {
"type": "Identifier",
"type": "Identifier",
"start": 54,
"end": 55,
"name": "a"
},
"computed": false
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,137 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 59,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 26,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 26,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "obj"
},
"init": {
"type": "ObjectExpression",
"type": "ObjectExpression",
"start": 12,
"end": 26,
"properties": [
{
"type": "ObjectProperty",
"start": 14,
"end": 18,
"key": {
"type": "Identifier",
"start": 14,
"end": 15,
"name": "a"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 1,
"raw": "1"
}
},
{
"type": "ObjectProperty",
"start": 20,
"end": 24,
"key": {
"type": "Identifier",
"start": 20,
"end": 21,
"name": "b"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 23,
"end": 24,
"value": 2,
"raw": "2"
}
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 32,
"end": 59,
"declarations": [
{
"type": "VariableDeclarator",
"start": 38,
"end": 59,
"id": {
"type": "Identifier",
"start": 38,
"end": 44,
"name": "height"
},
"init": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 47,
"end": 59,
"operator": "-",
"left": {
"type": "Literal",
"type": "Literal",
"start": 47,
"end": 48,
"value": 1,
"raw": "1"
},
"right": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 51,
"end": 59,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 51,
"end": 54,
"name": "obj"
},
"property": {
"type": "Literal",
"type": "Literal",
"start": 55,
"end": 58,
"value": "a",
"raw": "\"a\""
},
"computed": false
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,137 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 58,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 26,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 26,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "obj"
},
"init": {
"type": "ObjectExpression",
"type": "ObjectExpression",
"start": 12,
"end": 26,
"properties": [
{
"type": "ObjectProperty",
"start": 14,
"end": 18,
"key": {
"type": "Identifier",
"start": 14,
"end": 15,
"name": "a"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 1,
"raw": "1"
}
},
{
"type": "ObjectProperty",
"start": 20,
"end": 24,
"key": {
"type": "Identifier",
"start": 20,
"end": 21,
"name": "b"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 23,
"end": 24,
"value": 2,
"raw": "2"
}
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 31,
"end": 58,
"declarations": [
{
"type": "VariableDeclarator",
"start": 37,
"end": 58,
"id": {
"type": "Identifier",
"start": 37,
"end": 43,
"name": "height"
},
"init": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 46,
"end": 58,
"operator": "-",
"left": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 46,
"end": 54,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 46,
"end": 49,
"name": "obj"
},
"property": {
"type": "Literal",
"type": "Literal",
"start": 50,
"end": 53,
"value": "a",
"raw": "\"a\""
},
"computed": false
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 57,
"end": 58,
"value": 1,
"raw": "1"
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,153 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 63,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 26,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 26,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "obj"
},
"init": {
"type": "ObjectExpression",
"type": "ObjectExpression",
"start": 12,
"end": 26,
"properties": [
{
"type": "ObjectProperty",
"start": 14,
"end": 18,
"key": {
"type": "Identifier",
"start": 14,
"end": 15,
"name": "a"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 1,
"raw": "1"
}
},
{
"type": "ObjectProperty",
"start": 20,
"end": 24,
"key": {
"type": "Identifier",
"start": 20,
"end": 21,
"name": "b"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 23,
"end": 24,
"value": 2,
"raw": "2"
}
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 31,
"end": 63,
"declarations": [
{
"type": "VariableDeclarator",
"start": 37,
"end": 63,
"id": {
"type": "Identifier",
"start": 37,
"end": 43,
"name": "height"
},
"init": {
"type": "ArrayExpression",
"type": "ArrayExpression",
"start": 46,
"end": 63,
"elements": [
{
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 47,
"end": 59,
"operator": "-",
"left": {
"type": "Literal",
"type": "Literal",
"start": 47,
"end": 48,
"value": 1,
"raw": "1"
},
"right": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 51,
"end": 59,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 51,
"end": 54,
"name": "obj"
},
"property": {
"type": "Literal",
"type": "Literal",
"start": 55,
"end": 58,
"value": "a",
"raw": "\"a\""
},
"computed": false
}
},
{
"type": "Literal",
"type": "Literal",
"start": 61,
"end": 62,
"value": 0,
"raw": "0"
}
]
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,153 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 63,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 26,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 26,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "obj"
},
"init": {
"type": "ObjectExpression",
"type": "ObjectExpression",
"start": 12,
"end": 26,
"properties": [
{
"type": "ObjectProperty",
"start": 14,
"end": 18,
"key": {
"type": "Identifier",
"start": 14,
"end": 15,
"name": "a"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 1,
"raw": "1"
}
},
{
"type": "ObjectProperty",
"start": 20,
"end": 24,
"key": {
"type": "Identifier",
"start": 20,
"end": 21,
"name": "b"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 23,
"end": 24,
"value": 2,
"raw": "2"
}
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 31,
"end": 63,
"declarations": [
{
"type": "VariableDeclarator",
"start": 37,
"end": 63,
"id": {
"type": "Identifier",
"start": 37,
"end": 43,
"name": "height"
},
"init": {
"type": "ArrayExpression",
"type": "ArrayExpression",
"start": 46,
"end": 63,
"elements": [
{
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 47,
"end": 59,
"operator": "-",
"left": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 47,
"end": 55,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 47,
"end": 50,
"name": "obj"
},
"property": {
"type": "Literal",
"type": "Literal",
"start": 51,
"end": 54,
"value": "a",
"raw": "\"a\""
},
"computed": false
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 58,
"end": 59,
"value": 1,
"raw": "1"
}
},
{
"type": "Literal",
"type": "Literal",
"start": 61,
"end": 62,
"value": 0,
"raw": "0"
}
]
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,153 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 62,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 26,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 26,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "obj"
},
"init": {
"type": "ObjectExpression",
"type": "ObjectExpression",
"start": 12,
"end": 26,
"properties": [
{
"type": "ObjectProperty",
"start": 14,
"end": 18,
"key": {
"type": "Identifier",
"start": 14,
"end": 15,
"name": "a"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 1,
"raw": "1"
}
},
{
"type": "ObjectProperty",
"start": 20,
"end": 24,
"key": {
"type": "Identifier",
"start": 20,
"end": 21,
"name": "b"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 23,
"end": 24,
"value": 2,
"raw": "2"
}
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 31,
"end": 62,
"declarations": [
{
"type": "VariableDeclarator",
"start": 37,
"end": 62,
"id": {
"type": "Identifier",
"start": 37,
"end": 43,
"name": "height"
},
"init": {
"type": "ArrayExpression",
"type": "ArrayExpression",
"start": 46,
"end": 62,
"elements": [
{
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 47,
"end": 58,
"operator": "-",
"left": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 47,
"end": 55,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 47,
"end": 50,
"name": "obj"
},
"property": {
"type": "Literal",
"type": "Literal",
"start": 51,
"end": 54,
"value": "a",
"raw": "\"a\""
},
"computed": false
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 57,
"end": 58,
"value": 1,
"raw": "1"
}
},
{
"type": "Literal",
"type": "Literal",
"start": 60,
"end": 61,
"value": 0,
"raw": "0"
}
]
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,70 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 24,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 24,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 24,
"id": {
"type": "Identifier",
"start": 6,
"end": 12,
"name": "height"
},
"init": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 15,
"end": 24,
"operator": "-",
"left": {
"type": "Literal",
"type": "Literal",
"start": 15,
"end": 16,
"value": 1,
"raw": "1"
},
"right": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 19,
"end": 24,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 19,
"end": 22,
"name": "obj"
},
"property": {
"type": "Identifier",
"type": "Identifier",
"start": 23,
"end": 24,
"name": "a"
},
"computed": false
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,72 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 21,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 21,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 21,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "six"
},
"init": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 12,
"end": 21,
"operator": "+",
"left": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 12,
"end": 17,
"operator": "+",
"left": {
"type": "Literal",
"type": "Literal",
"start": 12,
"end": 13,
"value": 1,
"raw": "1"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 16,
"end": 17,
"value": 2,
"raw": "2"
}
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 20,
"end": 21,
"value": 3,
"raw": "3"
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,72 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 22,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 22,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 22,
"id": {
"type": "Identifier",
"start": 6,
"end": 10,
"name": "five"
},
"init": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 13,
"end": 22,
"operator": "+",
"left": {
"type": "BinaryExpression",
"type": "BinaryExpression",
"start": 13,
"end": 18,
"operator": "*",
"left": {
"type": "Literal",
"type": "Literal",
"start": 13,
"end": 14,
"value": 3,
"raw": "3"
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 1,
"raw": "1"
}
},
"right": {
"type": "Literal",
"type": "Literal",
"start": 21,
"end": 22,
"value": 2,
"raw": "2"
}
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,72 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 30,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 30,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 30,
"id": {
"type": "Identifier",
"start": 6,
"end": 12,
"name": "height"
},
"init": {
"type": "ArrayExpression",
"type": "ArrayExpression",
"start": 15,
"end": 30,
"elements": [
{
"type": "MemberExpression",
"type": "MemberExpression",
"start": 17,
"end": 25,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 17,
"end": 20,
"name": "obj"
},
"property": {
"type": "Literal",
"type": "Literal",
"start": 21,
"end": 24,
"value": "a",
"raw": "\"a\""
},
"computed": false
},
{
"type": "Literal",
"type": "Literal",
"start": 27,
"end": 28,
"value": 0,
"raw": "0"
}
]
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,122 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 54,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 26,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 26,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "obj"
},
"init": {
"type": "ObjectExpression",
"type": "ObjectExpression",
"start": 12,
"end": 26,
"properties": [
{
"type": "ObjectProperty",
"start": 14,
"end": 18,
"key": {
"type": "Identifier",
"start": 14,
"end": 15,
"name": "a"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 17,
"end": 18,
"value": 1,
"raw": "1"
}
},
{
"type": "ObjectProperty",
"start": 20,
"end": 24,
"key": {
"type": "Identifier",
"start": 20,
"end": 21,
"name": "b"
},
"value": {
"type": "Literal",
"type": "Literal",
"start": 23,
"end": 24,
"value": 2,
"raw": "2"
}
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 31,
"end": 54,
"declarations": [
{
"type": "VariableDeclarator",
"start": 37,
"end": 54,
"id": {
"type": "Identifier",
"start": 37,
"end": 43,
"name": "height"
},
"init": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 46,
"end": 54,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 46,
"end": 49,
"name": "obj"
},
"property": {
"type": "Literal",
"type": "Literal",
"start": 50,
"end": 53,
"value": "a",
"raw": "\"a\""
},
"computed": false
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,70 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 27,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 27,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 27,
"id": {
"type": "Identifier",
"start": 6,
"end": 10,
"name": "prop"
},
"init": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 13,
"end": 27,
"object": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 13,
"end": 22,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 13,
"end": 15,
"name": "yo"
},
"property": {
"type": "Literal",
"type": "Literal",
"start": 16,
"end": 21,
"value": "one",
"raw": "\"one\""
},
"computed": false
},
"property": {
"type": "Identifier",
"type": "Identifier",
"start": 23,
"end": 26,
"name": "two"
},
"computed": true
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,55 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 17,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 17,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 17,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "pt1"
},
"init": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 12,
"end": 17,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 12,
"end": 14,
"name": "b1"
},
"property": {
"type": "Identifier",
"type": "Identifier",
"start": 15,
"end": 16,
"name": "x"
},
"computed": true
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,97 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 34,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 34,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 34,
"id": {
"type": "Identifier",
"start": 6,
"end": 10,
"name": "prop"
},
"init": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 13,
"end": 34,
"object": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 13,
"end": 29,
"object": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 13,
"end": 23,
"object": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 13,
"end": 19,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 13,
"end": 15,
"name": "yo"
},
"property": {
"type": "Identifier",
"type": "Identifier",
"start": 16,
"end": 19,
"name": "one"
},
"computed": false
},
"property": {
"type": "Identifier",
"type": "Identifier",
"start": 20,
"end": 23,
"name": "two"
},
"computed": false
},
"property": {
"type": "Identifier",
"type": "Identifier",
"start": 24,
"end": 29,
"name": "three"
},
"computed": false
},
"property": {
"type": "Identifier",
"type": "Identifier",
"start": 30,
"end": 34,
"name": "four"
},
"computed": false
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,56 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 17,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 17,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 17,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "pt1"
},
"init": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 12,
"end": 17,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 12,
"end": 14,
"name": "b1"
},
"property": {
"type": "Literal",
"type": "Literal",
"start": 15,
"end": 16,
"value": 0,
"raw": "0"
},
"computed": false
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

View File

@ -1,56 +0,0 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
---
{
"start": 0,
"end": 22,
"body": [
{
"type": "VariableDeclaration",
"type": "VariableDeclaration",
"start": 0,
"end": 22,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 22,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "pt1"
},
"init": {
"type": "MemberExpression",
"type": "MemberExpression",
"start": 12,
"end": 22,
"object": {
"type": "Identifier",
"type": "Identifier",
"start": 12,
"end": 14,
"name": "b1"
},
"property": {
"type": "Literal",
"type": "Literal",
"start": 15,
"end": 21,
"value": "zero",
"raw": "'zero'"
},
"computed": false
}
}
],
"kind": "const"
}
],
"nonCodeMeta": {
"nonCodeNodes": {},
"start": []
}
}

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