tcr / corollary

Cross-compiler from Haskell to Rust, plus parser-haskell.
73 stars 5 forks source link

Translate colons in `case` arms properly #38

Open tcr opened 7 years ago

tcr commented 7 years ago

e.g. in this code, the colons will wrongly be treated as function arguments.

baseTypeOf :: [CDeclSpec] -> EnvMonad s (Maybe CStorageSpec, EnvMonad s IntermediateType)
baseTypeOf specs = do
    -- TODO: process attributes and the `inline` keyword
    let (storage, _attributes, basequals, basespecs, _inlineNoReturn, _align) = partitionDeclSpecs specs
    mstorage <- case storage of
        [] -> return Nothing
        [spec] -> return (Just spec)
        _ : excess : _ -> badSource excess "extra storage class specifier"
    base <- typedef (mutable basequals) basespecs
    return (mstorage, base)
    where
tcr commented 7 years ago

Another case where case parsing falls down here:

            IsFunc{} -> return expr'
            _ -> badSource node "dereference of non-pointer"