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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:49:20+00:00 2026-05-26T18:49:20+00:00

I am attempting to parse javascript (using javascript), and I’ve run into a problem

  • 0

I am attempting to parse javascript (using javascript), and I’ve run into a problem with objects. How does javascript determine the difference between an object or a block?

For instance

{ x : 1, y : 2}

Token Stream:

[{][x][:][1][,][y][:][2][}]

Is clearly an object, however

{ var x = 1; var y = 2}

Token Stream:

[{][var][x][=][1][;][var][y][=][2][}]

Is a perfectly valid anonymous javascript block. How would I go about efficiently identifying each token stream as an object or block?

However, more important then both of these how would I determine the difference between a token stream that could be an object or a block like the following:

{ a : null }

Token Stream:

[{][a][:][null][}]

This could either be an object whose parameter a is equal to null, or it could be a block where the first statement in the block (null) has a label (a)

  • 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-26T18:49:21+00:00Added an answer on May 26, 2026 at 6:49 pm

    You don’t.

    The context of the syntax affects it’s identity. You can’t just pluck things out of context and determine what they are.

    In the grammar, an object literal is:

    '{' (propertyNameAndValueList)? '}'
    

    whereas a block is:

    '{' (statementList)? '}'
    

    But literals only exist where expressions are allowed, while blocks exist where statements are allowed. And those aren’t the same thing.

    So, it’s the surrounding context that distinguishes the two forms.

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

Sidebar

Related Questions

I am attempting to parse a XML file using Javascript and I'm running into
I'm attempting to parse load a rather complicated XML schema into a Schema object
I am attempting to parse the following String into a DateTime object in c#:
I'm attempting to parse some Wiki-style markup using the Javascript Creole Wiki Markup Parser
I am attempting to parse a string like the following using a .NET regular
I have become accustomed to using TryParse for attempting to parse unknown types: Dim
I'm attempting to parse a JSON feed using the LastFM API but there are
I'm attempting to parse a set of CSV data using PHP, but having a
I'm attempting to parse an Oracle trace file using regular expressions. My language of
I am attempting to parse a text (CSS) file using fscanf and pull out

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.