~safinaskar/check-cfg-ambiguity

8d6bd0b390f1ca0a607ab8e38117d5a8a26d7f7a — Askar Safin 1 year, 5 months ago 55e6f5e
Optimization
1 files changed, 6 insertions(+), 11 deletions(-)

M CheckCFGAmbiguity.hs
M CheckCFGAmbiguity.hs => CheckCFGAmbiguity.hs +6 -11
@@ 119,17 119,12 @@ lowLevelTestAmbiguity (Grammar g) start count = case Data.Map.member start g of 
    while $ do {
      do {
        currWordsV <- readSTRef currWords;
        writeSTRef currWords [];
        for_ currWordsV $ \word -> do {
          let { (before, after) = break (\case { N _ -> True; T _ -> False; }) word };
          case after of {
            [] -> return ();
            (N nn):rest -> do {
              currWordsV2 <- readSTRef currWords;
              writeSTRef currWords $ ((fromJust $ Data.Map.lookup nn g) <&> \prod -> before ++ prod ++ rest) ++ currWordsV2;
            };
            _ -> error "Impossible";
          };
        writeSTRef currWords $ concat $ currWordsV <&> \word -> let {
          (before, after) = break (\case { N _ -> True; T _ -> False; }) word;
        } in case after of {
          [] -> [];
          (N nn):rest -> (fromJust $ Data.Map.lookup nn g) <&> \prod -> before ++ prod ++ rest;
          _ -> error "Impossible";
        };
        currWordsV2 <- readSTRef currWords;
        allWordsV <- readSTRef allWords;