You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by <mb...@my-Deja.com> on 2000/07/25 01:35:27 UTC

VBScript parser (was Re: Apache::ASP Question)

--

On Mon, 24 Jul 2000 13:19:51   Joshua Chamas wrote:
>Until I write a VBScript to perl parser, yes you can only
>use perl under Apache::ASP.

Ok, so are you actually going to write a VBScript to perl parser?  I was actually thinking of undertaking this project myself, but I've never written a lexer or a parser or anything like that.  If you _are_ going to do this I'd be glad to help.  If not, I'm probably going to get started with it anyways.  I realized a huge need for something like this since I've been working on a large site (high volume + large codebase) converting from WinNT/ASP to Solaris/Perl/CGI (with mod_perl of course).  I've written a _really_ simple script that converts stuff like "For i = 1 To 10" to "for (1..10) {" etc., but it's of course really flaky and unreliant (although it knocks out about 90% of the manual code conversion).

Ok, so what was the point again??  Oh yeah, are you really going to do this?  :-)  Or is someone else already in the process?

- Matt Barnicle


--== Sent via Deja.com http://www.deja.com/ ==--
Before you buy.

Re: VBScript::Parser

Posted by Ime Smits <im...@iae.nl>.
| To a VBScript parser it should die. So you could define the concept of how
| to write "$response->write( ... );" in other languages somehow, in the
| actual class that implements (or calls) the parser. That way pluging in a
| JScript parser becomes easier, and you could even support multiple
| languages in the same file, a-la MS ASP.

Excellent thought, I will keep this multilangual approach in mind.

Ime


Re: VBScript::Parser

Posted by Matt Sergeant <ma...@sergeant.org>.
On Thu, 27 Jul 2000, Joshua Chamas wrote:

> Matt Sergeant wrote:
> > 
> > On Thu, 27 Jul 2000, Ime Smits wrote:
> > 
> > > In short, I have the following in mind and partially worked out in actual
> > > code. A package VBScript::Parser which offers:
> > >
> > >     $parser=new VBScript::Parser;
> > >     $evalable_perl_code = $parser->parse($complete_asp_page);
> > 
> > No. The problem is that it would be really great if this could be a
> > generic VBScript parser, rather than an ASP/VB parser.
> > 
> 
> ???.  This will be a generic parser for VBScript.  What I would 
> feed it from Apache::ASP is a wholly native VBScript, with all 
> the static html ASP parts compiled out already into $response->write('');
> string, or something to that effect.  Ime's VBScript parser
> will not have to know anything about static HTML bits, nor ASP
> objects, that's the beauty of something like a pure vbscript to
> perl parser.  I'll handle all of the object definitions on the 
> other side, I already do, and do both pre & post processing to
> the ASP script so that hey can focus on the hard part, the 
> VBScript parser.

I guess what I was picturing, was setting up Apache::ASP so that its no
longer perl dependant at all, and that language specific bits aren't
included anywhere. If you pass:

>>
Response.Write "Hello "

$response->write("World!");
<<

To a VBScript parser it should die. So you could define the concept of how
to write "$response->write( ... );" in other languages somehow, in the
actual class that implements (or calls) the parser. That way pluging in a
JScript parser becomes easier, and you could even support multiple
languages in the same file, a-la MS ASP.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org


Re: VBScript::Parser

Posted by Joshua Chamas <jo...@chamas.com>.
Matt Sergeant wrote:
> 
> On Thu, 27 Jul 2000, Ime Smits wrote:
> 
> > In short, I have the following in mind and partially worked out in actual
> > code. A package VBScript::Parser which offers:
> >
> >     $parser=new VBScript::Parser;
> >     $evalable_perl_code = $parser->parse($complete_asp_page);
> 
> No. The problem is that it would be really great if this could be a
> generic VBScript parser, rather than an ASP/VB parser.
> 

???.  This will be a generic parser for VBScript.  What I would 
feed it from Apache::ASP is a wholly native VBScript, with all 
the static html ASP parts compiled out already into $response->write('');
string, or something to that effect.  Ime's VBScript parser
will not have to know anything about static HTML bits, nor ASP
objects, that's the beauty of something like a pure vbscript to
perl parser.  I'll handle all of the object definitions on the 
other side, I already do, and do both pre & post processing to
the ASP script so that hey can focus on the hard part, the 
VBScript parser.

