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
Glasgow Haskell Compiler
GHC
Commits
dc2f65f6
Commit
dc2f65f6
authored
Apr 02, 2012
by
pcapriotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support qualified identifiers in quasi-quotes (
#5555
).
parent
50e5a06b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
compiler/parser/Lexer.x
compiler/parser/Lexer.x
+24
-1
compiler/parser/Parser.y.pp
compiler/parser/Parser.y.pp
+5
-0
No files found.
compiler/parser/Lexer.x
View file @
dc2f65f6
...
...
@@ -321,6 +321,10 @@ $tab+ { warn Opt_WarnTabs (text "Tab character") }
"[" @varid "|" / { ifExtension qqEnabled }
{ lex_quasiquote_tok }
-- qualified quasi-quote (#5555)
"[" @qual @varid "|" / { ifExtension qqEnabled }
{ lex_qquasiquote_tok }
}
<0> {
...
...
@@ -562,7 +566,14 @@ data Token
| ITidEscape FastString -- $x
| ITparenEscape -- $(
| ITtyQuote -- ''
| ITquasiQuote (FastString,FastString,RealSrcSpan) -- [:...|...|]
| ITquasiQuote (FastString,FastString,RealSrcSpan)
-- ITquasiQuote(quoter, quote, loc)
-- represents a quasi-quote of the form
-- [quoter| quote |]
| ITqQuasiQuote (FastString,FastString,FastString,RealSrcSpan)
-- ITqQuasiQuote(Qual, quoter, quote, loc)
-- represents a qualified quasi-quote of the form
-- [Qual.quoter| quote |]
-- Arrow notation extension
| ITproc
...
...
@@ -1423,6 +1434,18 @@ getCharOrFail i = do
-- -----------------------------------------------------------------------------
-- QuasiQuote
lex_qquasiquote_tok :: Action
lex_qquasiquote_tok span buf len = do
let (qual, quoter) = splitQualName (stepOn buf) (len - 2) False
quoteStart <- getSrcLoc
quote <- lex_quasiquote quoteStart ""
end <- getSrcLoc
return (L (mkRealSrcSpan (realSrcSpanStart span) end)
(ITqQuasiQuote (qual,
quoter,
mkFastString (reverse quote),
mkRealSrcSpan quoteStart end)))
lex_quasiquote_tok :: Action
lex_quasiquote_tok span buf len = do
let quoter = tail (lexemeToString buf (len - 1))
...
...
compiler/parser/Parser.y.pp
View file @
dc2f65f6
...
...
@@ -350,6 +350,7 @@ TH_ID_SPLICE { L _ (ITidEscape _) } -- $x
'
$
(
' { L _ ITparenEscape } -- $( exp )
TH_TY_QUOTE { L _ ITtyQuote } -- ''T
TH_QUASIQUOTE { L _ (ITquasiQuote _) }
TH_QQUASIQUOTE { L _ (ITqQuasiQuote _) }
%monad { P } { >>= } { return }
%lexer { lexer } { L _ ITeof }
...
...
@@ -1360,6 +1361,10 @@ quasiquote :: { Located (HsQuasiQuote RdrName) }
;
ITquasiQuote
(
quoter
,
quote
,
quoteSpan
)
=
unLoc
$1
;
quoterId
=
mkUnqual
varName
quoter
}
in
L1
(
mkHsQuasiQuote
quoterId
(
RealSrcSpan
quoteSpan
)
quote
)
}
|
TH_QQUASIQUOTE
{
let
{
loc
=
getLoc
$1
;
ITqQuasiQuote
(
qual
,
quoter
,
quote
,
quoteSpan
)
=
unLoc
$1
;
quoterId
=
mkQual
varName
(
qual
,
quoter
)
}
in
sL
(
getLoc
$1
)
(
mkHsQuasiQuote
quoterId
(
RealSrcSpan
quoteSpan
)
quote
)
}
exp
::
{
LHsExpr
RdrName
}
:
infixexp
'::'
sigtype
{
LL
$
ExprWithTySig
$1
$3
}
...
...
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