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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:59:04+00:00 2026-06-02T06:59:04+00:00

I have the following function definitions in the same .js file (call it A.js)

  • 0

I have the following function definitions in the same .js file (call it A.js)

function PParser() {
....
makeExpression = function (lexemes, index) {

    return makeNumber(lexemes, index);
}

makeDeclaration = function(lexemes, index)
{
    if (lexemes[index].TokenType != LALLPLexer.VAR) {
        throw "Expected VAR at index " + index;
    }

    if (lexemes[index + 1].TokenType != LALLPLexer.ID) {
        throw "Expected ID at index " + index + 1;
    }

    if (lexemes[index + 2].TokenType != LALLPLexer.ASSIGN) {
        throw "Expected ASSIGN at index " + index + 2;
    }

    var expressionNodeResult = makeExpression(lexemes, index + 3);

...

when the “makeExpression” invocation is reached, I was expecting control flow to move to the function defined just above. However, instead, another function named “makeExpression” is called in a completely different .js file (B.js).

 function Controller()
{
...

this.parseToStatement = function(statementText)
{
    makeExpression = function(expressionNode)
    {
        return new IntLiteral(expressionNode.Content);
    }

    try {
        statement = parser.parseStatement(new LALLPLexer().lex(statementText));

        if (statement.NodeType == LALLPParser.DECLARATION) {

            return new Declaration(statement.Id, makeExpression(statement.Expression));
        }
    }
    catch (exception) {
        statement = new UnknownStatement(statementText);
    }

    return statement;
}
}

I’m not sure why. Interestingly enough, the line “parseStatement” shown above is up the call chain from the “makeExpression” invocation. Is this correct javascript behavior and, if so, why should I expect this behavior? How can I get the intended behavior?

  • 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-06-02T06:59:05+00:00Added an answer on June 2, 2026 at 6:59 am

    I’m not entirely sure about this, but I think js doesn’t make variables local by standard, so all those functions might be attached globally (To the window variable) and hence may overwrite each other.

    Try adding var to all of those definitions (or this.where appropriate). Maybe that will help.

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

Sidebar

Related Questions

I have the following C++ function definition, which I am trying to call through
i have following function but it is not working in IE. and please tell
I have following function into to get the text between tags but it is
i have following function where i have brands info in an array. i should
I have the following function in C#: public string getRowKey(string topic, string rk) {
I have the following function to convert a byte array of pixels into an
I have the following function which in words should take user credentials and validate
I have the following function function availableChatRoom($topic_id){ $max_rooms = 2; $max_users = 2; $sqli
I have the following: function refreshGrid(entity) { var store = window.localStorage; var partitionKey; ...
I have the following function: function getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key,

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.