aboutsummaryrefslogtreecommitdiff
path: root/rfc.md
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2017-12-22 00:43:39 +0000
committerAleksey Kladov <[email protected]>2017-12-22 00:43:39 +0000
commita5141fc7520be1e52940c002db53eaf3a2f9e83f (patch)
tree9ef3883c5faafc68ed61c314dafa35623eeeae76 /rfc.md
parenta2aa8214be6d1044cfa3b4cfcf1ea5586edf27fe (diff)
Describe banana-gorilla problem
Diffstat (limited to 'rfc.md')
-rw-r--r--rfc.md41
1 files changed, 40 insertions, 1 deletions
diff --git a/rfc.md b/rfc.md
index bb3863234..0e004670b 100644
--- a/rfc.md
+++ b/rfc.md
@@ -36,7 +36,46 @@ be `0.1.0`.
36# Motivation 36# Motivation
37[motivation]: #motivation 37[motivation]: #motivation
38 38
39Why are we doing this? What use cases does it support? What is the expected outcome? 39"Reusable software component" part is addressed first "IDE ready part"
40second.
41
42
43In theory, parsing can be a pure function, which takes a `&str` as an
44input, and produces a `ParseTree` as an output.
45
46This is great for reusability: for example, you can compile this
47function to WASM and use it for fast client-side validation of syntax
48on the rust playground, or you can develop tools like `rustfmt` on
49stable Rust outside of rustc repository, or you can embed the parser
50into your favorite IDE or code editor.
51
52This is also great for correctness: with such simple interface, it's
53possible to write property-based tests to thoroughly compare two
54different implementations of the parser. It's also straightforward to
55create a comprehensive test suite, because all the inputs and outputs
56are trivially serializable to human-readable text.
57
58Another benefit is performance: with this signature, you can cache a
59parse tree for each file, with trivial strategy for cache invalidation
60(invalidate an entry when the underling file changes). On top of such
61a cache it is possible to build a smart code indexer which maintains
62the set of symbols in the project, watches files for changes and
63automatically reindexes only changed files.
64
65Unfortunately, the current libsyntax is far from this ideal. For
66example, even the lexer makes use of the `FileMap` which is
67essentially a global state of the compiler which represents all know
68files. As a data point, it turned out to be easier to move `rustfmt`
69inside of main `rustc` repository than to move libsyntax outside!
70
71
72
73
74
75
76
77
78
40 79
41# Guide-level explanation 80# Guide-level explanation
42[guide-level-explanation]: #guide-level-explanation 81[guide-level-explanation]: #guide-level-explanation