Skip to content

Commit

Permalink
fix: Fix pretty-printer to output correct #endif comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Jan 23, 2024
1 parent 4414929 commit 61daedb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Language/Cimple/Lexer.x
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ tokens :-
<0,ppSC> "false" { mkL LitFalse }
<0,ppSC> "true" { mkL LitTrue }
<0,ppSC> "__func__" { mkL IdVar }
<0,ppSC> "nullptr" { mkL IdConst }
<0,ppSC> "__"[a-zA-Z]+"__"? { mkL IdConst }
<0,ppSC> [A-Z][A-Z0-9_]{1,2} { mkL IdSueType }
<0,ppSC> _*[A-Z][A-Z0-9_]* { mkL IdConst }
Expand Down
8 changes: 4 additions & 4 deletions src/Language/Cimple/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ ppNode = foldFix go
ppToplevel decls <$>
line <>
dullmagenta (text "#ifdef __cplusplus") <$>
rbrace <$>
rbrace <+> text "/* extern \"C\" */" <$>
dullmagenta (text "#endif")

Group decls -> vcat decls
Expand Down Expand Up @@ -446,17 +446,17 @@ ppNode = foldFix go
dullmagenta (text "#if" <+> cond) <$>
ppToplevel decls <>
elseBranch <$>
dullmagenta (text "#endif")
dullmagenta (text "#endif /*" <+> cond <+> text "*/")
PreprocIfdef name decls elseBranch ->
dullmagenta (text "#ifdef" <+> ppLexeme name) <$>
ppToplevel decls <>
elseBranch <$>
dullmagenta (text "#endif //" <+> ppLexeme name)
dullmagenta (text "#endif /*" <+> ppLexeme name <+> text "*/")
PreprocIfndef name decls elseBranch ->
dullmagenta (text "#ifndef" <+> ppLexeme name) <$>
ppToplevel decls <>
elseBranch <$>
dullmagenta (text "#endif //" <+> ppLexeme name)
dullmagenta (text "#endif /*" <+> ppLexeme name <+> text "*/")
PreprocElse [] -> empty
PreprocElse decls ->
linebreak <>
Expand Down

0 comments on commit 61daedb

Please sign in to comment.