GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implement tuple projection shorthand · Issue #34 · Seddryck/Expressif.Syntax

Implement tuple projection shorthand #34

New issue
Copy link
New issue
Copy link
Closed
#41
Closed
Implement tuple projection shorthand#34
#41
Copy link
Labels
new-feature

Description

@Seddryck
Seddryck
opened on Aug 13, 2026
Issue body actions

Description

Implement tuple projection shorthand as first-class syntax.

Expressif uses $ to select an element from the current tuple. The syntax parser should preserve this surface form in the CST instead of lowering it directly to a tuple-at(...) function call.

Examples:

$0
$1
$2
$^0

The shorthand may appear anywhere an expression is accepted, including pipelines and function arguments.

Syntax model

Add a dedicated syntax node:

ExpressionSyntax
└── TupleProjectionSyntax
    ├── direction: FromStart | FromEnd
    └── index: integer

The exact representation may differ, but the CST must distinguish tuple projection from an ordinary function call.

For example:

$0

should conceptually produce:

TupleProjectionSyntax
├── direction: FromStart
└── index: 0

and:

$^0

should produce:

TupleProjectionSyntax
├── direction: FromEnd
└── index: 0

Syntax

Projection from the beginning uses:

$0
$1
$2
$10

Projection from the end uses:

$^0
$^1
$^2

$0 means the first tuple element. $^0 means the last tuple element.

The parser only recognizes the syntax. Whether an index is valid for a particular tuple belongs to semantic validation.

Usage in expressions

Examples:

$0
$0 | upper
$1 | add(5)
foo($0)
foo($^0)

Tuple projection should compose with the same pipeline and argument grammar as other expressions.

Distinction from other access syntax

Tuple projection is distinct from record access and original-input references.

Examples:

.name    // current record field access
^.name   // original input record field access
$0       // first tuple element
$^0      // last tuple element

The grammar must preserve these as different syntax nodes.

No lowering in the parser

The current Expressif parser lowers tuple projection shorthand to a semantic function such as tuple-at.

The Tree-sitter grammar should not do that.

For example:

$1

must remain TupleProjectionSyntax in the CST. A later binding/lowering layer may translate it to the semantic equivalent of:

tuple-at(1)

Likewise, end-relative projection should be interpreted by the semantic layer rather than rewritten by the grammar.

Whitespace

Whitespace around the complete shorthand is insignificant:

$0
  $0
$0  

Whitespace inside the shorthand is not allowed:

$ 0
$ ^0
$^ 0

Out of scope

Do not implement or special-case:

  • runtime tuple arity validation;
  • bounds validation;
  • record field access;
  • array element access;
  • map shorthand;
  • unary expressions;
  • binary expressions;
  • semantic lowering to tuple-at.

Tests

Add Tree-sitter corpus tests covering at minimum:

  • $0;
  • multi-digit indexes;
  • $^0;
  • end-relative multi-digit indexes;
  • tuple projection as a root/open expression;
  • tuple projection in a pipeline;
  • tuple projection as a function argument;
  • distinction from field access syntax;
  • surrounding whitespace;
  • malformed $ syntax;
  • malformed $^ syntax.

Tests should assert CST structure, not only parse success.

Architectural constraint

Tuple projection shorthand is syntax, not a function call.

The parser must preserve the user's source form. Any normalization to tuple-at or equivalent semantic operation belongs to the binding/lowering layer.

Activity

  1. Seddryck
    added
    new-feature
    on Aug 13, 2026
  2. Seddryck
    closed this as completedin #41on Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    new-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.