Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6924079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:37:03+00:00 2026-05-27T10:37:03+00:00

In my DSL variables are dynamic, they are created the first time a value

  • 0

In my DSL variables are dynamic, they are created the first time a value is assigned to them. So this is a valid code:

a = 0
b = 2 // new variable created
a = 3 // existing variable reassigned

My naive approach is to have rules like this

Identifier:
  ID; // ID from Terminals

Assignable:
  {Assignable} ref=[Identifier|ID] |
  {Assignable} newVar=Identifier;

It doesn’t work, complaining “The following alternatives can never be matched: 2”. It’s understandable, because the generated Antlr debug grammar contains a rule:

ruleAssignable: ruleIdentifier | ruleIdentifier;

(The trick of [Identifier|ID] comes from a response to a question on cross-referencing. I just copied it without fully understanding 🙂 I also tried to grok how it’s solved in the Xbase grammar:

{XAssignment} /* (declaringType=[types::JvmDeclaredType] '::')? */ feature=[types::JvmIdentifiableElement|ValidID] OpSingleAssign value=XAssignment

It seems to use only cross-referencing, and I can’t see how new variable declaration is handled.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:37:04+00:00Added an answer on May 27, 2026 at 10:37 am

    It’s not a particularly good idea to use the same syntax for a variable declaration and an assignment expression. If possible I’d introduced a keyword or a special operator for the declaration.

    In case you can’t or don’t want to do that, the hard way would be to decide on either a cross-reference or a simple identifier.

    If you go with the first, you’ll have to disable error messages for unresolved references.
    If you choose the latter, you’ll have to pimp content assist and hyperlinking manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DSL Java object, i.e. a POJO which returns this in setters
I'm working on a DSL in Microsoft's new M Grammar, and it needs to
There's a new dsl in capybara 1.0.0.rc1 that's very similar to steak. I'm trying
I have a groovy DSL script like this: entity(attribute1:one, attribute2:two) so far so good.
I have a problem constructing a DSL in Clojure. This is the concrete problem
What Is the exact use of DSL? Is it worth time spending on reading
In order to create a DSL for my new Scala project I've written the
I'm developing a DSL using Eclipse's Xtext framework. For the content assist/code completion, I
I've created a router in PHP which takes a DSL (based on the Rails
we have .dsl file with below entry [condition][]residence duration >\= {value}=FamilyMember(basicInfo.permanentResidenceDuration >= {value}) Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.