Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't create empty groups for empty list of feature defines. #66

Merged
merged 1 commit into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Language/Cimple/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ ppNode = foldFix go
IfStmt cond t e -> ppIfStmt cond t e
ForStmt i c n body -> ppForStmt i c n body
Default s -> kwDefault <> colon <+> s
Label l s -> ppLexeme l <> colon <$> s
Label l s -> indent (-99) (line <> ppLexeme l <> colon) <$> s
ExprStmt e -> e <> semi
Goto l -> kwGoto <+> ppLexeme l <> semi
Case e s -> kwCase <+> e <> colon <+> s
Expand Down
9 changes: 5 additions & 4 deletions src/Language/Cimple/TreeParser.y
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Language.Cimple.TreeParser
) where

import Data.Fix (Fix (..))
import Data.Maybe (maybeToList)
import Data.Text (Text)
import qualified Data.Text as Text
import Language.Cimple.Ast (CommentStyle (..), Node,
Expand Down Expand Up @@ -145,12 +146,12 @@ HeaderBody

Source :: { [NonTerm] }
Source
: Features localInclude Includes Decls { [Fix (Group $1), $2] ++ $3 ++ $4 }
: Features localInclude Includes Decls { maybeToList $1 ++ [$2] ++ $3 ++ $4 }

Features :: { [NonTerm] }
Features :: { Maybe NonTerm }
Features
: { [] }
| Features IfDefine { $2 : $1 }
: { Nothing }
| NonEmptyList(IfDefine) { Just $ Fix $ Group $1 }

IfDefine :: { NonTerm }
IfDefine
Expand Down