File tree Expand file tree Collapse file tree 8 files changed +279
-177
lines changed Expand file tree Collapse file tree 8 files changed +279
-177
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ library
38
38
-Wincomplete-uni-patterns
39
39
-Wmissing-signatures
40
40
41
- build-tools : alex, happy
41
+ build-tools : alex, happy >= 1.19.8
42
42
default-language : Haskell2010
43
43
44
44
exposed-modules : Language.Rust.Syntax
@@ -133,10 +133,10 @@ test-suite rustc-tests
133
133
134
134
type : exitcode-stdio-1.0
135
135
default-language : Haskell2010
136
-
137
- build-depends : base >= 4.8 && < 5.0
138
- , process >= 1.4. 3
139
- , prettyprinter >= 1.0
136
+
137
+ build-depends : base >= 4.9 && < 5.0
138
+ , process >= 1.3
139
+ , prettyprinter >= 1.1
140
140
, bytestring >= 0.10
141
141
, aeson >= 0.11.0.0
142
142
, directory >= 1.2.5.0
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ fn main() {
23
23
loop { break ; }
24
24
' l: loop { break ' l 1 ; }
25
25
match x { _ => ( ) }
26
- let x = move |a, b, c| { a + b + c } ;
26
+ let x = move |a, b, c| { a + b + c } ;
27
+ let f = |_||x, y| x+y;
27
28
let x = { 1 } ;
28
29
let x = unsafe { 1 } ;
29
30
a = 1 ;
Original file line number Diff line number Diff line change @@ -56,12 +56,10 @@ parse' is = case execParser parser is initPos of
56
56
Left (pos, msg) -> throw (ParseFail pos msg)
57
57
Right x -> x
58
58
59
-
60
59
execParserTokens :: P a -> [Spanned Token ] -> Position -> Either (Position ,String ) a
61
- execParserTokens p toks pos = execParser (pushTokens toks *> p) (inputStreamFromString " " ) pos
60
+ execParserTokens p toks = execParser (pushTokens toks *> p) (inputStreamFromString " " )
62
61
where pushTokens = traverse_ pushToken . reverse
63
62
64
-
65
63
-- | Given a path pointing to a Rust source file, read that file and parse it into a 'SourceFile'
66
64
readSourceFile :: FilePath -> IO (SourceFile Span )
67
65
readSourceFile fileName = parse' <$> readInputStream fileName
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE TemplateHaskellQuotes #-}
2
+
3
+ module Language.Rust.QuasiQuote (
4
+ expr
5
+ ) where
6
+
7
+ import Language.Rust.Parser.ParseMonad
8
+ import Language.Rust.Parser.Internal
9
+ import Language.Rust.Data.InputStream (inputStreamFromString )
10
+ import Language.Rust.Data.Position (Position (.. ))
11
+
12
+ import Language.Haskell.TH
13
+ import Language.Haskell.TH.Quote (QuasiQuoter (.. ), dataToExpQ , dataToPatQ )
14
+
15
+ import Data.Data (Data )
16
+
17
+ expr :: QuasiQuoter
18
+ expr = QuasiQuoter { quoteExp = expr'
19
+ , quotePat = notExprFail
20
+ , quoteType = noExprFail
21
+ , quoteDec = notExprFail
22
+ }
23
+ where
24
+ notExprFail :: String -> Q a
25
+ notExprFail _ = fail " This quasiquoter only works for expressions"
26
+
27
+ exprParser
28
+
29
+ expr' :: String -> Q Exp
30
+ expr' s =
31
+ case parsePartial (inputStreamFromString s) of
32
+ Left (pos,msg) -> fail $ " Could not parse the type in the quasiquote
33
+ let inp = inputStreamFromString s
34
+ ty_either = parsePartial inp
35
+ in
36
+
37
+
38
+
Original file line number Diff line number Diff line change
1
+ {
2
+ {-# OPTIONS_HADDOCK hide, not -home #-}
3
+ {-# LANGUAGE OverloadedStrings, OverloadedLists, PartialTypeSignatures #-}
4
+
5
+ module Language.Rust .QuasiQuoteParser (
6
+
7
+ ) where
8
+
9
+
Original file line number Diff line number Diff line change @@ -92,8 +92,8 @@ data Token
92
92
| Underscore -- ^ @_@ token
93
93
| LifetimeTok Ident -- ^ a lifetime (something like @\'a@ or @\'static@)
94
94
| Space Space Name -- ^ whitespace
95
- -- ^ doc comment with its contents, whether it is outer/inner, and whether it is inline or not
96
95
| Doc String ! AttrStyle ! Bool
96
+ -- ^ doc comment with its contents, whether it is outer/inner, and whether it is inline or not
97
97
| Shebang -- ^ @#!@ shebang token
98
98
| Eof -- ^ end of file token
99
99
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ import Test.Framework.Providers.API
33
33
main :: IO ()
34
34
main = do
35
35
-- Check last time `rustc` version was bumped
36
- let lastDay = fromGregorian 2017 8 21
36
+ let lastDay = fromGregorian 2017 9 25
37
37
today <- utctDay <$> getCurrentTime
38
38
when (diffDays today lastDay > 32 ) $
39
39
putStrLn $ " \x1b [33m" ++ " \n The version of `rustc' the tests will try to use is older than 1 month" ++ " \x1b [0m"
You can’t perform that action at this time.
0 commit comments