narcissus on Narwhal

2 views
Skip to first unread message

Andy Chu

unread,
Dec 12, 2009, 3:01:59 PM12/12/09
to cowber...@gmail.com, narw...@googlegroups.com
Kris, I started porting Brendan Eich's Narcissus over to Narwhal
before finding that you already started it:

http://github.com/kriskowal/narcissus

Are you using this anywhere or was it just started? I ran into these issues:

ReferenceError: "snarf" is not defined.
org.mozilla.javascript.EcmaError: ReferenceError: "snarf" is not
defined. (/home/andy/git/narwhal2/packages/narcissus/lib/narcissus/exec.js#56)

That was on Rhino -- in the code it says:

// Extensions to ECMA.
snarf: snarf, evaluate: evaluate,

The other one is that he uses "catch if" syntax, which is a
Rhino-specific extension to ECMAScript:

undefined:321: SyntaxError: Unexpected token if
} catch (e if e == BREAK && x.target == n) {
^^

so that doesn't work on v8.

Andy

Zachary Carter

unread,
Dec 13, 2009, 3:31:01 PM12/13/09
to narw...@googlegroups.com
These seem to be Spidermonkey specific extensions.

On Sat, Dec 12, 2009 at 3:01 PM, Andy Chu <an...@chubot.org> wrote:
Kris, I started porting Brendan Eich's Narcissus over to Narwhal
before finding that you already started it:

http://github.com/kriskowal/narcissus

Are you using this anywhere or was it just started?  I ran into these issues:

ReferenceError: "snarf" is not defined.
org.mozilla.javascript.EcmaError: ReferenceError: "snarf" is not
defined. (/home/andy/git/narwhal2/packages/narcissus/lib/narcissus/exec.js#56)

That was on Rhino -- in the code it says:

   // Extensions to ECMA.
   snarf: snarf, evaluate: evaluate,

Snarf is defined here: http://mxr.mozilla.org/mozilla/source/js/src/js.c#3793

It takes a relative path and returns the contents of the file. Could be redefined using fs.
 
The other one is that he uses "catch if" syntax, which is a
Rhino-specific extension to ECMAScript:

undefined:321: SyntaxError: Unexpected token if
                       } catch (e if e == BREAK && x.target == n) {
                                  ^^

so that doesn't work on v8.
This also works on Spidermonkey. It could be replaced by an if statement in the catch that re-throws on else.
 

Andy


I'll be looking deeper into Narcissus too when I have some time.

--
Zach Carter
http://zach.carter.name

Kris Kowal

unread,
Dec 13, 2009, 3:32:38 PM12/13/09
to narw...@googlegroups.com
On Sun, Dec 13, 2009 at 12:31 PM, Zachary Carter <zack....@gmail.com> wrote:
> These seem to be Spidermonkey specific extensions.

In a major commit, Andy took care of these. I've transferred
maintainer responsibilities to him in my most recent catalog.

Kris Kowal

Andy Chu

unread,
Dec 13, 2009, 3:48:16 PM12/13/09
to narw...@googlegroups.com
> I'll be looking deeper into Narcissus too when I have some time.

Cool. As Kris just mentioned, I fixed up some of these issues so now
you can execute some stuff inside Narcissus on Rhino:
http://github.com/andychu/narcissus (not on v8 yet because of "catch
if")

But I left off with testFunction broken, and I'm not sure why
testFunction is not working. It defines a function and then tries to
call it. http://github.com/andychu/narcissus/blob/master/tests/narcissus-test.js
(see bottom)

Either narcissus was broken (and I wouldn't be that surprised, it is
not that "rigorous") or I somehow messed it up in conversion to
Narwhal. I never ran it in its original state (and I didn't see any
instructions on how to do so). If anyone has done so that would be
useful information!

I was actually more interested in the parser, which seems to work
although I haven't tested that thoroughly. I saw some related work on
es-discuss: http://code.google.com/p/ecmascript-ast/

Andy

Irakli Gozalishvili

unread,
Dec 28, 2009, 1:34:01 PM12/28/09
to narw...@googlegroups.com
That's really great Andy!! Thanks a lot for this work, I'll definitely will use this in jsdoc-toolkit port I have.

BTW: just wondering why don't you use narwhal itself for building narcissus.js instead of python??
--
Irakli Gozalishvili
Web: http://rfobic.wordpress.com/
Phone: +31 614 205275
Address: Taksteeg 3 - 4, 1012PB Amsterdam, Netherlands



--

You received this message because you are subscribed to the Google Groups "Narwhal and Jack" group.
To post to this group, send email to narw...@googlegroups.com.
To unsubscribe from this group, send email to narwhaljs+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/narwhaljs?hl=en.



Andy Chu

unread,
Dec 29, 2009, 12:12:27 PM12/29/09
to narw...@googlegroups.com
On Mon, Dec 28, 2009 at 10:34 AM, Irakli Gozalishvili <rfo...@gmail.com> wrote:
> That's really great Andy!! Thanks a lot for this work, I'll definitely will
> use this in jsdoc-toolkit port I have.

So I'm basically done with the Jekyll-like static doc generator, but I
have to use it to document itself and such before I "release". I
thought about also writing a "docstring" parser for jsdoc-like docs,
but I would rather not if it already exists.

Can jsdoc-toolkit take a .js file and output a JSON file of the
docstrings? Something like:

{filename: "foo.js",
items: [
{name: "myFunction"
args: [
{name: "a", type: "int", desc: "An integer a"}
...
]
}
....
]
}

If so I think it would make sense to loosely integrate the 2 things.

The Narcissus parser doesn't retain comments though (probably not too
hard to add). It will output line/column numbers of every token
(which I haven't enabled yet, but that's easy).

Is this it? http://code.google.com/p/jsdoc-toolkit/ Or are you
porting it to Narwhal?

>
> BTW: just wondering why don't you use narwhal itself for building
> narcissus.js instead of python??

Yeah that could have been done. I guess just that Python is more
stable so I just chose it for this non-essential part.

thanks,
Andy

Reply all
Reply to author
Forward
0 new messages