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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:33:00+00:00 2026-05-15T05:33:00+00:00

I have been successfully using my code with the javascript library in the ANTLR

  • 0

I have been successfully using my code with the javascript library in the ANTLR javascript target in a few browsers, but now I want to use Rhino on the server and I am having some trouble. I have some simple java code that references the Rhino 1.7R2 release’s js-14.jar file.

Context context = Context.enter();
Scriptable scope = context.initStandardObjects();
context.evaluateReader(scope, new FileReader("C:\\antlr3-all.js"), "antlr", 1, null);

This fails with an EcmaError whose message is:

TypeError: Cannot call property namespace in object [JavaPackage org.antlr]. 
It is not a function, it is "object". (antlr#259)

The javascript line that it’s referring to is:

org.antlr.namespace("org.antlr.runtime.tree");

This org.antlr.namespace was declared as a function earlier in the file, so I am not sure what to think of this. I also don’t see that “namespace” is a reserved word in javascript or in Rhino in particular.

Here’s the declaration of org.antlr.namespace at line 56:

org.antlr.namespace = function() {
    var a=arguments, o=null, i, j, d;
    for (i=0; i<a.length; i=i+1) {
        d=a[i].split(".");
        o=org.antlr.global;

        // ANTLR is implied, so it is ignored if it is included
        for (j=0; j<d.length; j=j+1) {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }

    return o;
};

The ANTLR javascript target page mentions that Rhino is a tested platform, so I am thinking that I might just be misusing Rhino. Does anyone have any tips?

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

    TypeError: Cannot call property
    namespace in object [JavaPackage
    org.antlr].

    It takes your org.antlr as a java package and tries to make a call to the object namespace. So defining the function like this does not work.

    Defining each part of the functions namespace by itself worked for me:

    org = new function() {//Define the structure one piece at a time
        this.antlr = new function(){
             this.namespace = ''; 
             return this;
        };
        return this;
    };
    org.antlr.namespace = function() {print('Help'); return 0;}
    

    Sorry that I can’t give a more detailed answer, I don’t know mutch about javascript^^.
    I guess that since org and org.antlr are undefined you can’t assign to them.

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

Sidebar

Ask A Question

Stats

  • Questions 511k
  • Answers 511k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'll answer my own question: Turns out (obviously), that going… May 16, 2026 at 5:26 pm
  • Editorial Team
    Editorial Team added an answer Can't you set a maximum number of lines to the… May 16, 2026 at 5:26 pm
  • Editorial Team
    Editorial Team added an answer $newname = realpath(dirname(__FILE__).'/../upload').'/'.$filename; May 16, 2026 at 5:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have been using UIBinder on SmartGWT widgets rather successfully. However, I have to
I have been using Selenium Webdriver successfully with JAR downloaded from their pages or
I've successfully been able to make elements (like div's, panel's, whatever) draggable by using
I have a variable that I'm using to build a JavaScript function call, and
So far during my site development I have been storing all my jQuery functions
I've been writing tests for a while now and I'm starting to get the
So heres my problem. On the first fire of my code it works perfect
I have a web application that I am hosting, and a client of mine
In my previous web development experience I have used LAMP setups. I am trying
I have a very novice question, so apologies if the answer to this is

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.