Skip to content

Fix single-element array parsing: enable R = [10] syntax #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 13, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 1, 2025

Problem

Single-element arrays could not be created in Yaksok. Code like R = [10] would fail to parse, preventing users from creating arrays with just one element.

Root Cause

The parser only had rules for:

  • Empty arrays: []
  • Multi-element arrays: [item1, item2, ...] (via comma-separated Sequence)

There was no parsing rule to handle single-element arrays like [10].

Solution

Added a new parsing rule in /core/prepare/parse/rule.ts to handle the [ Evaluable ] pattern:

{
    pattern: [
        { type: Expression, value: '[' },
        { type: Evaluable },
        { type: Expression, value: ']' },
    ],
    factory: (nodes, tokens) => {
        const item = nodes[1] as Evaluable
        return new ListLiteral([item], tokens)
    },
}

The rule is positioned before the existing [ Sequence ] rule to ensure single-element arrays are matched first.

Test Coverage

Added comprehensive test cases covering different data types:

R = [10]       # number array
S = ["hello"]  # string array  
T = [3.14]     # float array
U = [true]     # boolean array

All existing array functionality remains unchanged - empty arrays [] and multi-element arrays [1, 2, 3] continue to work as before.

Fixes #93.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • canonical-bos01.cdn.snapcraftcontent.com
  • dl.deno.land
    • Triggering command: curl -s REDACTED (dns block)
    • Triggering command: curl --fail --location --progress-bar --output /home/REDACTED/.deno/bin/deno.zip REDACTED (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI assigned Copilot and rycont Jul 1, 2025
Copy link

cloudflare-workers-and-pages bot commented Jul 1, 2025

Deploying dalbit-yaksok with  Cloudflare Pages  Cloudflare Pages

Latest commit: d5d4ff4
Status: ✅  Deploy successful!
Preview URL: https://8bf92e46.yaksok-ts.pages.dev
Branch Preview URL: https://copilot-fix-93.yaksok-ts.pages.dev

View logs

@Copilot Copilot AI changed the title [WIP] 원소가 하나인 배열을 생성할 수 없음 Fix single-element array parsing: enable R = [10] syntax Jul 1, 2025
@Copilot Copilot AI requested a review from rycont July 1, 2025 00:22
Copilot finished work on behalf of rycont July 1, 2025 00:22
@rycont rycont marked this pull request as ready for review July 13, 2025 06:57
Copy link
Owner

@rycont rycont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rycont rycont merged commit 63a415d into main Jul 13, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

원소가 하나인 배열을 생성할 수 없음
2 participants