Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Tobias Decking
GHC
Commits
864388a3
Commit
864388a3
authored
Oct 04, 2004
by
simonpj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[project @ 2004-10-04 09:27:32 by simonpj]
Make combineSrcSpans commutative
parent
a022fe50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
ghc/compiler/basicTypes/SrcLoc.lhs
ghc/compiler/basicTypes/SrcLoc.lhs
+11
-7
No files found.
ghc/compiler/basicTypes/SrcLoc.lhs
View file @
864388a3
...
...
@@ -284,21 +284,25 @@ mkSrcSpan loc1 loc2
file = srcLocFile loc1
combineSrcSpans :: SrcSpan -> SrcSpan -> SrcSpan
-- Assumes the 'file' part is the same in both
combineSrcSpans (ImportedSpan str) _ = ImportedSpan str
combineSrcSpans (UnhelpfulSpan str) r = r -- this seems more useful
combineSrcSpans _ (ImportedSpan str) = ImportedSpan str
combineSrcSpans l (UnhelpfulSpan str) = l
combineSrcSpans start end
| line1 == line2 = if col1 == col2
then SrcSpanPoint file line1 col1
else SrcSpanOneLine file line1 col1 col2
| otherwise = SrcSpanMultiLine file line1 col1 line2 col2
= case line1 `compare` line2 of
EQ -> case col1 `compare` col2 of
EQ -> SrcSpanPoint file line1 col1
LT -> SrcSpanOneLine file line1 col1 col2
GT -> SrcSpanOneLine file line1 col2 col1
LT -> SrcSpanMultiLine file line1 col1 line2 col2
GT -> SrcSpanMultiLine file line2 col2 line1 col1
where
line1 = srcSpanStartLine start
col1 = srcSpanStartCol start
line2 = srcSpanEndLine end
col1 = srcSpanStartCol start
col2 = srcSpanEndCol end
file = srcSpanFile start
col2 = srcSpanEndCol end
file = srcSpanFile start
instance Outputable SrcSpan where
ppr span
...
...
Write
Preview
Markdown
is supported
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