You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by darren chamberlain <da...@boston.com> on 2000/07/27 15:17:51 UTC

VBScript parser a la Lingua::Romana::Perligata

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

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