Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cabal
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
Cabal
Commits
e1ca4f4d
Commit
e1ca4f4d
authored
9 years ago
by
Oleg Grenrus
Browse files
Options
Downloads
Patches
Plain Diff
Make Text Platform parse unambigious
parent
22b4553b
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Cabal/Distribution/System.hs
+18
-6
18 additions, 6 deletions
Cabal/Distribution/System.hs
with
18 additions
and
6 deletions
Cabal/Distribution/System.hs
+
18
−
6
View file @
e1ca4f4d
...
...
@@ -161,6 +161,10 @@ instance Text Arch where
parse
=
fmap
(
classifyArch
Strict
)
ident
-- See the comment in instance Text Platform definition
parseDashlessArch
::
Parse
.
ReadP
r
Arch
parseDashlessArch
=
fmap
(
classifyArch
Strict
)
dashlessIdent
classifyArch
::
ClassificationStrictness
->
String
->
Arch
classifyArch
strictness
s
=
fromMaybe
(
OtherArch
s
)
$
lookup
(
lowercase
s
)
archMap
...
...
@@ -183,8 +187,15 @@ instance Binary Platform
instance
Text
Platform
where
disp
(
Platform
arch
os
)
=
disp
arch
<>
Disp
.
char
'-'
<>
disp
os
-- TODO: there are ambigious platforms like: `arch-word-os`
-- which could be parsed as
-- * Platform "arch-word" "os"
-- * Platform "arch" "word-os"
-- We could support that preferring variants 'OtherOS' or 'OtherArch'
--
-- For now we split into arch and os parts on the first dash.
parse
=
do
arch
<-
parse
arch
<-
parse
DashlessArch
_
<-
Parse
.
char
'-'
os
<-
parse
return
(
Platform
arch
os
)
...
...
@@ -198,13 +209,14 @@ buildPlatform = Platform buildArch buildOS
-- Utils:
ident
::
Parse
.
ReadP
r
String
ident
=
liftM2
(
:
)
first
rest
Parse
.+++
liftM2
(
:
)
first
rest'
ident
=
liftM2
(
:
)
first
rest
where
first
=
Parse
.
satisfy
Char
.
isAlpha
rest
=
Parse
.
munch
(
\
c
->
Char
.
isAlphaNum
c
||
c
==
'_'
)
dashlessIdent
::
Parse
.
ReadP
r
String
dashlessIdent
=
liftM2
(
:
)
first
rest
where
first
=
Parse
.
satisfy
Char
.
isAlpha
-- We try first to parse identifier without dashes
-- This is required to parse 'Platform' properly
-- https://github.com/haskell/cabal/issues/2804
rest
=
Parse
.
munch
(
\
c
->
Char
.
isAlphaNum
c
||
c
==
'_'
)
rest'
=
Parse
.
munch
(
\
c
->
Char
.
isAlphaNum
c
||
c
==
'_'
||
c
==
'-'
)
lowercase
::
String
->
String
lowercase
=
map
Char
.
toLower
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment