block :: Parser Block
block = do
    blknm <- blockname
    checkBlock blknm
    cs <- braces (many actionCond)
    check blknm cs
    nextBlock
    return $ Block blknm cs
  where
    blockname :: Parser BlockName
    blockname = sym2enum blockNames [minBound..maxBound]
    checkBlock blknm = do
        st <- getState
        let cblknm = head $ blocks st
        when (blknm /= cblknm) $ unexpected $ ": " ++ show cblknm ++ "{} is expected"
    nextBlock = do st <- getState
                   setState st { blocks = tail $ blocks st }
    check blknm cs = case last cs of
      ActionCond _ Nothing _ -> return ()
      _                      -> unexpected $ ": action without condition must exist in " ++ show blknm ++ "{}"

----------------------------------------------------------------
block :: Parser Block
block = do
    blknm <- blockname
    checkBlock blknm
    cs <- braces (many actionCond)
    check blknm cs
    nextBlock
    return $ Block blknm cs
  where
    blockname :: Parser BlockName
    blockname = sym2enum blockNames [minBound..maxBound]
    checkBlock blknm = do
        st <- getState
        let cblknm = head $ blocks st
        when (blknm /= cblknm) $ unexpected $ ": " ++ show cblknm ++ "{} is expected"
    nextBlock = do st <- getState
                   setState st { blocks = tail $ blocks st }
    check blknm cs = case last cs of
      ActionCond _ Nothing _ -> return ()
      _                      -> unexpected $ ": action without condition must exist in " ++ show blknm ++ "{}"

----------------------------------------------------------------
block = do
    blknm <- blockname
    checkBlock blknm
    cs <- braces (many actionCond)
    check blknm cs
    nextBlock
    return $ Block blknm cs
  where
    blockname :: Parser BlockName
    blockname = sym2enum blockNames [minBound..maxBound]
    checkBlock blknm = do
        st <- getState
        let cblknm = head $ blocks st
        when (blknm /= cblknm) $ unexpected $ ": " ++ show cblknm ++ "{} is expected"
    nextBlock = do st <- getState
                   setState st { blocks = tail $ blocks st }
    check blknm cs = case last cs of
      ActionCond _ Nothing _ -> return ()
      _                      -> unexpected $ ": action without condition must exist in " ++ show blknm ++ "{}"

----------------------------------------------------------------