David Thrane Christiansen
74e7886ce7
feat: custom error recovery in parser ( #3413 )
...
Adds a simple error-recovery mechanism to Lean's parser, similar to
those used in other combinator parsing libraries.
Lean itself isn't very amenable to error recovery with this mechanism,
as it requires global knowledge of the grammar in question to write
recovery rules that don't break backtracking or `<|>`. I only found a
few opportunities.
But for DSLs, this is really important. In particular, Verso parse
errors interacted very badly with Lean parse errors in a way that
required frequent "restart file" commands, but this mechanism allows me
to both recover from Verso parse errors and to have Lean skip the rest
of the file rather than repeatedly trying to parse it as Lean commands.
2024-02-21 14:29:54 +00:00
Henrik Böving
23e49eb519
perf: add prelude to all Lean modules
2024-02-18 14:55:17 -08:00
Kyle Miller
ae6fe098cb
feat: Rust-style raw string literals ( #2929 )
...
For example, `r"\n"` and `r#"The word "this" is in quotes."#`.
Implements #1422
2023-12-20 16:53:08 +00:00
Kyle Miller
bcbcf50442
feat: string gaps for continuing string literals across multiple lines ( #2821 )
...
Implements "gaps" in string literals. These are escape sequences of the
form `"\" newline whitespace+` that have the interpretation of an empty
string. For example,
```
"this is \
a string"
```
is equivalent to `"this is a string"`. These are modeled after string
continuations in
[Rust](https://doc.rust-lang.org/beta/reference/tokens.html#string-literals ).
Implements RFC #2838
2023-12-07 08:17:00 +00:00
int-y1
8d7520b36f
chore: fix typos in comments
2023-10-08 10:46:05 +02:00
Joachim Breitner
b2d668c340
perf: Use flat ByteArrays in Trie ( #2529 )
2023-09-20 13:22:37 +02:00
Sebastian Ullrich
241430aa03
perf: avoid calculating position, revert building unexpected message in mkUnexpectedTokenErrors
2023-09-12 11:42:24 +02:00
Sebastian Ullrich
6c0baf4aed
feat: support reporting range for parser errors, report ranges for expected token errors
2023-09-12 11:42:24 +02:00
Sebastian Ullrich
f4fc8b3e15
refactor: parser error setters
2023-09-12 11:42:24 +02:00
Mario Carneiro
2037094f8c
doc: document all parser aliases ( #2499 )
2023-09-06 09:02:25 +00:00
Marcus Rossel
7ee7595637
doc: fix typos ( #2467 )
2023-08-28 15:40:33 +10:00
Sebastian Ullrich
8fc1af650a
fix: symmetry in orelse antiquotation parsing
2023-07-28 08:36:33 -07:00
Sebastian Ullrich
eceac9f12a
perf: avoid syntax stack copy at orelseFn
2023-07-28 08:36:33 -07:00
Mario Carneiro
e64a2e1a12
fix: misleading indentation
2023-06-17 06:56:53 -07:00
Mario Carneiro
b139a97825
fix: hygieneInfo should not consume whitespace
2023-06-09 15:05:19 +02:00
Mario Carneiro
c20a7bf305
feat: hygieneInfo parser (aka this 2.0)
2023-06-02 16:19:02 +02:00
Sebastian Ullrich
9c9cc017df
fix: ignore empty character literals
2022-12-12 22:59:06 +01:00
Sebastian Ullrich
42a080fae2
fix: comments ending in --/
...
Fixes #1883
2022-11-25 10:32:49 +01:00
Sebastian Ullrich
1f447efa54
doc: update Lean.Parser.Basic
2022-11-11 14:17:21 +01:00
Sebastian Ullrich
30dd28480d
fix: suppressInsideQuot inside quotation
2022-11-11 13:45:41 +01:00
Sebastian Ullrich
22510db004
refactor: simplify parser code using withFn
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
fb941d0827
fix: ensure parser caching is sound re. syntax stack accesses
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
12b267bd8c
refactor: categoryParserOfStack is dead
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
17782fba1a
fix: replace broken ptrEq cache sanity checks with private ParserContext constructor
...
The context is now manipulated using `adaptCacheableContext` and `adaptUncacheableContext`
and created using `ParserFn.run`.
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
d3f7d0350f
refactor: move parser types into separate file
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
9a4626c495
fix: must cache stack of parser evals
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
36189cb51a
chore: simplify parser cache key computation, panic on environment/token table divergence
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
ed03ff9d00
perf: cache leading_parser and syntax as well
...
We better hope the `leading_parser`s are closed terms
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
da6efe1bca
fix: make parser caching sound (I hope?)
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
35509b5e98
refactor: more sensible ordering of declarations in Lean.Parser.Basic
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
246923886a
fix: do not create choice nodes for failed parses
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
57320712f0
fix: extraneous missing items on parser stack
2022-11-11 09:13:02 +01:00
Sebastian Ullrich
7e193a45ce
perf: cache category parses
2022-11-11 09:13:02 +01:00
Leonardo de Moura
2386c401d2
chore: use String.get' and String.next' at Parser/Basic.lean
...
This commit also cleans up old frontend legacy.
2022-11-09 17:06:22 -08:00
Sebastian Ullrich
5249611d75
doc: fix mkAntiquot docstring
2022-11-03 10:07:38 +01:00
Sebastian Ullrich
71e647049f
refactor: lexOrd should not be an instance
2022-09-28 15:57:01 -07:00
Sebastian Ullrich
d0a002ffff
fix: prefer longer parse even if unsuccessful
2022-09-28 15:57:01 -07:00
Mario Carneiro
85119ba9d1
chore: move Std.* data structures to Lean.*
2022-09-26 05:46:04 -07:00
Gabriel Ebner
b1bef71d59
feat: colEq parser
2022-09-19 12:44:43 -07:00
Mario Carneiro
6392c5b456
chore: import reductions
2022-09-15 14:02:38 -07:00
Gabriel Ebner
f1b5fa53f0
chore: use new comment syntax
2022-09-14 08:26:17 -07:00
Leonardo de Moura
e39c3af5bb
chore: remove [inline] from parser combinators
2022-09-08 14:50:27 -07:00
E.W.Ayers
4e7c1e1ec8
fix: missing digits in scientific literal should be an error
2022-08-17 05:57:22 -07:00
E.W.Ayers
9e194e3c3d
fix: add + parser to decimalNumberFn
2022-08-16 07:29:39 -07:00
Mario Carneiro
e816424466
chore: use Category declarations for builtin cats too ( #1400 )
2022-08-03 18:10:54 -07:00
Mario Carneiro
114cd3e5cd
doc: add ParserCategory docs
2022-08-01 11:23:09 +02:00
Mario Carneiro
ecb787529a
refactor: rename ref to declName
2022-08-01 11:23:09 +02:00
Mario Carneiro
711532f5c6
feat: add ref field to ParserCategory
2022-08-01 11:23:09 +02:00
Mario Carneiro
65e2b8a932
feat: track parser names by category
2022-08-01 11:23:09 +02:00
Mario Carneiro
89a16daa81
feat: add TokenMap
2022-07-31 15:42:26 -07:00