Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do some refactoring of parse error handling #79

Merged
merged 1 commit into from
Oct 21, 2020
Merged

Conversation

kaj
Copy link
Owner

@kaj kaj commented Oct 20, 2020

Unify ParseError and Error, so the ParseError case of Error just contains a ParseError struct. This also makes the reporting of a parse error look like in dart-sass, including a copy of the actual text on the line where it occurred.

Add a check method in ParseError to convert a nom::IResult to a Result with a possible ParseError, and get rid of the bogus conversion from nom::IResult to Error::S.

@kaj kaj force-pushed the refactor-parse-error branch 3 times, most recently from 1944235 to 4891cff Compare October 20, 2020 19:19
Unify `ParseError` and `Error`, so the ParseError case of Error just
contains a ParseError struct.

Add a `check` method in `ParseError` to convert a `nom::IResult` to a
`Result` with a possible `ParseError`, and get rid of the bogus
conversion from `nom::IResult` to `Error::S`.
@kaj kaj force-pushed the refactor-parse-error branch from 4891cff to 52098f3 Compare October 20, 2020 21:25
@kaj kaj merged commit 1015726 into master Oct 21, 2020
@kaj kaj deleted the refactor-parse-error branch October 21, 2020 17:29
kaj added a commit that referenced this pull request Oct 25, 2020
Progress: 2320 of 5577 tests passed in dart-sass compatiblilty mode.

### Breaking changes

* The `Item::Comment` enum value now contains a `SassString` rather
  than a `String`.
* The `Error::ParseError` enum value changed, and `ErrPos` is replaced
  with `SourcePos` and `SourceName`.
* The error type of `parse_scss_data` changed to `ParseError`.
* `Unit::dimension()` now returns a `Dimension` rather than a `&str`.

### Improvements

* PR #79: Refactor some error handling.  Relates to #46.
* Improve map parsing (a map is parsed as a plain vec of key/value
  pairs, filterig duplicates happens only when it is evaluated).
* Allow multiple `&` items in the same selector.
* `&` evaluates to null when used as a value without enclosing selector.
* Implement the `@debug` directive.
* Fix `a % b` evaluation for negative values.
* Allow / ignore comments in properties and values.
* Allow `!default` and `!global` in any order on variable declarations.
* Improve `inspect(...)` formatting of list values.
* Refactor and improve arithmetic on different units.
* `ListSeparator` is now `Copy`.
* Allow interpolation in comments.
* Some refactoring

Tested with rustc 1.47.0 (18bf6b4f0 2020-10-07),
1.44.1 (c7087fe00 2020-06-17), 1.42.0 (b8cedc004 2020-03-09),
1.40.0 (73528e339 2019-12-16), 1.38.0 (625451e37 2019-09-23),
1.48.0-beta.5 (4c78178b1 2020-10-21), and
1.49.0-nightly (ffa2e7ae8 2020-10-24).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant