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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:35:34+00:00 2026-05-31T05:35:34+00:00

My grammar is something like this ifStatment ::= IF PARETHESIS logicOperation PARENTHESIS_ KEY procedures

  • 0

My grammar is something like this

ifStatment      ::= IF PARETHESIS logicOperation PARENTHESIS_ KEY procedures KEY_ elseIfStatment;

elseIfStatment  ::= ELSE IF PARENTHESIS logicOperation PARENTHESIS_ KEY procedures KEY_ elseIfStatment  
                    |elseStatment;

elseStatment    ::= ELSE KEY procedures KEY_
                    | ;

“logicOperation” returns true/false value, and “procedures” is what I want to do if “logicOperation” is true.

I was tinking of using the cup stack in “procedures” production to check if “logicOperation” is true.

It would work if there was only an “elseStatment” and not “elseIf”, but with the elseIf I could’nt know the exact position of logicOperation in the stack.

What should I do?

  • 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-31T05:35:35+00:00Added an answer on May 31, 2026 at 5:35 am

    I was doing it wrong, thats not how a parser works.
    There are two ways of doing it:

    1. Abstract Syntax Tree: Save the procedures and execute after parsing

    2. Three addres code: traduce the code to something else, like assembler.

    But if someone still needs to make it, the way to go is using inherited attributes, something that java-cup doesn’t have, so use bison and c.

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

Sidebar

Related Questions

I have an Xtext grammar that does something like this: Model: (names += Name)*
My grammar is something like this decl: attributes; {/*create an object here with the
With ANTLR2, you could define something like this in grammar definition file: options {
I have this grammar and need to modify it to allow parenthesis like: (-1)
Let's say I have a grammar defined to something like: some_rule := a b
I have this simple grammar for a C# like syntax. I can't figure out
How do you do something like this with ANTLR? Example input: title: hello world
Say I have a Boost Spirit grammar like this, where a parent rule passes
I am developing my own DSL in XText. I want do something like this:
perhaps I'm asking the wrong question. I have code like this: class ExpressionGrammar(Grammar): def

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.