Skip to content

Commit 10b1353

Browse files
committed
Try to make travia happy
1 parent eed32bd commit 10b1353

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ env:
1414
before_install:
1515
- travis_retry sudo add-apt-repository -y ppa:hvr/ghc
1616
- travis_retry sudo apt-get update
17-
- travis_retry sudo apt-get install cabal-install-1.22 ghc-$GHCVER-prof ghc-$GHCVER-dyn happy
18-
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/1.22/bin:$PATH
17+
- travis_retry sudo apt-get install cabal-install-1.22 ghc-$GHCVER-prof ghc-$GHCVER-dyn happy alex-3.1.4
18+
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/1.22/bin:/opt/alex/3.1.4/bin:$PATH
1919

2020
install:
2121
- cabal update

Cabal/Cabal.cabal

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ library
159159
parsec >=3.1.9 && <3.2,
160160
bytestring >= 0.9
161161

162+
build-tools:
163+
alex >= 3.1.4
164+
162165
if flag(bundled-binary-generic)
163166
build-depends: binary >= 0.5 && < 0.7
164167
else

Cabal/Distribution/Parsec/Parser.hs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Distribution.Parsec.Lexer
2525
import Distribution.Parsec.LexerMonad (unLex, LexState(..), LexResult(..), Position(..), LexWarning)
2626

2727
import Text.Parsec.Prim
28-
import Text.Parsec.Combinator hiding (eof)
28+
import Text.Parsec.Combinator hiding (eof, notFollowedBy)
2929
import Text.Parsec.Pos
3030
import Text.Parsec.Error
3131

@@ -90,15 +90,13 @@ describeToken t = case t of
9090
EOF -> "end of file"
9191
LexicalError is -> "character in input " ++ show (B.head is)
9292

93-
--tokName, tokStr, tokNum, tokOther, tokFieldLine :: Parser String
9493
tokName :: Parser (Name Position)
95-
--tokNum, tokOther
96-
--tokStr :: Parser String
97-
tokIndent :: Parser Int
98-
tokColon, tokOpenBrace,
99-
tokCloseBrace :: Parser ()
94+
tokName', tokStr, tokNum, tokOther :: Parser (SectionArg Position)
95+
tokIndent :: Parser Int
96+
tokColon, tokOpenBrace, tokCloseBrace :: Parser ()
97+
tokFieldLine :: Parser (FieldLine Position)
10098

101-
tokName = getTokenWithPos $ \t -> case t of L pos (TokSym x) -> Just (name pos x); _ -> Nothing
99+
tokName = getTokenWithPos $ \t -> case t of L pos (TokSym x) -> Just (mkName pos x); _ -> Nothing
102100
tokName' = getTokenWithPos $ \t -> case t of L pos (TokSym x) -> Just (SecArgName pos x); _ -> Nothing
103101
tokStr = getTokenWithPos $ \t -> case t of L pos (TokStr x) -> Just (SecArgStr pos x); _ -> Nothing
104102
tokNum = getTokenWithPos $ \t -> case t of L pos (TokNum x) -> Just (SecArgNum pos x); _ -> Nothing
@@ -109,16 +107,20 @@ tokOpenBrace = getToken $ \t -> case t of OpenBrace -> Just (); _ -> Nothing
109107
tokCloseBrace = getToken $ \t -> case t of CloseBrace -> Just (); _ -> Nothing
110108
tokFieldLine = getTokenWithPos $ \t -> case t of L pos (TokFieldLine s) -> Just (FieldLine pos s); _ -> Nothing
111109

112-
--sectionName, sectionArg, fieldSecName, fieldContent :: Parser String
113110
colon, openBrace, closeBrace :: Parser ()
114111

115-
sectionName = tokName <?> "section name"
112+
sectionArg :: Parser (SectionArg Position)
116113
sectionArg = tokName' <|> tokStr
117114
<|> tokNum <|> tokOther <?> "section parameter"
115+
116+
fieldSecName :: Parser (Name Position)
118117
fieldSecName = tokName <?> "field or section name"
118+
119119
colon = tokColon <?> "\":\""
120120
openBrace = tokOpenBrace <?> "\"{\""
121121
closeBrace = tokCloseBrace <?> "\"}\""
122+
123+
fieldContent :: Parser (FieldLine Position)
122124
fieldContent = tokFieldLine <?> "field contents"
123125

124126
newtype IndentLevel = IndentLevel Int
@@ -150,8 +152,8 @@ data Field ann = Field !(Name ann) [FieldLine ann]
150152
data Name ann = Name !ann !ByteString
151153
deriving (Eq, Show, Functor)
152154

153-
name :: ann -> ByteString -> Name ann
154-
name ann bs = Name ann (B.map Char.toLower bs)
155+
mkName :: ann -> ByteString -> Name ann
156+
mkName ann bs = Name ann (B.map Char.toLower bs)
155157

156158
getName :: Name a -> ByteString
157159
getName (Name _ bs) = bs
@@ -240,9 +242,9 @@ elements ilevel = many (element ilevel)
240242
element :: IndentLevel -> Parser (Field Position)
241243
element ilevel =
242244
(do ilevel' <- indentOfAtLeast ilevel
243-
name <- tokName
245+
name <- fieldSecName
244246
elementInLayoutContext (incIndentLevel ilevel') name)
245-
<|> (do name <- tokName
247+
<|> (do name <- fieldSecName
246248
elementInNonLayoutContext name)
247249

248250
-- An element (field or section) that is valid in a layout context.
@@ -382,6 +384,8 @@ eof = notFollowedBy anyToken <?> "end of file"
382384
elaborate :: Show a => [Field a] -> [Field a]
383385
elaborate [] = []
384386
elaborate (field@Field{} : rest) = field : elaborate rest
387+
elaborate (IfElseBlock args t e : rest) =
388+
IfElseBlock args (elaborate t) (elaborate e) : elaborate rest
385389
elaborate (Section name args fields : Section ename [] efields : rest)
386390
| getName name == "if" && getName ename == "else" =
387391
IfElseBlock args (elaborate fields) (elaborate efields) : elaborate rest

0 commit comments

Comments
 (0)