473,394 Members | 1,094 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,394 software developers and data experts.

JavaScript parser in lex+yacc or jflex+byacc/j

does anyone know of a "reasonably practical" yacc-type parser for
JavaScript?

in the absence of one, i will endevour to write my own starting from
the BNF specification:

http://www.ecma-international.org/pu...T/Ecma-262.pdf

any help/pointers gratefully received...

May 23 '06 #1
7 12025
VK

macabstract wrote:
does anyone know of a "reasonably practical" yacc-type parser for
JavaScript?


http://www.jslint.com

.... unless what does "reasonably practical" mean to you?

May 23 '06 #2
i need a lexer/parser in a high-level parsing language such as lex/yacc
rather than a coded-from-scratch one in C/Java/JS (as is the case with
jslint).

my motivation is to write a JavaScript/AJAX obfuscation utility to
mangle variable names between JavaScript and the server-side language
(typically Java/C#).

by "reasonably practical" (apologies for my vagueness), i meant that
the grammar used should be consistent with JavaScript used in popular
browsers such as Mozilla and IE.

May 24 '06 #3
macabstract wrote:
my motivation is to write a JavaScript/AJAX obfuscation utility to
mangle variable names between JavaScript and the server-side language
(typically Java/C#).
What should this be good for?
by "reasonably practical" (apologies for my vagueness), i meant that
the grammar used should be consistent with JavaScript used in popular
browsers such as Mozilla and IE.


Unlike Mozilla and other Gecko-based UAs, IE supports JScript, not
JavaScript. Furthermore, JavaScript and JScript are ECMAScript
implementations that extend the specified language; probably you
will have to take several peculiarities of those languages into
account.
PointedEars
--
#define QUESTION ((bb) || !(bb))
// William Shakespeare (if he would have been a hacker ;-))
May 25 '06 #4
Thomas 'PointedEars' Lahn wrote:
Unlike Mozilla and other Gecko-based UAs, IE supports JScript, not
JavaScript. Furthermore, JavaScript and JScript are ECMAScript
implementations that extend the specified language;


When the implementations were created before the standard existed, is it
really accurate to say they are implementations of the standard? That's
putting the cart before the horse.

Shouldn't you say that ECMAScript is a proposed standard which attempts to
unify, extend, and standardize Javascript and JScript into a language
definition that encapsulates most of the functionality of each and provides
a starting point for future new implementations and changes to Javascript
and JScript?

Repeatedly parroting that "Javascript and JScript are ECMAScript
implementations" is a bit misleading, IMO.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
May 25 '06 #5
"macabstract" <ma*********@yahoo.co.uk> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
does anyone know of a "reasonably practical" yacc-type parser for
JavaScript?

in the absence of one, i will endevour to write my own starting from
the BNF specification:

http://www.ecma-international.org/pu...T/Ecma-262.pdf

any help/pointers gratefully received...


The DMS Software Reengineering Toolkit has excellent parsers for
Javascript. It is frankly a lot of work to get the details for the
various
Javascript dialects right. DMS also provides considerable
support for custom analysis or transformation on the parsed
code.

We use DMS + these grammars to provide JavaScript source formatting tools,
obfuscation tools (which some folks in this group just can't
get over) and other tools that require deep, detailed access to the
JavaScript
(and/or the HTML page in which it is often embedded),
such as clone detection. An example next tool on which we are
working would be test coverage for JavaScript;
we've already delivered test coverage tools for half a dozen
other languages using DMS.

See http://www.semanticdesigns.com/Produ...MSToolkit.html
--
Ira Baxter, CTO
www.semanticdesigns.com
May 25 '06 #6
Matt Kruse said the following on 5/25/2006 3:50 PM:
Thomas 'PointedEars' Lahn wrote:
Unlike Mozilla and other Gecko-based UAs, IE supports JScript, not
JavaScript. Furthermore, JavaScript and JScript are ECMAScript
implementations that extend the specified language;
When the implementations were created before the standard existed, is it
really accurate to say they are implementations of the standard? That's
putting the cart before the horse.


Thats putting the cart before the wheel before the horse.
Shouldn't you say that ECMAScript is a proposed standard which attempts to
unify, extend, and standardize Javascript and JScript into a language
definition that encapsulates most of the functionality of each and provides
a starting point for future new implementations and changes to Javascript
and JScript?
But then they all repeat the "But the website says it is an ECMAScript
implementation".
Repeatedly parroting that "Javascript and JScript are ECMAScript
implementations" is a bit misleading, IMO.


It is very misleading.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 25 '06 #7
Matt Kruse wrote:
<snip>
When the implementations were created before the
standard existed, is it really accurate to say they
are implementations of the standard? That's putting
the cart before the horse.

<snip>

When pre-existing JavaScript(tm) and JScript implementations have
changed in a way that brings them into line with ECMA 262 editions, and
then been claimed by their authors to be ECMAScript implementations,
shoudn't we accept that that is what they are.

The significant differences between JavaScript(tm) 1.2 and 1.3, where
the latter brought JavaScript(tm) into line with ECMA 262, 2nd Ed. being
an obvious example. The introduction of previously absent
properties/methods into JScript 5.6 to bring it into line with ECMA 262,
3rd Ed. being another.

Richard.
May 25 '06 #8

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

Similar topics

18
by: Moonlit | last post by:
Hi, I am searching for the best lex and yacc combination (or something similar) that can be used in combination with C++ and that can contain C++ code. I have the regular flex/bison port working...
28
by: Yuri CHUANG | last post by:
"No newline at the end of your output" is really a problem? I've never learned that before. So I desire to know some tips about writting a program perfectly.Can anyone give me some tips which are...
5
by: alebcn75 | last post by:
Hello, I'm trying to solve the following issue which is puzzling me. I have a concrete class, say Parser, which provides some basic parsing functionality (such as reading word by word, line by...
27
by: Dave | last post by:
I'm having a hard time tying to build gcc 4.3.1 on Solaris using the GNU compilers. I then decided to try to use Sun's compiler. The Sun Studio 12 compiler reports the following code, which is in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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.