-- Joshua
_________________________________________________________________
Joshua Chamas			        Chamas Enterprises Inc.
NodeWorks >> free web link monitoring	Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

Re: VBScript::Parser

Posted by Matt Sergeant <ma...@sergeant.org>.
On Thu, 27 Jul 2000, Ime Smits wrote:

> | No. The problem is that it would be really great if this could be a
> | generic VBScript parser, rather than an ASP/VB parser.
> 
> s/(.*?)<%(.*?)%>/&parse_html($1).&parse_vb($2)/seg, so don't worry - you'll
> get your generic method ;)

Won't work. You need to know the types of variables outside of the current
"scope" in ASP terms, but inside the scope in VB terms. Might work if its
a method call, but still, its not very elegant.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org


Re: VBScript::Parser

Posted by Ime Smits <im...@iae.nl>.
| No. The problem is that it would be really great if this could be a
| generic VBScript parser, rather than an ASP/VB parser.

s/(.*?)<%(.*?)%>/&parse_html($1).&parse_vb($2)/seg, so don't worry - you'll
get your generic method ;)

Ime



Re: VBScript::Parser

Posted by Matt Sergeant <ma...@sergeant.org>.
On Thu, 27 Jul 2000, Ime Smits wrote:

> | Well you still have to implement a VBScript parser (Damian, of course,
> | implemented a latin parser), and the problem is that ASP is parsed by
> | Apache::ASP, not by perl, so you'd have to make use of the VB parser at
> | that point.
> 
> Hi, just wanted to let you know, I'm going to pick this up in about one or
> two weeks from now, as soon as I tackled some deadlines.
> 
> In short, I have the following in mind and partially worked out in actual
> code. A package VBScript::Parser which offers:
> 
>     $parser=new VBScript::Parser;
>     $evalable_perl_code = $parser->parse($complete_asp_page);

No. The problem is that it would be really great if this could be a
generic VBScript parser, rather than an ASP/VB parser. 

I can see two methods to do this (there are probably more):

1. Create a parse tree out of the ASP, the parse tree can be dead
simple, just an array of blessed scalar refs, the bless objects being
::Characters, ::Code and ::Output (presumably Apache::ASP::...). Then do a
second pass that converts each using the parser to pure perl, using an
appropriate language module. (the perl version can reproduce the perl code
verbatim, the VB one has to do some translating).

2. Have language modules that contain getBinder, getResponseStr, etc
methods. For Perl this is "->", and "$Response" respectively. Or something
similar that allows you to construct language independant
$Response->Write() parts for non-delimited parts (the plain HTML bits) and
<%= ... %> delimited parts. Then you end up with a single script in either
Perl or VB. Then you pass it to the translate() method, which in perl is
simply sub { return shift; }, and in VB does all the work, using a generic
VB to Perl translator.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org


VBScript::Parser

Posted by Ime Smits <im...@iae.nl>.
| Well you still have to implement a VBScript parser (Damian, of course,
| implemented a latin parser), and the problem is that ASP is parsed by
| Apache::ASP, not by perl, so you'd have to make use of the VB parser at
| that point.

Hi, just wanted to let you know, I'm going to pick this up in about one or
two weeks from now, as soon as I tackled some deadlines.

In short, I have the following in mind and partially worked out in actual
code. A package VBScript::Parser which offers:

    $parser=new VBScript::Parser;
    $evalable_perl_code = $parser->parse($complete_asp_page);

The evalable_perl_code will start with a "$VB=new VBScript::Core;". All
VBScript statements will have to get a perl method in the VBScript::Core
package, so a=mids(x,y) could be translated to $a = $VB->mid($x,$y). I could
definitely need some help in creating methods for all statements in
VBScript.

All Server, Request, Response and Application objects will inherited from
Joshua's Apache::ASP. After that, we could create other objects like
VBScript::adodb::connection to implement things like
"server.createobject(adodb.connection)" and the like.

