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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:25:23+00:00 2026-05-24T02:25:23+00:00

When I compile the following ANTLR grammar file, conditional_expression : (logical_or_expression -> logical_or_expression) (‘?’

  • 0

When I compile the following ANTLR grammar file,

conditional_expression
    : (logical_or_expression -> logical_or_expression) ('?' expression ':' rhs=conditional_expression -> ^('?' $conditional_expression expression $rhs))?
    ;

I get the following error message.

error(132): nesC.g:769:109: reference $conditional_expression is
ambiguous; rule conditional_expression is enclosing rule and
referenced in the production (assu ming enclosing rule)

Can anybody tell me the solution to this? Thanks. 🙂

  • 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-24T02:25:24+00:00Added an answer on May 24, 2026 at 2:25 am

    ANTLR cannot decide what you mean by $conditional_expression: the rule itself, or the one you labeled $rhs.

    conditional_expression // <--- this one?
      :  (logical_or_expression -> logical_or_expression) 
         ('?' expression ':' rhs=conditional_expression -> ^('?' $conditional_expression expression $rhs))?
                               //     ^
                               //     |
                               //     +--- or this one?
      ;
    

    To get it working as you now tried, you’ll need to move rhs=conditional_expression to a rule of its own, in which case there is no ambiguous naming:

    conditional_expression
      :  (logical_or_expression  -> logical_or_expression) 
         ('?' expression ':' rhs -> ^('?' $conditional_expression expression rhs))?
      ;
    
    rhs
      :  conditional_expression
      ;
    

    But wouldn’t this also do the trick for you:

    conditional_expression
      :  (e=logical_or_expression                        -> logical_or_expression) 
         ('?' if_true=expression ':' if_false=expression -> ^('?' $e $if_true $if_false))?
      ;
    

    or:

    conditional_expression
      :  (e=logical_or_expression                                                -> logical_or_expression) 
         ('?' if_true=conditional_expression ':' if_false=conditional_expression -> ^('?' $e $if_true $if_false))?
      ;
    

    ?

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

Sidebar

Related Questions

The following compile error occurs: Parser Error Message: The 'Text' property of 'asp:ListItem' does
When I try to compile the following function I get the error. string& foo(){
When trying to compile the following file in xcode: http://openkinect.org/wiki/C%2B%2BOpenCvExample I get these errors:
When I compile the following code, I only see the error during Run-time which
I am trying to compile the following code and i am getting the error:
Tying to compile the following program with Visual Studio 10, I get lot of
I tried to compile the following .asm file in VS2008 (as part of an
When I try to compile to following code, I get two errors: Description Resource
If I compile the following code snippet with Visual C# 2010 I ALWAYS get
I could not compile the following code in Java, error is: misplaced construct(s). What's

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.