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

Related Questions

I have been using fullcalendar plugin successfully for a few months and suddenly ran
All these years i have been successfully using EnumServicesStatus in combination with OpenScManager (with
I have a Linq-To-Sql based repository class which I have been successfully using. I
I have successfully been using the eclipse Indigo internal browser to view my web
I have successfully been using Win32::Ole module to browser through pages and submit forms.
I have been trying to post using RestKit after I have successfully used it
I have started using https://github.com/omab/django-social-auth and been successfully able to login via twitter, google
I have been using UIBinder on SmartGWT widgets rather successfully. However, I have to
I have been successful in dynamically loading an album in SSP before, but using
We have been successfully using protobuf-net v1 in a compact framework application to handle

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.