Specy / rooc

An optimization modeling language with solvers for OR and CO problems
https://rooc.specy.app
GNU General Public License v3.0
37 stars 1 forks source link

Add implicit multiplication #5

Closed Specy closed 11 months ago

Specy commented 11 months ago

There needs to be a way to express unambiguous implicit multiplication, like 2x and 300(x + y) basically everything that is preceded by a number, perhaps also (...)(...) i've tried to express this as part of the grammar but it doesn't seem to be working, but i haven't experimented much with it It might need to be added as a preprocessor perhaps?

Specy commented 11 months ago

The grammar for the implicit multiplication isn't the clearest but i tried my best to make it as less ambiguous as possible, added in f9eeac3 It is now possible to do:

10x >= 1
10(x + y) + 2 >= 1    
10|x + y| + 2>= 1      

(x + y)10 + 2 >= 1
(x + y)(z - 2) + 2 >= 1
(x + y)|x + y| + 2 >= 1  
(x + y)z + 2 >= 1

|x + y|10 + 2 >= 1
|x + y|(z - 2) + 2 >= 1
|x + y||x + y| + 2 >= 1
|x + y|z + 2 >= 1

2(x + y)3|x + y|z + 2 >= 1