Commit 726112d6 authored by Oleg Grenrus's avatar Oleg Grenrus
Browse files

Allow NBSP in sections, warn about them [ci skip]

parent c87d5b5b
......@@ -58,8 +58,6 @@ import Distribution.Parsec.LexerMonad
import Distribution.Text (display)
import Distribution.Version (mkVersion, Version, asVersionIntervals, orLaterVersion, LowerBound (..))
--import Debug.Trace
-- ---------------------------------------------------------------
-- Parsing
......
......@@ -46,9 +46,9 @@ $alpha = [a-z A-Z] -- alphabetic characters
$symbol = [\= \< \> \+ \* \- \& \| \! \$ \% \^ \@ \# \? \/ \\ \~]
$ctlchar = [\x0-\x1f \x7f]
$printable = \x0-\x10ffff # $ctlchar -- so no \n \r
$nbsp = \xa0
$spacetab = [$space \t]
$bom = \xfeff
$nbsp = \xa0
$nbspspacetab = [$nbsp $space \t]
$paren = [ \( \) \[ \] ]
......@@ -76,16 +76,16 @@ tokens :-
}
<bol_section, bol_field_layout, bol_field_braces> {
$spacetab* @nl { \_ _ _ -> adjustPos retPos >> lexToken }
$nbspspacetab+ @nl { \_ _ _ -> adjustPos retPos >> addWarning LexWarningNBSP "Non-breaking space occured" >> lexToken }
$nbspspacetab* @nl { \_ _ inp -> checkWhitespace inp >> adjustPos retPos >> lexToken }
-- no @nl here to allow for comments on last line of the file with no trailing \n
$spacetab* "--" $comment* ; -- TODO: check the lack of @nl works here
-- including counting line numbers
$spacetab* "--" $comment* ; -- TODO: check the lack of @nl works here
-- including counting line numbers
}
<bol_section> {
$spacetab* --TODO prevent or record leading tabs
{ \pos len inp -> if B.length inp == len
$nbspspacetab* --TODO prevent or record leading tabs
{ \pos len inp -> checkWhitespace inp >>
if B.length inp == len
then return (L pos EOF)
else setStartCode in_section
>> return (L pos (Indent len)) }
......@@ -162,6 +162,14 @@ toki t pos len input = return $! L pos (t (B.take len input))
tok :: Monad m => Token -> Position -> t -> t1 -> m LToken
tok t pos _len _input = return $! L pos t
checkWhitespace :: ByteString -> Lex ()
checkWhitespace bs
| B.any (== 194) bs = addWarning LexWarningNBSP "Non-breaking space found"
| otherwise = return ()
whitespace :: Position -> Int -> ByteString -> Lex ()
whitespace _ _ = checkWhitespace
-- -----------------------------------------------------------------------------
-- The input type
......
......@@ -154,35 +154,6 @@ problematicFiles =
, eq "DSTM/0.1/DSTM.cabal"
, eq "DSTM/0.1.1/DSTM.cabal"
, eq "DSTM/0.1.2/DSTM.cabal"
-- executable
{-
, eq "DefendTheKing/0.1/DefendTheKing.cabal"
, eq "DefendTheKing/0.2/DefendTheKing.cabal"
, eq "DefendTheKing/0.2.1/DefendTheKing.cabal"
, isPrefixOf "HaLeX/"
, isPrefixOf "PerfectHash/"
, isPrefixOf "hburg/"
, isPrefixOf "hemkay/"
, isPrefixOf "historian/"
, isPrefixOf "hp2any-graph/"
, isPrefixOf "hp2any-manager/"
-}
-- hs-source-dirs:
-- .
, isPrefixOf "writer-cps-mtl/"
, isPrefixOf "writer-cps-monads-tf/"
, isPrefixOf "writer-cps-transformers/"
-- unexpected character in input '\194' - nbsp
, eq "Octree/0.5/Octree.cabal"
, eq "hermit/0.1.8.0/hermit.cabal"
, eq "oeis/0.3.0/oeis.cabal"
, eq "oeis/0.3.1/oeis.cabal"
, eq "oeis/0.3.2/oeis.cabal"
, eq "oeis/0.3.3/oeis.cabal"
, eq "oeis/0.3.4/oeis.cabal"
, eq "oeis/0.3.5/oeis.cabal"
, eq "oeis/0.3.6/oeis.cabal"
, eq "oeis/0.3.7/oeis.cabal"
-- colon : after section header
, eq "ds-kanren/0.2.0.0/ds-kanren.cabal"
, eq "ds-kanren/0.2.0.1/ds-kanren.cabal"
......@@ -207,6 +178,9 @@ problematicFiles =
-- hs-source-dirs ".", old parser broken
, isPrefixOf "hledger-ui/"
, eq "hspec-expectations-pretty/0.1/hspec-expectations-pretty.cabal"
, isPrefixOf "writer-cps-mtl/"
, isPrefixOf "writer-cps-monads-tf/"
, isPrefixOf "writer-cps-transformers/"
-- {- comment -}
, eq "ixset/1.0.4/ixset.cabal"
]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment