Built-in scripting engine for DSL

I am working on a project that requires built-in DSL to fully meet the expected requirements.

DSL will be user defined. This is the layout of the desired syntax:

user-defined-event-1 {
    // event body
}

user-defined-event-2 {
    // event body
}

Probably the most similar event- driven language I know is LSL (from Second Life) .

So, after reading other similar questions on SO, I would like to ask for the best embedded scripting engine (Ruby, Lua, Python, etc.) in C ++ (I work in Qt), which allows me to create this DSL.

In my project, I would verify that the script correctly uses the DSL syntax (at least one specific event) and gives the user all the power of the main script and, if possible, Qt.

No built-in language required to work with Qt. It can be isolated, but it would be nice to have some integration.

+3
source share
8 answers

There are at least some Qt-Lua bindings . Lua can do some of the syntax you showed above; in particular, {}indicates a table (associative array) in Lua, and if you pass an anonymous table only to functions, you do not need parentheses:

Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> function LengthOfTable(t) print(#t) end
> LengthOfTable ({"a","b","c"})
3
> LengthOfTable {"a","b","c"}
3

Is Lua really the best for your application, of course, depends on your application. In any case, Lua is very easy (IMO) to implement in C or C ++.

+3
source
+1

Qt QtScript . langauge ECMAScript (, javascript).

+1

Tcl :

proc user-defined-event-1 {} {
# event body
puts "Hello World"
}

proc , {} . tcl , . , .

+1

, PyQt.

0

boost:: python . , python-Qt.

0

, , DSL. , DSL (, Boost.Proto), .

0

DSL , ANTLR. ANTLR , JDBC- Cassandra. , 4, ++. 3 Qt emit.

0

Source: https://habr.com/ru/post/1720506/


All Articles