Specy / rooc

A language for compiling formal mathematical models into static models which are transformed to be solved
https://rooc.specy.app
MIT License
4 stars 0 forks source link

Add implicit multiplication #5

Closed Specy closed 9 months ago

Specy commented 9 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 9 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