aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar
Commit message (Collapse)AuthorAgeFilesLines
* Fix yet another parser infinite loopAleksey Kladov2018-09-082-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is an example of fixing a common parser error: infinite loop due to error recovery. This error typically happens when we parse a list of items and fail to parse a specific item at the current position. One choices is to skip a token and try to parse a list item at the next position. This is a good, but not universal, default. When parsing a list of arguments in a function call, you, for example, don't want to skip over `fn`, because it's most likely that it is a function declaration, and not a mistyped arg: ``` fn foo() { quux(1, 2 fn bar() { } ``` Another choice is to bail out of the loop immediately, but it isn't perfect either: sometimes skipping over garbage helps: ``` quux(1, foo:, 92) // should skip over `:`, b/c that's part of `foo::bar` ``` In general, parser tries to balance these two cases, though we don't have a definitive strategy yet. However, if the parser accidentally neither skips over a token, nor breaks out of the loop, then it becomes stuck in the loop infinitely (there's an internal counter to self-check this situation and panic though), and that's exactly what is demonstrated by the test. To fix such situation, first of all, add the test case to tests/data/parser/{err,fuzz-failures}. Then, run ``` RUST_BACKTRACE=short cargo test --package libsyntax2 ```` to verify that parser indeed panics, and to get an idea what grammar production is the culprit (look for `_list` functions!). In this case, I see ``` 10: libsyntax2::grammar::expressions::atom::match_arm_list at crates/libsyntax2/src/grammar/expressions/atom.rs:309 ``` and that's look like it might be a culprit. I verify it by adding `eprintln!("loopy {:?}", p.current());` and indeed I see that this is printed repeatedly. Diagnosing this a bit shows that the problem is that `pattern::pattern` function does not consume anything if the next token is `let`. That is a good default to make cases like ``` let let foo = 92; ``` where the user hasn't typed the pattern yet, to parse in a reasonable they correctly. For match arms, pretty much the single thing we expect is a pattern, so, for a fix, I introduce a special variant of pattern that does not do recovery.
* Fix block structure in enumsAleksey Kladov2018-09-082-6/+15
|
* simplifyAleksey Kladov2018-09-084-9/+9
|
* Don't get stuck in tuple exprsAleksey Kladov2018-09-081-0/+4
|
* Don't get stuck in macrosAleksey Kladov2018-09-081-1/+6
|
* fix stuck parserAleksey Kladov2018-09-082-2/+11
|
* fix labled expressionsAleksey Kladov2018-09-081-6/+16
|
* Moved TokenSet into it's own file.Zac Winter2018-09-061-1/+2
|
* for types in boundsAleksey Kladov2018-09-042-12/+21
|
* extern blocksAleksey Kladov2018-09-031-0/+1
|
* Complete paramsAleksey Kladov2018-09-032-2/+5
|
* start item recoveryAleksey Kladov2018-08-314-6/+14
|
* add impl works with lifetimesAleksey Kladov2018-08-281-3/+4
|
* Add ret typeAleksey Kladov2018-08-281-0/+2
|
* better pattern recoveryAleksey Kladov2018-08-281-1/+5
|
* better recovery for exprsAleksey Kladov2018-08-281-1/+4
|
* Fix error blocksAleksey Kladov2018-08-274-0/+17
|
* move scopes to fileAleksey Kladov2018-08-271-2/+2
|
* Support if-let in scopesAleksey Kladov2018-08-271-1/+3
|
* fix curly braces parsingAleksey Kladov2018-08-261-2/+9
|
* scope based comletionAleksey Kladov2018-08-261-2/+2
|
* fix stray curlyAleksey Kladov2018-08-261-1/+6
|
* Require semi after exprsAleksey Kladov2018-08-251-3/+8
|
* incremental reparseAleksey Kladov2018-08-251-3/+3
|
* fix assertione error on block parsingAleksey Kladov2018-08-253-9/+8
|
* start incremental reparseAleksey Kladov2018-08-254-3/+9
|
* rename file -> rootAleksey Kladov2018-08-251-1/+1
|
* parameter parsing does not destroy blocksAleksey Kladov2018-08-247-3/+34
|
* nodes for blocksAleksey Kladov2018-08-248-133/+203
|
* Labeled expressionsAleksey Kladov2018-08-242-17/+46
|
* break&continueAleksey Kladov2018-08-241-1/+38
|
* renamesAleksey Kladov2018-08-2411-28/+28
|
* better self-typesAleksey Kladov2018-08-234-9/+11
|
* SimplifyAleksey Kladov2018-08-231-28/+26
|
* renameAleksey Kladov2018-08-233-4/+4
|
* Allow arbitrary self-typesAleksey Kladov2018-08-231-13/+26
|
* allow field attrsAleksey Kladov2018-08-161-3/+9
|
* tt-attrsAleksey Kladov2018-08-162-56/+7
|
* full range exprAleksey Kladov2018-08-141-1/+5
|
* Qualified pathsAleksey Kladov2018-08-134-19/+32
|
* Fix some more bugsAleksey Kladov2018-08-132-2/+8
|
* Optional patterns in trait methodsAleksey Kladov2018-08-133-10/+19
|
* More renamesAleksey Kladov2018-08-134-12/+12
|
* Safer errorsAleksey Kladov2018-08-132-6/+3
|
* renamesAleksey Kladov2018-08-131-7/+7
|
* Fix some parser bugsAleksey Kladov2018-08-134-5/+17
|
* dyn typeAleksey Kladov2018-08-131-1/+12
|
* more renamesAleksey Kladov2018-08-111-2/+2
|
* ENUM_ITEM -> ENUMAleksey Kladov2018-08-111-1/+1
|
* STRUCT_ITEM -> STRUCTAleksey Kladov2018-08-111-1/+1
|