Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Finn Teegen
curry-base
Commits
2ade4fcf
Commit
2ade4fcf
authored
Oct 24, 2013
by
Matthias Böhm
Browse files
added extractOrigName function that extracts the original name of an identifier
parent
95a1c7c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Curry/Base/Ident.hs
View file @
2ade4fcf
...
...
@@ -67,7 +67,7 @@ module Curry.Base.Ident
,
recordExtId
,
labelExtId
,
isRecordExtId
,
isLabelExtId
,
fromRecordExtId
,
fromLabelExtId
,
renameLabel
,
recordExt
,
labelExt
,
mkLabelIdent
-- ** Constructed identifiers
,
identPrefix
,
Curry
.
Base
.
Ident
.
sep
,
identPrefix
,
Curry
.
Base
.
Ident
.
sep
,
extractOrigName
)
where
import
Data.Char
(
isAlpha
,
isAlphaNum
,
isSpace
)
...
...
@@ -709,3 +709,19 @@ identPrefix = "#"
-- elements
sep
::
String
sep
=
":_"
-- |Extracts the original name of the given identifier. This is the string after
-- the last "sep".
extractOrigName
::
Ident
->
Ident
extractOrigName
=
updIdentName
extractOrigName'
extractOrigName'
::
String
->
String
extractOrigName'
s
=
last
(
split'
s
""
[]
)
where
sep'
=
Curry
.
Base
.
Ident
.
sep
lenSep
=
length
sep'
split'
::
String
->
String
->
[
String
]
->
[
String
]
split'
str
acc1
acc2
|
sep'
`
isPrefixOf
`
str
=
split'
(
drop
lenSep
str
)
""
(
reverse
acc1
:
acc2
)
|
null
str
=
reverse
(
reverse
acc1
:
acc2
)
|
otherwise
=
split'
(
tail
str
)
(
head
str
:
acc1
)
acc2
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment