サンプル
acorn 8.18.0: parseExpressionAt
検証済みサンプル — npm acorn 8.18.0: parseExpressionAt. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: acorn.parseExpressionAt(input, offset, options)…
sha256:09d1876f21b3e3e2b52b152f2f9b00ac4e3390c2c79cdbb48e6721c4aad5da1b
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 2
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 npm
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-26 |
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-07 |
ケース
HOW- ゴール
- verify acorn.parseExpressionAt in pkg:npm/acorn@8.18.0
- パッケージ
- シンボル
-
- acorn.parseExpressionAt
- 作成日
- 2026-08-26T11:02:16Z
コントラクト
- acorn.parseExpressionAt(input, offset, options) parses a single JavaScript expression starting at the given offset and returns an AST Node
- acorn.parseExpressionAt returns node with correct type, start, end, and expression-specific fields
- acorn.parseExpressionAt supports locations and ranges options for source mapping
- acorn.parseExpressionAt supports ecmaVersion option for modern ECMAScript syntax features
- acorn.parseExpressionAt throws SyntaxError when given invalid JavaScript syntax at the offset
ファイル
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
ソース
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify acorn.parseExpressionAt in pkg:npm/acorn@8.18.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/acorn@8.18.0
Demonstrate these symbols/APIs:
- acorn.parseExpressionAt
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:2454e3b22563855d5dbe8f805a449826580cfcb69ad5d80c0f363f44f5ecdea8","contract":["acorn.parseExpressionAt(input, offset, options) parses a single JavaScript expression starting at the given offset and returns an AST Node","acorn.parseExpressionAt returns node with correct type, start, end, and expression-specific fields","acorn.parseExpressionAt supports locations and ranges options for source mapping","acorn.parseExpressionAt supports ecmaVersion option for modern ECMAScript syntax features","acorn.parseExpressionAt throws SyntaxError when given invalid JavaScript syntax at the offset"],"goal":"verify acorn.parseExpressionAt in pkg:npm/acorn@8.18.0","kind":"HOW","packages":["pkg:npm/acorn@8.18.0"],"schemaVersion":1,"symbols":["acorn.parseExpressionAt"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/acorn@8.18.0"],"schemaVersion":1,"subject":"pkg:npm/acorn@8.18.0","symbols":["acorn.parseExpressionAt"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-acorn-parse-expression-at",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-acorn-parse-expression-at",
"version": "1.0.0",
"dependencies": {
"acorn": "8.18.0"
}
},
"node_modules/acorn": {
"version": "8.18.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
"integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
"license": "MIT",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
}
}
}
{
"name": "sample-acorn-parse-expression-at",
"version": "1.0.0",
"type": "module",
"dependencies": {
"acorn": "8.18.0"
}
}
{
"schemaVersion": 1,
"goal": "verify acorn.parseExpressionAt in pkg:npm/acorn@8.18.0",
"kind": "HOW",
"packages": [
"pkg:npm/acorn@8.18.0"
],
"symbols": [
"acorn.parseExpressionAt"
]
}
import assert from 'node:assert/strict';
import * as acorn from 'acorn';
// 1. Basic expression parsing at offset 0
{
const code = '1 + 2';
const node = acorn.parseExpressionAt(code, 0, { ecmaVersion: 2020 });
assert.equal(node.type, 'BinaryExpression');
assert.equal(node.start, 0);
assert.equal(node.end, 5);
assert.equal(node.operator, '+');
assert.equal(node.left.type, 'Literal');
assert.equal(node.left.value, 1);
assert.equal(node.right.type, 'Literal');
assert.equal(node.right.value, 2);
}
// 2. Parsing expression starting at arbitrary offset
{
const code = 'const msg = "hello " + name;';
const offset = 12; // Start of `"hello " + name`
const node = acorn.parseExpressionAt(code, offset, { ecmaVersion: 2020 });
assert.equal(node.type, 'BinaryExpression');
assert.equal(node.start, 12);
assert.equal(node.end, 27);
assert.equal(node.left.type, 'Literal');
assert.equal(node.left.value, 'hello ');
assert.equal(node.right.type, 'Identifier');
assert.equal(node.right.name, 'name');
}
// 3. Options: locations and ranges
{
const code = 'foo.bar(42)';
const node = acorn.parseExpressionAt(code, 0, {
ecmaVersion: 2020,
locations: true,
ranges: true
});
assert.equal(node.type, 'CallExpression');
assert.deepEqual(node.range, [0, 11]);
assert.ok(node.loc);
assert.equal(node.loc.start.line, 1);
assert.equal(node.loc.start.column, 0);
assert.equal(node.loc.end.line, 1);
assert.equal(node.loc.end.column, 11);
}
// 4. Modern syntax with optional chaining and nullish coalescing
{
const code = 'user?.profile?.name ?? "Anonymous"';
const node = acorn.parseExpressionAt(code, 0, { ecmaVersion: 2022 });
assert.equal(node.type, 'LogicalExpression');
assert.equal(node.operator, '??');
assert.equal(node.left.type, 'ChainExpression');
assert.equal(node.right.value, 'Anonymous');
}
// 5. Syntax error handling
{
assert.throws(
() => {
acorn.parseExpressionAt('1 +', 0, { ecmaVersion: 2020 });
},
(err) => {
assert.ok(err instanceof SyntaxError);
assert.ok(typeof err.pos === 'number');
return true;
}
);
}
console.log('All contract assertions passed successfully.');
オリジンシーダー
匿名