TelluIoT / ThingML

The ThingML modelling language
https://github.com/TelluIoT/ThingML
Apache License 2.0
101 stars 32 forks source link

Bit/byte operators in the action language #213

Open brice-morin opened 6 years ago

brice-morin commented 6 years ago

A few ThingML programs use bit/byte operators and have to rely on extern expressions, which by chance are the same in all the languages we target so far. Still, this is a hack, not allowing for proper type-checking, etc. We would need to introduce those operators (shift left/righ, bit-wise and, or, xor) in the action language.

jakhog commented 6 years ago

Just for reference, here are the binary operators that are defined in Java, C, JavaScript and Go:

jakhog commented 6 years ago

I can see two possible conflicts with the ThingML syntax, namely the & and ^.

& which is used in the extern segments. So an expression like:

`extern_var` & var

Could mean both an extern with two segments, or the binary and

^ is used for escaping names in ThingML. So that you can give names that are the same as keywords. So I think this might cause problems for the parser as well.

brice-morin commented 6 years ago

Well, do we really need this escape mechanism in ThingML? If so, I guess we can change the symbol.

For the &, I see the problem.

brice-morin commented 5 years ago

In addition:

That is particularly annoying, meaning that the externs we write so as to deal with those operators are actually not as portable as we thought... i.e. we need, more than ever, to have them in the action language.

@ffleurey comments?