![]() |
Chat on IRC |
easy to embed language
Posted by pramod [send private reply] at December 08, 2002, 12:35:57 AM
hi,
i was looking to embed some kind of a language in my application. actually, i don't need a full fledged language all i need to do is to eval an expression of the type : y = x^3 +4*sin(x) + cos(x)^3 - ln(c*x) i'm writing a graph drawing app. i thought i'd write it myself, but i ended doing some kind of complicated shit, trying to write an entire language and the project got out of hand and so went into the refrigerator. then i thought i'd embed a language, but it turns out two languages that i know well and are supposed to be used for this kind of thing are horribly complicated to embed - vbscript and python. vbscript needs com and activex and shit and whatever and i never got beyond the first page on linking C/C++ and python in the python manuals. so whats the easiest language to embed. preferably something like 5-10 lines of code! :-)
Posted by CViper [send private reply] at December 08, 2002, 04:57:59 AM
You could try javascript ( http://www.mozilla.org/js/spidermonkey/ ). It's a bit more than 5-10 lines of code, but it's still quite easy.
Otherwise you could try flex + bison and create your own parser/interpreter. There is one example in the manual that shows how to evaluate equations (for a calculator). With minor changes you could convert it to what you want to do (probably).
Posted by regretfuldaydreamer [send private reply] at December 08, 2002, 05:57:28 AM
Just develop your own language for interpreting it. I don't think you'll find anything that will embed as easily as in five or ten lines though. or even 50 or 100.
Posted by CViper [send private reply] at December 08, 2002, 12:11:39 PM
nah, the mozilla JS is "very" easy to embed (about as easy as I think you can get it).
Especially, since most of the mathematical functions are included by default (and the above application probably dosen't need much else)
Posted by unknown_lamer [send private reply] at December 08, 2002, 04:52:50 PM
http://www.gnu.org/software/guile/
scm_boot (inner_main, argc, argv); scm_c_define_gsubr ("proc-name", c-proc, req_args, opt args, rest); scm_c_define ("symbol", value); Really easy to embed, because it was designed for that.
Posted by CDR700 [send private reply] at December 09, 2002, 07:04:32 PM
Unknown_Lamer do you remember Lua ( http://www.lua.org ) the embeddable thing you called "a miserable mix of scheme lisp and something ?". Just thoughts.
Posted by unknown_lamer [send private reply] at December 10, 2002, 09:06:21 AM
Lua looked like BASIC. Vlad was the one that talked about. Hey, you are vlad. I suppose that Lua might be better but I (heart) Scheme and know how to embded Guile quickly.
Register as a new user | |||||||||