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

  • Home
  • SEARCH
  • 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 5930967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:37:41+00:00 2026-05-22T14:37:41+00:00

I have a grammar file for a new general-purpose programming language I’m trying to

  • 0

I have a grammar file for a new general-purpose programming language I’m trying to build. I’m trying to make the language robust and natural to use (it is heavily inspired by Ruby, among others), and in doing so I have introduced some left-recursive rules.

I’ve seen some examples that seem to indicate the following left-recursive rule:

rule l_recurse
  l_recurse / 'something else'
end

can be made non-left-recursive by changing it to:

rule r_recurse
  'something else' / r_recurse
end

To me this looks like it would have the a different problem and would still fail. Am I right, or will this “just work”?

The specific left-recursions I’m trying to (find and) eliminate are found in this grammar file. I’m not sure which rules are affected, but at least some were pointed out to have left-recursion. (By the way I have tried to eliminate the specific range issue he mentioned by tightening up range’s 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-05-22T14:37:42+00:00Added an answer on May 22, 2026 at 2:37 pm

    The particular case

    rule l_recurse
      l_recurse / 'something else'
    end
    

    simplifies to

    rule l_recurse
       'something_else'
    end
    

    (and so does the right recursion rule) so I need to see your specific example to find out what you want to know. The answer to this question gives the general rule for left recursion elimination.

    One of the typical easy-to-remove left recursion cases is lists:

    rule l_list
        item | l_list ',' item
    end
    

    and that can be changed to right recursion

    rule r_list
        item r_tail?
    end
    
    rule r_tail
        ',' r_list
    end
    

    (which is a special case of the general recursion elimination).

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

Sidebar

Related Questions

I have an ANTLR grammar file as part of a C# project file and
I have to define the grammar of a file like the one shown below.
Using Flex and Bison, I have a grammar specification for a boolean query language,
I have the following context free grammar in a text file 'grammar.txt' S ::=
I have a file with the following grammar: <whitespace_sequence><string><whitespace_sequence><--More--><whitespace_sequence><string_sequence><newline> Using Python (2.4), I would
i have shared the header file containing class definition of a Context Free grammar
I have a text file which I'm trying to parse. The file looks like
I have lexer/parser (Generated from an ANTLR grammar file) which (for performance reasons) I
I'm trying to parse a txt file that represents a grammar to be used
I have written following ParserRule in my Xtext grammar file: TestSpec: '{' ...... (('my'

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.