Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

We have a graphical designer, now they want a text based designer. Suggestions?

I'm sorry I could not think of a better title.

The problem is the following:

For our customer we have created (as part of a larger application) a graphical designer which they can use to build "scenario's".

These scenario's consist of "Composites" which in turn consist of "Commands". These command objects all derive from CommandBase and implement an interface called ICompilable.

The scenario class also implements ICompilable. When Compile() is called on a command an array of bytes is returned which can then be send to the device for which they are intended (can't disclose to much info about that hardware, sorry)

Just to give you an idea:

var scenario = new Scenario();

scenario.Add(new DelayCommand(1));
scenario.Add(new CountWithValueCommand(1,ActionEnum.Add,1));
scenario.Add(new DirectPowerCommand(23,false,150));
scenario.Add(new WaitCommand(3));
scenario.Add(new DirectPowerCommand(23,false,150));
scenario.Add(new SkipIfCommand(1,OperatorEnum.SmallerThan,10));
scenario.Add(new JumpCommand(2));

byte[] compiledData = scenario.Compile();

The graphical designer abstracts all this from the user and allows him (or her) to simply drag en drop composites onto the designer surface. (Composites can group commands so we can provide building blocks for returning tasks)

Recently our customer came to us and said, "well the designer is really cool, but we have some people who would rather have some kind of programming language, just something simple."

(Simple to them of course)

I would very much like to provide them with a simple language, that can call various commmands and also replace SkipIfCommand with a nicer structure, etc...

I have no idea where to start or what my options are (without breaking what we have)

I have heard about people embedding languages such as Python, people writing their own language an parsers, etc...

Any suggestions?

PS: Users only work with composites, never with commands. Composites are loaded dynamically at runtime (along with their graphical designer) and may be provided by third parties in seperate assemblies.

like image 837
TimothyP Avatar asked Dec 30 '22 08:12

TimothyP


1 Answers

From what i think i've understood you have two options

you could either use an XML style "markup" to let them define entities and their groupings, but that may not be best.

Your alternatives are yes, yoou could embedd a language, but do you really need to, wouldnt that be overkill, and how can you control it?

If you only need really simple syntax then perhaps write your own language. Its actually not that hard to create a simple interpreter, as long as you have a strict, unambiguous language. Have a look for some examples of compilers in whatever youre using, c#?

I wrote a very simple interperter in java at uni, it wasnt as hard as you'd think.

like image 196
Andrew Bullock Avatar answered Jan 04 '23 16:01

Andrew Bullock