Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
5e275d39
Commit
5e275d39
authored
Jun 29, 2004
by
ijones
Browse files
allowed Version types to carry state. lots of small changes
parent
57eb6f48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Distribution/Version.hs
View file @
5e275d39
...
...
@@ -190,11 +190,11 @@ showVersionRange (IntersectVersionRanges r1 r2)
-- * Parsing
-- ------------------------------------------------------------
word
::
Parser
String
word
::
Gen
Parser
Char
st
String
word
=
many1
letter
<?>
"word"
-- -----------------------------------------------------------
parseVersionRange
::
Parser
VersionRange
parseVersionRange
::
Gen
Parser
Char
st
VersionRange
parseVersionRange
=
try
(
do
reservedOp
"<"
v
<-
parseVersion
return
$
EarlierVersion
v
)
...
...
@@ -217,7 +217,7 @@ parseVersionRange = try (do reservedOp "<"
-- -----------------------------------------------------------
-- |Parse any kind of version
parseVersion
::
Parser
Version
parseVersion
::
Gen
Parser
Char
st
Version
parseVersion
=
do
branch
<-
branchParser
date
<-
dateParser
...
...
@@ -225,13 +225,13 @@ parseVersion
-- -----------------------------------------------------------
-- |Parse a version of the form 1.2.3
branchParser
::
Parser
[
Int
]
branchParser
::
Gen
Parser
Char
st
[
Int
]
branchParser
=
do
n
<-
number
bs
<-
branches
return
(
n
:
bs
)
branches
::
Parser
[
Int
]
branches
::
Gen
Parser
Char
st
[
Int
]
branches
=
option
[]
$
do
char
'.'
...
...
@@ -239,12 +239,12 @@ branches
bs
<-
branches
return
(
n
:
bs
)
dateParser
::
Parser
[
String
]
dateParser
::
Gen
Parser
Char
st
[
String
]
dateParser
=
(
try
$
do
char
'-'
;
d
<-
word
;
return
[
"date="
++
d
])
<|>
(
do
notFollowedBy
anyChar
;
return
[]
)
number
::
(
Integral
a
,
Read
a
)
=>
Parser
a
number
::
(
Integral
a
,
Read
a
)
=>
Gen
Parser
Char
st
a
number
=
do
{
ds
<-
many1
digit
;
return
(
read
ds
)
}
...
...
@@ -299,7 +299,7 @@ shortMonthParser = foldl1 (<|>) [do reserved a;return b | (a,b)
("Nov", November), ("Dec", December)]]
-}
lexer
::
P
.
TokenParser
()
lexer
::
P
.
TokenParser
st
lexer
=
P
.
makeTokenParser
(
emptyDef
...
...
@@ -311,31 +311,31 @@ lexer = P.makeTokenParser
P
.
reservedOpNames
=
[
"<"
,
">"
,
"<="
,
">="
,
"=="
,
"-"
]
})
whiteSpace
::
CharParser
()
()
whiteSpace
::
CharParser
st
()
whiteSpace
=
P
.
whiteSpace
lexer
lexeme
::
CharParser
()
a
->
CharParser
()
a
lexeme
::
CharParser
st
a
->
CharParser
st
a
lexeme
=
P
.
lexeme
lexer
symbol
::
String
->
CharParser
()
String
symbol
::
String
->
CharParser
st
String
symbol
=
P
.
symbol
lexer
natural
::
CharParser
()
Integer
natural
::
CharParser
st
Integer
natural
=
P
.
natural
lexer
parens
::
CharParser
()
a
->
CharParser
()
a
parens
::
CharParser
st
a
->
CharParser
st
a
parens
=
P
.
parens
lexer
semi
::
CharParser
()
String
semi
::
CharParser
st
String
semi
=
P
.
semi
lexer
identifier
::
CharParser
()
String
identifier
::
CharParser
st
String
identifier
=
P
.
identifier
lexer
reserved
::
String
->
CharParser
()
()
reserved
::
String
->
CharParser
st
()
reserved
=
P
.
reserved
lexer
reservedOp
::
String
->
CharParser
()
()
reservedOp
::
String
->
CharParser
st
()
reservedOp
=
P
.
reservedOp
lexer
-- ------------------------------------------------------------
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment