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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:23:00+00:00 2026-05-31T00:23:00+00:00

I need to write a parser for Java programming language. I’ve seen some implementations

  • 0

I need to write a parser for Java programming language. I’ve seen some implementations (JavaCC, SableCC) and i think i can handle it.

The thing is I need to rename the variables. Could I do this using the parser?

If yes, how?

  • 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-31T00:23:01+00:00Added an answer on May 31, 2026 at 12:23 am

    You don’t need a parser if all you want to do is rename variables globally. All you need is an (island) lexer that can pick out identifiers, so that you can replace them. You can get such a lexer from any parser generator that has a Java grammar by simply ignore the parser part. That should save you a lot of trouble.

    If you try to use a parser for this, that builds an AST, it will be easy to determine the identifiers (there will IDENTIFIER tree nodes) and probably even replacing them by smashing the tree nodes. Your problem will be regenerating legal source text. Most parser generators don’t provide text-to-tree-to-text capabilities.

    If you want to rename variables according to scopes, you need a parser, and full name and type resolution. That’s way harder than a mere parser; the rules about name lookup in Java 7 are pretty complicated. Again, there are parser generators out there with Java grammars; but in this case, they won’t help you unless you want to implement that name and type resolution. You’ll find that a lot more work than you expect.

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

Sidebar

Related Questions

I need to write parser for some specific language (subset of SQL). As I
I need to write a simple parser to a sort of Domain Specific Language.
I'm working with Quickbook's IIF file format and I need to write a parser
I need to write a Java Comparator class that compares Strings, however with one
I need to write a Java client application which, when given the below URL,
I need to write a scraper in Java + Groovy.. I was wondering if
I need to write a simple parser that will convert the tokens to parser
I am writing an interpreter in Java for a domain-specific language with some scripting
I need to write a bit of SQL which parses the second word of
I need to write a little program in C that parses a string. I

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.