473,725 Members | 1,740 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 4595
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
43536
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
6104
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' value='value1'> <input type='file' name='file1'>
2
1853
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
2198
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
20641
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 doing it). Am I missing something?
3
1153
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 parsing I know which number
6
2641
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. My guess since I have thought about it is to leverage Java libraries. Would that be the only...
10
8332
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
8747
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9392
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9246
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9162
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6694
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5997
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3211
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
2
2619
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.