Let me know if you're interested to help me out with this.

Ime


Re: VBScript parser a la Lingua::Romana::Perligata

Posted by Matt Sergeant <ma...@sergeant.org>.
On Thu, 27 Jul 2000, darren chamberlain wrote:

> mbarnicle@my-Deja.com said something to this effect:
> > On Mon, 24 Jul 2000 13:19:51   Joshua Chamas wrote:
> > >Until I write a VBScript to perl parser, yes you can only
> > >use perl under Apache::ASP.
> > Ok, so are you actually going to write a VBScript to perl parser?
> 
> Has anyone considered using an approach similar to the one Damian Conway
> uses in Lingua::Romana::Perligata? This is from a talk he gave at the Perl
> Conference last week. Lingua::Romana::Perligata lets you write your code in
> Latin, which gets translated into Perl on the fly during the compile stage
> using source filters (see Filter::Util::Call). Using this method, you could
> write your code in VBScript (or use some older VBScript code), put the call
> to the source filter at the top, and (at compile time), it gets translated
> into Perl.
> 
> THe advantage of this approach is that you could use existing VBScript
> code without modification (provided your source filter was sophisticated
> enough). The disadvantage is that you'd have to know VBScript pretty
> well to implement it.

Well you still have to implement a VBScript parser (Damian, of course,
implemented a latin parser), and the problem is that ASP is parsed by
Apache::ASP, not by perl, so you'd have to make use of the VB parser at
that point.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org


VBScript parser a la Lingua::Romana::Perligata

Posted by darren chamberlain <da...@boston.com>.
mbarnicle@my-Deja.com said something to this effect:
> On Mon, 24 Jul 2000 13:19:51   Joshua Chamas wrote:
> >Until I write a VBScript to perl parser, yes you can only
> >use perl under Apache::ASP.
> Ok, so are you actually going to write a VBScript to perl parser?

Has anyone considered using an approach similar to the one Damian Conway
uses in Lingua::Romana::Perligata? This is from a talk he gave at the Perl
Conference last week. Lingua::Romana::Perligata lets you write your code in
Latin, which gets translated into Perl on the fly during the compile stage
using source filters (see Filter::Util::Call). Using this method, you could
write your code in VBScript (or use some older VBScript code), put the call
to the source filter at the top, and (at compile time), it gets translated
into Perl.

THe advantage of this approach is that you could use existing VBScript
code without modification (provided your source filter was sophisticated
enough). The disadvantage is that you'd have to know VBScript pretty
well to implement it.

(darren)

-- 
Although I can accept talking scarecrows, lions and great wizards of
emerald cities, I find it hard to believe there is no paperwork involved
when your house lands on a witch.

Re: VBScript parser (was Re: Apache::ASP Question)

Posted by Ime Smits <im...@iae.nl>.
| so are you actually going to write a VBScript to perl parser?  I was
actually
| thinking of undertaking this project myself, but I've never written a
lexer
| or a parser or anything like that.

For what it's worth: Some months ago I was facing the problem of moving
several ASP scripted IIS/Microsoft SQL sites to a Unix Apache/mySQL server.
And instead of doing things by hand, I wrote a tool do do the conversion. It
did the trick for the projects I initially intended it for. But after
extending functionality over and over together with a collegue who's perl
knowledge is far less advanced, I finally abonded development of my tool
when it reached 1500 obfuscated lines of perl code and things got unreadible
even for myself. I am planning to do a complete OO rewrite someday - but my
resources are very limited at the moment.

For basic VBScripting and it generates working stand-alone perl scripts
suitable for plain CGI and mod_perl, test it on
http://www.guru4hire.nl/asp2pl

Let me know if someone starts with Parse::VBScript, I am willing to
contribute.

Ime




Re: VBScript parser (was Re: Apache::ASP Question)

Posted by Matt Sergeant <ma...@sergeant.org>.
On Tue, 25 Jul 2000, Joshua Chamas wrote:

