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 — variable or function name start with number is causing syntax error · Issue #267 · IBM/JSONata4Java

variable or function name start with number is causing syntax error  #267

New issue
Copy link
New issue
Copy link
Closed
Closed
variable or function name start with number is causing syntax error #267
Copy link

Description

@cuichenli
cuichenli
opened on May 17, 2023
Issue body actions

The code I tried:

(
  $0f = true;
  $0f
)

as the following screenshots:

image

However, this can correctly compile and execute on https://try.jsonata.org/

image

Activity

  1. wnm3 commented on May 17, 2023

    @wnm3
    wnm3
    on May 17, 2023
    Contributor
    More actions

    Our definition of variable and function ID requires starting with a letter or underscore:

    VAR_ID : '$' ID ;
    
    ID
    	: [\p{L}_] [\p{L}0-9_]*
    	| BACK_QUOTE ~[`]* BACK_QUOTE;
    

    There is a test case (token-conversion/case002.json) from jsonata.org that fails if I enable numbers for the first letter (you can experiment using "aa" as the first label and then finding $.aa, or using "a7" as the first label and then finding $.a7, but $.7a fails.

    {
        "expr": "$.7a",
        "data": {"7a":33, "a7":55, "7":88},
        "bindings": {},
        "code": "S0201"
    }
    

    I don't think we plan to fix this and question whether jsonata.org should tighten their checking.

    We use a different approach for parsing than jsonata.org so will have slight differences.

    Please close if you agree you can use different variable names starting with a letter.

  2. cuichenli
    closed this as completedon May 19, 2023
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — 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.