473,545 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

use of Rhino to parse the Javascript code

Hi

I want to develop a Java application to check the syntax of Javascript
code and I am thinking about using Rhino. But I don't know where to
start and there is no document for this. Has anybody done this before?
or can Rhino be embedded in my Java application to check the syntax of
JavaScript code? I thought it is possible.

Thanks!

Feb 27 '07 #1
3 4584
ja********@gmai l.com wrote:
Hi

I want to develop a Java application to check the syntax of Javascript
code and I am thinking about using Rhino. But I don't know where to
start and there is no document for this. Has anybody done this before?
or can Rhino be embedded in my Java application to check the syntax of
JavaScript code? I thought it is possible.

Thanks!
Rhino can certainly be embedded into your application to run javascript
code. To just check syntax, it's really overkill. What you really want
to do is use a Javascript grammar to parse the code that you want to
check (you can probably find the grammar, or even the ready-made lexer
and parser, in the rhino package).

Your parser can then tell you if any errors were encountered during
parsing (indicating a syntax error).

Jeremy
Feb 27 '07 #2
On Feb 26, 6:10 pm, Jeremy <jer...@pinacol .comwrote:
jackcha...@gmai l.com wrote:
Hi
I want to develop a Java application to check the syntax of Javascript
code and I am thinking about using Rhino. But I don't know where to
start and there is no document for this. Has anybody done this before?
or can Rhino be embedded in my Java application to check the syntax of
JavaScript code? I thought it is possible.
Thanks!

Rhino can certainly be embedded into your application to run javascript
code. To just check syntax, it's really overkill. What you really want
to do is use a Javascript grammar to parse the code that you want to
check (you can probably find the grammar, or even the ready-made lexer
and parser, in the rhino package).

Your parser can then tell you if any errors were encountered during
parsing (indicating a syntax error).

Jeremy
thanks for your prompted reply!

yeah, that is what I am looking for. The class in Rhino that does the
grammer parsing so that I can reuse the class in my Java application.
But I didn't find this or its related document.

Feb 27 '07 #3
"ja********@gma il.com" <ja********@gma il.comwrote:
I want to develop a Java application to check the syntax of Javascript
code and I am thinking about using Rhino. But I don't know where to
start and there is no document for this. Has anybody done this before?
or can Rhino be embedded in my Java application to check the syntax of
JavaScript code? I thought it is possible.
Yes, it has been done before, but be warned that parsing Javascript is not
easy.

See www.jslint.com for Douglas Crockford's jslint program (or
http://codespeak.net/svn/kupu/trunk/kupu/jslint.js for my modified version
which has error messages that can be parsed by most editors, command line
arguments to suppress warnings, and works with either Rhino or Windows
CScript).
Feb 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
43520
by: Matteo | last post by:
Hy everybody. I'm not a html writer, but a sysadmin who's trying to help a user able to compile an online form with IE but not with Mozilla (Moz1.6, Ns7.1, Firefox 0.8+) due to a javascript date check. Let's go straight to the point: <script language="JavaScript"> alert("Date: "+Date.parse("2000-01-01"))
6
6065
by: nate | last post by:
Hello, Does anyone know where I can find an ASP server side script written in JavaScript to parse text fields from a form method='POST' using enctype='multipart/form-data'? I'd also like it to parse the filename. <form name='form1' method='POST' enctype='multipart/form-data' action='sub.asp'> <input type='text' name='title1'...
2
1841
by: k0t1k | last post by:
This is "newObject" method from org.mozilla.javascript.Context class. .... 01 : public final Scriptable newObject(Scriptable scope, String constructorName, Object args) 02 : { 03 : scope = ScriptableObject.getTopLevelScope(scope); 04 : Function ctor = ScriptRuntime.getExistingCtor(this, scope, 05 : constructorName);
6
2187
by: Ian Davies | last post by:
Hello I have found the following script php/java for dynamic menu lists. Where a selection from the first updates (filters items in) the other. I have modified it for my tables. However I am getting an error Parse error: parse error, unexpected T_VAR in e:\domains\i\iddsoftware.co.uk\user\htdocs\QuestionDB\Questions.php on line 42
3
20635
by: aaronwmail-usenet | last post by:
Ok, I've seen many examples of javascript parsing an XML document retrieved from a file indicated by a URL. The problem is I need to parse (usually small) xml *strings* embedded in the javascript program or generated locally, and I can't find any way to do this exposed (even though some internal part of the engine clearly is capable of...
3
1146
by: CribbsStyle | last post by:
Ok, I've got to where I can download the source code of a webpage, the problem is how do I parse this source code? I would to be able to pull the below all out of the source... Full Names The number in "javascript:profile(NUMBER)" Now as you can from the source below, Each Full Name Goes with a Number, how can I arrange this, so after...
6
2628
by: Chad Crabtree | last post by:
As I'm sure some of you already know there is quite a bit of stir on Reddit about a few Javascript Rails clones. Both of them run on Rhino, which brings me to my question. Why is it that both Trimpath and the google guy choose to run on rhino vs Spidermonky. I'm coming here as it's the only place I can think of to find a cogent answer. ...
10
8306
by: gh | last post by:
I have a short JS program that runs fine from the command line: #!/usr/bin/java org.mozilla.javascript.tools.shell.Main print("Hello World"); I saved it as HelloWorld.js. (It's the shabang that makes it a JavaScript program, not the .js.) However, if I start it from Safari or Firefox, I get the following message in the log:
0
7475
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7409
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7918
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1897
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1022
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
715
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.