You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current errors are insuficient to learn how to resolve the issue when the parser is complaining, and lack a bit of context, they are classified by:
Lexing/Parsing errors
The current parser errors regarding variables and missing features is very bad.
Properties raises
Unsupported feature
ppx raise
API error usage
Improving Parser errors
Maybe we can improve ParseError and display the error with the expected next values?
Property errors
Type-check errors
Render error messages with the value ppx payload
Wrong value
display: blocki;^^^^^^Notavalidvaluefor `display`.display defintion expects one of `'block'|'contents'|'flex'|'flow'|'flow-root'|'grid'|'inline'|'inline-block'|'inline-flex'|'inline-grid'|'inline-list-item'|'inline-table'|'list-item'|'none'|'ruby'|'ruby-base'|'ruby-base-container'|'ruby-text'|'ruby-text-container'|'run-in'|'table'|'table-caption'|'table-cell'|'table-column'|'table-column-group'|'table-footer-group'|'table-header-group'|'table-row'|'table-row-group'|'-ms-flexbox'|'-ms-inline-flexbox'|'-ms-grid'|'-ms-inline-grid'|'-webkit-flex'|'-webkit-inline-flex'|'-webkit-box'|'-webkit-inline-box'|'-moz-inline-stack'|'-moz-box'|'-moz-inline-box'`(optional) Maybe you mean `block`?
Wrong value format
Detect when partial matching happens and render the closest as an error message
border: 1pxsolid;^^^^^^^^^^^^^^^^^Missingvaluefor `border`.border defintion is `<line-width>||<line-style> || <color>`
Missing `<color>`
// ----
// TODO: More examples
When a not valid property is passed to our parser (we should differentiate when the property is a valid CSS but we don't support vs a invalid property)
Currently our css_parser.mly generates a ton of warnings. This causes menhir to do a decent job on reducing those, based on the order of tokens, but when you are refactoring the parser this breaks into a lot of pieces.
It’s currently a little unreliable:
stylesheets
declarations
declarations_list
Use the BNF syntax to parse CSS
Go back to a BNF syntax (probably from SASS) or other places
Try to look for occurences where our syntax should be tricter, document them
Current errors
The current errors are insuficient to learn how to resolve the issue when the parser is complaining, and lack a bit of context, they are classified by:
Lexing/Parsing errors
The current parser errors regarding variables and missing features is very bad.
Properties raises
ppx raise
Improving Parser errors
Maybe we can improve ParseError and display the error with the expected next values?
Property errors
Type-check errors
Render error messages with the value ppx payload
Wrong value
Wrong value format
Detect when partial matching happens and render the closest as an error message
Wrong type
Missing property
When a not valid property is passed to our parser (we should differentiate when the property is a valid CSS but we don't support vs a invalid property)
Unsupported interpolation in property
Interpolation broken format
How?
Remove raises on the ppx to add errors in the AST https://ocaml.org/p/ppxlib/0.27.0/doc/manual.html#embedding-the-errors-in-the-ast
Error messages content snippets need to be on ReScript syntax
Make
combine_xor
generate a error from their combinations (This might be very diff)Read about errors in Parser combinators: https://abstractfun.com/2018-11-19-introduction-to-parser-combinators
https://github.com/ebresafegaga/mehir-error-messages
Check how other parsers check errors
[Menhir advanced API example](https://www.notion.so/Menhir-advanced-API-example-85fd4618181c4337aaded2a97b1d4559?pvs=21)
Understand how menhir can help
--exn-carries-state
Remove parsing reduce/shifts
Currently our css_parser.mly generates a ton of warnings. This causes menhir to do a decent job on reducing those, based on the order of tokens, but when you are refactoring the parser this breaks into a lot of pieces.
It’s currently a little unreliable:
Use the BNF syntax to parse CSS
Consider using the Incremental API
Consider rewriting with a handmade parser
Like rescript/syntax: https://github.com/rescript-lang/rescript-compiler/tree/master/res_syntax/src
The text was updated successfully, but these errors were encountered: