Skip to content

Commit aeacbe1

Browse files
committed
Merge branch 'WIP-happy1.9.6'
2 parents 22c6686 + c301d98 commit aeacbe1

File tree

8 files changed

+279
-177
lines changed

8 files changed

+279
-177
lines changed

language-rust.cabal

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ library
3838
-Wincomplete-uni-patterns
3939
-Wmissing-signatures
4040

41-
build-tools: alex, happy
41+
build-tools: alex, happy >= 1.19.8
4242
default-language: Haskell2010
4343

4444
exposed-modules: Language.Rust.Syntax
@@ -133,10 +133,10 @@ test-suite rustc-tests
133133

134134
type: exitcode-stdio-1.0
135135
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
140140
, bytestring >=0.10
141141
, aeson >= 0.11.0.0
142142
, directory >= 1.2.5.0

sample-sources/expressions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ fn main() {
2323
loop { break; }
2424
'l: loop { break 'l 1; }
2525
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;
2728
let x = { 1 };
2829
let x = unsafe { 1 };
2930
a = 1;

src/Language/Rust/Parser.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ parse' is = case execParser parser is initPos of
5656
Left (pos, msg) -> throw (ParseFail pos msg)
5757
Right x -> x
5858

59-
6059
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 "")
6261
where pushTokens = traverse_ pushToken . reverse
6362

64-
6563
-- | Given a path pointing to a Rust source file, read that file and parse it into a 'SourceFile'
6664
readSourceFile :: FilePath -> IO (SourceFile Span)
6765
readSourceFile fileName = parse' <$> readInputStream fileName

src/Language/Rust/Parser/Internal.y

Lines changed: 222 additions & 166 deletions
Large diffs are not rendered by default.

src/Language/Rust/QuasiQuote.hs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+

src/Language/Rust/QuasiQuoteParser.y

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
{-# OPTIONS_HADDOCK hide, not-home #-}
3+
{-# LANGUAGE OverloadedStrings, OverloadedLists, PartialTypeSignatures #-}
4+
5+
module Language.Rust.QuasiQuoteParser (
6+
7+
) where
8+
9+

src/Language/Rust/Syntax/Token.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ data Token
9292
| Underscore -- ^ @_@ token
9393
| LifetimeTok Ident -- ^ a lifetime (something like @\'a@ or @\'static@)
9494
| Space Space Name -- ^ whitespace
95-
-- ^ doc comment with its contents, whether it is outer/inner, and whether it is inline or not
9695
| Doc String !AttrStyle !Bool
96+
-- ^ doc comment with its contents, whether it is outer/inner, and whether it is inline or not
9797
| Shebang -- ^ @#!@ shebang token
9898
| Eof -- ^ end of file token
9999

test/rustc-tests/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import Test.Framework.Providers.API
3333
main :: IO ()
3434
main = do
3535
-- Check last time `rustc` version was bumped
36-
let lastDay = fromGregorian 2017 8 21
36+
let lastDay = fromGregorian 2017 9 25
3737
today <- utctDay <$> getCurrentTime
3838
when (diffDays today lastDay > 32) $
3939
putStrLn $ "\x1b[33m" ++ "\nThe version of `rustc' the tests will try to use is older than 1 month" ++ "\x1b[0m"

0 commit comments

Comments
 (0)