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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:29:51+00:00 2026-06-10T06:29:51+00:00

This is an example grammar: grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals generate myDsl http://www.xtext.org/example/mydsl/MyDsl START: elem

  • 0

This is an example grammar:

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

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

START: elem += DOG ;

DOG:
‘DOG’ INT ‘;’ ;

terminal CAT : (‘A’..’Z’)(‘A’..’Z’)(‘A’..’Z’)’ ‘(‘0’..’9′)+;

When Xtext sees the line: DOG 1234, it can’t resolve and will give the error “mismatch input DOG 1234… expecting DOG” something like that. I thought that when Xtext encounters a keyword, it should have higher precedence than the terminal. But it seems like it’s confused. How can I fix this?

Note that DOG and CAT is used in different placed (i.e. the terminal CAT is used in other rule, but its definition conflicts with DOG rule)

  • 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-06-10T06:29:53+00:00Added an answer on June 10, 2026 at 6:29 am

    In this situation, as you can see, error is not “Expection CAT_RULE ..”. So when you write DOG1234 as an element, Xtext is not parsing it as DOG and INT , instead it is getting ‘DOG1234’ as String, then looks for DOG rule and of course DOG rule only allows “DOG” keyword.

    For example if you define DOG as another Terminal rule AFTER the CAT rule, also an element RAT ‘conflicting’ with CAT RULE and separate it’s INT value from keyword by using new line you will see all of them works.

        START: elem += DOG 
        catelem += CAT 
        ratelem += RAT;
    
        RAT:
            "RAT"INT";"
        ;
    
    
    
    terminal CAT : ('A'..'Z')('A'..'Z')('A'..'Z')' '('0'..'9')+;
    terminal DOG : "DOG"("0".."9")+";";
    

    And then usage of your new DSL example:

    DOG1234;
    CSA 1 
    RAT
    12347
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have the default example of a xtext grammar. grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
I've defined a simple Xtext grammar which looks like this (simplified): grammar org.xtext.example.mydsl.MyDsl with
While reading http://en.wikipedia.org/wiki/C_preprocessor#Multiple_evaluation_of_side_effects , I came across this example: \#define max(a,b) \ ({ typeof
This example working great because here containment is body http://jsfiddle.net/roXon/hMmbK/2/ when i use container
This example shows what I am trying to do: http://jsfiddle.net/Dqjvy/ I would like it
in this example http://sorgalla.com/projects/jcarousel/examples/static_controls.html i need an active state on li so it should
In the boost::proto manual, there is an example of a grammar that matches terminals
This example uses a StringWriter to hold the serialized data, then calling ToString() gives
This example is simplified a bit, but in my ASP.NET web page in my
this example below works when hover event is trigered and when its not, its

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.