> Like Matt suggested you can start with his simple vbscript to 
> perlscript converter, but I would recommend to do a really 
> complete job that you use a full on grammar and something 
> like Parse::Yapp to do the parse tree.  I personally would
> find this approach the most enjoyable, but it may be that
> the parse times that result from this are too slow, and you
> might need to take the approach that Matt did and brute
> force your way through the code to render to perlscript.

Well you might find this interesting:

http://compilers.iecc.com/comparch/article/00-05-085

Sounds a lot like parsing perl :-)

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org


Re: VBScript parser (was Re: Apache::ASP Question)

Posted by Joshua Chamas <jo...@chamas.com>.
mbarnicle@my-Deja.com wrote:
> 
> --
> 
> On Mon, 24 Jul 2000 13:19:51   Joshua Chamas wrote:
> >Until I write a VBScript to perl parser, yes you can only
> >use perl under Apache::ASP.
> 
> Ok, so are you actually going to write a VBScript to perl parser?  I was actually thinking of undertaking this project myself, but I've never written a lexer or a parser or anything like that.  If you _are_ going to do this I'd be glad to help.  If not, I'm probably going to get started with it anyways.  I realized a huge need for something like this since I've been working on a large site (high volume + large codebase) converting from WinNT/ASP to Solaris/Perl/CGI (with mod_perl of course).  I've written a _really_ simple script that converts stuff like "For i = 1 To 10" to "for (1..10) {" etc., but it's of course really flaky and unreliant (although it knocks out about 90% of the manual code conversion).
> 
> Ok, so what was the point again??  Oh yeah, are you really going to do this?  :-)  Or is someone else already in the process?
> 

Like Matt suggested you can start with his simple vbscript to 
perlscript converter, but I would recommend to do a really 
complete job that you use a full on grammar and something 
like Parse::Yapp to do the parse tree.  I personally would
find this approach the most enjoyable, but it may be that
the parse times that result from this are too slow, and you
might need to take the approach that Matt did and brute
force your way through the code to render to perlscript.

I have not started on this, and likely would not for a while
yet so feel free to have at it.  If you decomped this 
functionality into a module like Parse::VBScript or
some such ( I don't know about this CPAN namespace ) and
presented an interface like:

  my $vbparser = Parse::VBScript->new($string_ref);
  my $perlscript_ref = $vbparser->perlscript();

this interface would allow me to use your code from
Apache::ASP easily by passing the VBScript code into
the parser, and get the equivalent perlscript.  The 
passing by ref would just save on some of the string 
copying that may be unnecessary otherwise.

There is a HUGE need for this vbscript emulation, and this 
would greatly add to the functionality of Apache::ASP, so 
many thanks ahead of time!

-- Joshua
_________________________________________________________________
Joshua Chamas			        Chamas Enterprises Inc.
NodeWorks >> free web link monitoring	Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

Re: VBScript parser (was Re: Apache::ASP Question)

Posted by Matt Sergeant <ma...@sergeant.org>.
On Mon, 24 Jul 2000 mbarnicle@my-Deja.com wrote:

> --
> 
> On Mon, 24 Jul 2000 13:19:51   Joshua Chamas wrote:
> >Until I write a VBScript to perl parser, yes you can only
> >use perl under Apache::ASP.
> 
> Ok, so are you actually going to write a VBScript to perl parser?  I
> was actually thinking of undertaking this project myself, but I've
> never written a lexer or a parser or anything like that.  If you _are_
> going to do this I'd be glad to help.  If not, I'm probably going to
> get started with it anyways.  I realized a huge need for something
> like this since I've been working on a large site (high volume + large
> codebase) converting from WinNT/ASP to Solaris/Perl/CGI (with mod_perl
> of course).  I've written a _really_ simple script that converts stuff
> like "For i = 1 To 10" to "for (1..10) {" etc., but it's of course
> really flaky and unreliant (although it knocks out about 90% of the
> manual code conversion).
> 
> Ok, so what was the point again??  Oh yeah, are you really going to do
> this?  :-)  Or is someone else already in the process?

I wrote a naive thing for converting scriptlets to perl scriptlets
(scriptlets let you write COM objects in scripting code), but it's not
very complete either. It's somewhere on my old fastnetltd web pages at
http://come.to/fastnet

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org