Brad
Brad

Reputation: 10660

How to interpret custom scripting language?

I was wondering what the easiest way to parse/interpret a custom language would be. Are there any libraries that could help me out?

I essentially want the end-user to be able to write scripts using a custom syntax that I design (the syntax will probably be similar to c++) and I would need my C++ protogram to interpret the script, much like how there is a C++ library for parsing LUA.

Are there any libraries/examples to help me, or will I just have to do manual tokenizing, parsing and interpreting?

Upvotes: 2

Views: 2498

Answers (3)

Yann Ramin
Yann Ramin

Reputation: 33167

There are numerous frameworks to help, but remember that language design is not to be taken lightly - are you sure you're not better off just using Lua?

Upvotes: 6

Hannes de Jager
Hannes de Jager

Reputation: 2923

Use tools like Lex and Yacc to generate a scanner/parser for you

Upvotes: 2

Cheers and hth. - Alf
Cheers and hth. - Alf

Reputation: 145239

For defining your own parser, take a look at Boost Spirit.

But the practical way is to use an existing language that's been widely used for such things. E.g. JavaScript. Then Google's JavaScript binding is reportedly excellent.

Googling "Google's JavaScript binding" served up, as second hit, a link to Wikipedia's article on V8.

Cheers & hth.,

Upvotes: 1

Related Questions