Skip to content

Commit f265c97

Browse files
committed
Typos, TODOs, etc.
Nothing semantically significant.
1 parent a7471f5 commit f265c97

File tree

15 files changed

+64
-84
lines changed

15 files changed

+64
-84
lines changed

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
1-
# Parser and pretty printer for Rust [![Build Status][4]][5] [![Windows build status][7]][8]
1+
# Parser and pretty-printer for Rust [![Build Status][4]][5] [![Windows build status][7]][8]
22

33
`language-rust` aspires to efficiently and accurately parse and pretty-print the [Rust language][0].
44
The underlying AST structures are also intended to be as similar as possible to the AST `rustc` uses
55
itself. When `language-rust` and `rustc` have diverging AST, the divergence should be detailed in
66
the documentation.
77

8+
A typical use looks like:
9+
10+
```haskell
11+
>>> :set -XTypeApplications +t
12+
>>> import Language.Rust.Syntax
13+
>>>
14+
>>> -- Sample use of the parser
15+
>>> import Language.Rust.Parser
16+
>>> let inp = inputStreamFromString "fn main () { println!(\"Hello world!\"); }"
17+
inp :: InputStream
18+
>>> Right sourceFile = parse @(SourceFile Span) inp
19+
sourceFile :: SourceFile Span
20+
>>>
21+
>>> -- Sample use of the pretty-printer
22+
>>> import Language.Rust.Pretty
23+
>>> pretty sourceFile
24+
fn main() {
25+
println!("Hello world!");
26+
}
27+
it :: Doc b
28+
```
29+
830
## Building
931

10-
## Cabal
32+
### Cabal
1133

1234
With Cabal and GHC, you should only need to run
1335

@@ -16,7 +38,7 @@ With Cabal and GHC, you should only need to run
1638
cabal configure
1739
cabal build
1840

19-
## Stack
41+
### Stack
2042

2143
With the [Stack][1] tool installed, you should only need to run
2244

@@ -33,6 +55,8 @@ from nightly as they come out, but in general will only target compatibility wit
3355

3456
## Bugs
3557

58+
Please report any bugs to the [github issue tracker][9].
59+
3660
### Parser
3761

3862
Any difference between what is accepted by the `rustc` parser and the `language-rust` parser
@@ -60,3 +84,4 @@ pretty-printing.
6084
[6]: https://github.com/rust-lang-nursery/fmt-rfcs
6185
[7]: https://ci.appveyor.com/api/projects/status/um8dxklqmubvn091/branch/master?svg=true
6286
[8]: https://ci.appveyor.com/project/harpocrates/language-rust/branch/master
87+
[9]: https://github.com/harpocrates/language-rust/issues

Setup.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

language-rust.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ stability: alpha
1515
bug-reports: https://github.com/harpocrates/language-rust/issues
1616
category: Language
1717
build-type: Simple
18-
extra-source-files: ChangeLog.md
18+
extra-source-files: ChangeLog.md README.md
1919
cabal-version: >=1.10
2020

2121
source-repository head
@@ -28,7 +28,7 @@ flag useByteStrings
2828

2929
flag enableQuasiquotes
3030
description: Provide the experimental 'Language.Rust.Quote' module
31-
default: True
31+
default: False
3232

3333
library
3434
hs-source-dirs: src

src/Language/Rust/Data/InputStream.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ import qualified Data.ByteString.UTF8 as BE
4141
import qualified Data.Char as Char
4242
#endif
4343

44-
-- TODO: backpack this when GHC 8.2 is released
45-
4644
-- | Read a file into an 'InputStream'
4745
readInputStream :: FilePath -> IO InputStream
4846

src/Language/Rust/Parser/Lexer.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bitwise and, and unary reference), @&&&x&&&y@ lexes into 'AmpersandAmpersand', '
1818
@'IdentTok' "x"@, 'AmpersandAmpersand', 'Ampersand', @'IdentTok' "y"@. Although the parser sometimes
1919
needs to "break apart" tokens, it never has to think about putting them together. That means it can
2020
easily figure out that @&&&x&&&y@ parses as @&(&(&x)) && (&y)@ and not @&(&(&x)) & (&(&y))@ even if
21-
bitwise conjunctions binds more tightly that logical conjunctions.
21+
bitwise conjunctions bind more tightly that logical conjunctions.
2222

2323
This sort of amguity where one tokens need to be broken up occurs for
2424

src/Language/Rust/Parser/ParseMonad.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Stability : experimental
88
Portability : portable
99
1010
Both the lexer and the parser run inside of the 'P' monad. As detailed in the section on
11-
[threaded-lexers](https://www.haskell.org/happy/doc/html/sec-monads.html#sec-lexers) in Happy's
11+
on [threaded-lexers](https://www.haskell.org/happy/doc/html/sec-monads.html#sec-lexers) in Happy's
1212
instruction manual, the benefits of this are that:
1313
1414
* Lexical errors can be treated in the same way as parse errors
@@ -101,7 +101,7 @@ getPState = P $ \ !s pOk _ -> pOk s s
101101

102102
-- | Update the state stored in the parser.
103103
setPState :: PState -> P ()
104-
setPState s = P $ \_ pOk _ -> pOk () s
104+
setPState s = P $ \ _ pOk _ -> pOk () s
105105

106106
-- | Modify the state stored in the parser.
107107
modifyPState :: (PState -> PState) -> P ()
@@ -113,7 +113,7 @@ getPosition = curPos <$> getPState
113113

114114
-- | Update the current position of the parser.
115115
setPosition :: Position -> P ()
116-
setPosition pos = modifyPState $ \s -> s{ curPos = pos }
116+
setPosition pos = modifyPState $ \ s -> s{ curPos = pos }
117117

118118
-- | Retrieve the current 'InputStream' of the parser
119119
getInput :: P InputStream

src/Language/Rust/Pretty/Internal.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ import Language.Rust.Syntax.AST
101101
import Language.Rust.Syntax.Token
102102
import Language.Rust.Syntax.Ident
103103

104-
import Data.Text.Prettyprint.Doc hiding ((<+>), hsep, indent, vsep)
104+
import Data.Text.Prettyprint.Doc hiding ( (<+>), hsep, indent, vsep )
105105

106-
import Data.Maybe (maybeToList, fromMaybe)
107-
import Data.Foldable (toList)
108-
import Data.List (unfoldr)
109-
import Data.List.NonEmpty (NonEmpty(..))
106+
import Data.Maybe ( maybeToList, fromMaybe )
107+
import Data.Foldable ( toList )
108+
import Data.List ( unfoldr )
109+
import Data.List.NonEmpty ( NonEmpty(..) )
110110
import qualified Data.List.NonEmpty as N
111111

112112
-- | Print a source file

src/Language/Rust/Pretty/Resolve.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ data Severity
9797

9898
-- | Localized information about an issue in a syntax tree
9999
data Issue = Issue
100-
{ description :: String -- ^ Description of the issue
101-
, severity :: Severity -- ^ Severity of the issue
100+
{ description :: String -- ^ Description of the issue
101+
, severity :: !Severity -- ^ Severity of the issue
102102
-- | The first element in this list is the syntax tree where the issue occurs. The next elements
103103
-- are increasingly zoomed out syntax trees centered on the first element. In lieu of positional
104104
-- information, this provides a next best way of debugging exactly where the problem is.

src/Language/Rust/QuasiQuote.hs

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/Language/Rust/QuasiQuoteParser.y

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)