Link to home
Start Free TrialLog in
Avatar of Cognize
Cognize

asked on

How do you write a C# application that can parse simple JavaScript - where to start?

Hi,

A vague question, but I'm wondering how you would go about parsing a scripting language in managed code. I'm sure it's not simple, but have no idea where I'd start.

Say I wanted a C# windows forms application that was able to accept user input in the form of Javascript such as:

function showMessage( var message )
{
       alert('Hello!');
}

or maybe something more complex.

If I wanted to design something myself (and not use a library or engine) that could parse this script and replicate it in managed code - how is this done? (regardless of whether it's a good idea or not)

Obvioulsly there's plenty of programs out there that do this such as web browsers...

Can anybody give me any advice.
Avatar of tiagosalgado
tiagosalgado
Flag of Portugal image

In other words, you want to create a interpreter/compiler ?
Avatar of Cognize
Cognize

ASKER

Yes, more an interpreter I guess?
I never done something similar, but i guess you need to define what king of functions your app will support.
If you want to support ALL javascript functions you're done :)
Avatar of Cognize

ASKER

What do you mean I'm done? Is there support in .NET?
ASKER CERTIFIED SOLUTION
Avatar of tiagosalgado
tiagosalgado
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cognize

ASKER

Just for interest really.

I just want an idea of how a developer might go about such a task.