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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:28:40+00:00 2026-05-31T12:28:40+00:00

I am writing some bottom-up parsers for PHP, JavaScript, and CSS. Preferably, I would

  • 0

I am writing some bottom-up parsers for PHP, JavaScript, and CSS. Preferably, I would like to write one parser that will be able to parse all the languages. I heard somewhere that JavaScript could be parsed with an LALR(1) parser (correct me if I’m wrong, however). Would a LALR(1) parser be sufficient for PHP and CSS, or will I need to write something different?

  • 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-31T12:28:42+00:00Added an answer on May 31, 2026 at 12:28 pm

    I doubt you can implement one parser to parse all 3 of these languages. I think you’ll need 3 parsers. They may share the parsing engine, if that’s what you mean.

    You can make pretty much any parsing technology parse any language, by accepting “too much” (because the parsing machinery isn’t strong enough to discriminate) and adding post-parsing processing of the captured structure (typically ASTs) to inspect/handle/eliminate the excess accepted.

    The argument is is just how much excess you have to collect, and how painful is it to eliminate the excess accepted.

    So, LALR(1) will do it. There are existence proofs, too; the PHP interpreter is implemented using Bison (LALR(1)); you can discover this for yourself by downloading the PHP tarball and digging around in it.

    I don’t think CSS is a tough grammar. I think there’s a lot of it, though.

    JavaScript will give you a bad time with the missing semicolon problem, because it is defined as “if the parser would give you a error without it, and it is not present, pretend it is present”. So in essence you have to abuse the error handling machinery in the parser to recover.

    You’re looking at a lot of work. Wouldn’t it be easier to get existing parsers? Or do you want one unified set of machinery for a reason?

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

Sidebar

Related Questions

I am writing some css code for a school website that looks like this
So I was writing some code today that basically looks like this: string returnString
I'm currently writing a web application in HTML5/Javascript and PHP. Some employees of the
Just writing some CSS and I have a pretty cool Search form where you
I'm writing some data acquisition software and need a gui plotting library that is
I'm writing some custom Comparators, and I'd like them to push null items to
I am finding I'm writing a lot of code that looks like this: <div
Writing some test scripts in IronPython, I want to verify whether a window is
While writing some C code, I decided to compile it to assembly and read
Im writing some helper functions for a project im working on. I've always wanted

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.