473,388 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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 4568
ja********@gmail.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...@gmail.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********@gmail.com" <ja********@gmail.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
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...
6
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...
2
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 : ...
6
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...
3
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...
3
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...
6
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...
10
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.