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 6321777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:12:44+00:00 2026-05-24T16:12:44+00:00

I am developing my own DSL in XText. I want do something like this:

  • 0

I am developing my own DSL in XText.

I want do something like this:

1 AND (2 OR (3 OR 4))

Here my current .xtext file:

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
    (greetings+=CONDITION_LEVEL)
;

terminal NUMBER :
    ('1'..'9') ('0'..'9')*
;

AND:
    ' AND '
;

OR:
    ' OR '
;

OPERATOR : 
    AND | OR
;

CONDITION_LEVEL:
    ('('* NUMBER (=>')')* OPERATOR)+ NUMBER ')'*
;

The problem I am having is that the dsl should have the possibility to make unlimited bracket, but show an error when the programmer don’t closes all opened bracket.

example:

1 AND (2 OR (3 OR 4)

one bracket is missing –> should make error.

I don’t know how I can realize this in XText. Can anybody help?

thx for helping.

  • 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-24T16:12:44+00:00Added an answer on May 24, 2026 at 4:12 pm

    Try this:

    CONDITION_LEVEL
      :  ATOM ((AND | OR) ATOM)*
      ;
    
    ATOM 
      :  NUMBER 
      |  '(' CONDITION_LEVEL ')'
      ;
    

    Note that I have no experience with XText (so I did not test this), but this does work with ANTLR, on which XText is built (or perhaps it only uses ANTLR…).

    Aslo, you probably don’t want to surround your operator-tokens with spaces, but put them on a hidden-parser channel:

    grammar org.xtext.example.mydsl.MyDsl hidden(SPACE)
    
    ...
    
    terminal SPACE : (' '|'\t'|'\r'|'\n')+;
    
    ...
    

    Otherwise source like this would fail:

    1 AND(2 OR 3)
    

    For details, see Hidden Terminal Symbols from the XText user guide.

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

Sidebar

Related Questions

I'm currently developing my own AuthorizationManager, it looks something like that: public class MyAuthorizationManager
I'm developing own CMS and i want to implement functionality to dynamically include existing
I'm developing my own OS, but for this I need to touch on linking,
I have just started with wordpress and want to start developing my own themes.
I'm developing a game. I want to have game entities each have their own
I am developing my own class model for my database and I would like
I am developing my own PHP Library and I would like to call RESTful
I was thinking about developing an own file archive format to use for private
Let's say you're developing your own stackoverflow in ASP.NET MVC :-) You'd like to
When developing my own Java class to use within ColdFusion 8 I stumble upon

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.