PLTools / Lama

Teaching language LaMa for a compiler course
GNU General Public License v3.0
70 stars 37 forks source link

Lamac big execution time #5

Open merge34 opened 4 years ago

merge34 commented 4 years ago

Hello. During my progress in the compiler course I've encountered a possible bug in lamac.

Scenario

  1. Add case ... of construction to the code
  2. Add a considerable number (10+) of string patterns
  3. Add function call using dot notation after ->
  4. Run lamac <file name>

Problem In the described scenario lamac execution time grows exponentially as the number of patterns grows.

Expected behavior Execution time in the described scenario is similar to the execution time of lamac without dot notation usage.

Example Consider the following gist, in which I've implemented 2 semantically equivalent programs, according to specification:

  1. In file example1.lama I've implemented the described scenario without dot notation usage. So, without any dependence on N, we have something like:

    $ time lamac test.lama
    real    0m8,152s                                                                                                                   
    user    0m8,037s  
    sys     0m0,102s
  2. In file example2.lama I've implemented exactly described scenario. So, we have:

Environment description

dboulytchev commented 4 years ago

Looks like Ostap issue with dot notation support. Should be postponed until hash-consing and proper memoization is implemented.