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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:45:59+00:00 2026-06-10T14:45:59+00:00

I have a simple little grammar which keeps giving a multiple alternatives error when

  • 0

I have a simple little grammar which keeps giving a multiple alternatives error when I try to generate Xtext artefacts.
The grammar is:

grammar org.xtext.example.hyrule.HyRule with org.eclipse.xtext.xbase.Xbase

generate hyRule (You can only use links to eclipse.org sites while you have fewer than 25 messages )

Start:
    rules+=Rule+
    ;

Rule:
    'FOR''PAYLOAD'payload=PAYLOAD'ELEMENTS' elements+=JvmFormalParameter+'CONSTRAINED' 'BY' expressions+= XExpression*;

PAYLOAD:
    "Stacons"|"PFResults"|"any"
;

And the exact error I get is:

![warning(200): ../org.xtext.example.hyrule/src-gen/org/xtext/example/hyrule/parser/antlr/internal/InternalHyRule.g:3197:2: Decision can match input such as "{RULE_ID, '=>', '('}" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
error(201): ../org.xtext.example.hyrule/src-gen/org/xtext/example/hyrule/parser/antlr/internal/InternalHyRule.g:3197:2: The following alternatives can never be matched: 2][1]

I have attached the Syntax diagram for the generated antlr grammar in antlrworks, and can clearly see the multiple alternatives(JvmFormalParameter can match RULE_ID via the JvmTypeReference or the ValidID rule).

So it looks as if JvmFormalParameter is ambiguous…Apologies for my stupidity but could someone point out what it is I’m missing? Is there some way of overcoming this ambiguity when using the JvmFormalParameter rule in my grammar?

enter image description here

  • 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-10T14:46:01+00:00Added an answer on June 10, 2026 at 2:46 pm

    The rule JvmFormalParameter is defined as

    JvmFormalParameter returns types::JvmFormalParameter:
        (parameterType=JvmTypeReference)? name=ValidID;
    

    so the type of the parameter is optional. If you use elements+=JvmFormalParameter+, you allow multiple parameters without a delimiter thus the parser cannot decide about the input sequence

    String s
    

    since both String and s could be names of two parameters or String s could be a single parameter with a type String and the name s. You should use a delimiter like

    elements+=JvmFormalParameter (',' elements+=JvmFormalParameter)*
    

    or use the rule FullJvmFormalParameter which is defined with a mandatory type reference:

    FullJvmFormalParameter returns types::JvmFormalParameter:
        parameterType=JvmTypeReference name=ValidID;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple little piece of Lua code, which I wrote while
I have this simple little JavaScript snippet to try and protect my email address
I have a simple little code fragment that is frustrating me: HashSet<long> groupUIDs =
I am writing a simple little DSL for specifying constraints on messages, and Have
A little stuck here. I have a simple question I guess. Given the following
I have a little problem with a simple vbScript. The script has to run
This is a very simple question yet I have little knowledge in Linux and
I have simple class with width and height member fields which define number of
I have this simple little batch file program that I wrote but it fails
I'm writing a simple little application, which is a booking system. In the system

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.