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

Parser render module #530

Merged
merged 36 commits into from
Feb 26, 2025
Merged

Parser render module #530

merged 36 commits into from
Feb 26, 2025

Conversation

zakybilfagih
Copy link
Collaborator

No description provided.

Copy link

vercel bot commented Dec 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
styled-ppx ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 10:21am

@zakybilfagih zakybilfagih requested a review from davesnx December 26, 2024 15:26
Comment on lines +130 to +133
Styled_ppx_css_parser.Parser_location.update_pos_lnum(
at_rule_prelude_loc,
loc,
),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When have you seen this to be needed? Can add a test for it? ^^

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this keeps the cnum of the first location but offset the lnum with the second loc. i've tried using intersection but this seems to work well to highlight the correct error location.

@zakybilfagih zakybilfagih marked this pull request as ready for review January 29, 2025 03:01
@zakybilfagih zakybilfagih requested a review from davesnx February 22, 2025 05:28
Comment on lines +897 to +898
| "<=" => Ok(IDENT("<="))
| ">=" => Ok(IDENT(">="))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are those idents?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we filter out the whitespace, there is no way of telling if there is a whitespace between gt and lt with eq. So I changed the property spec from this

<mf-lt> = '<' '='?
<mf-gt> = '>' '='?

to this

and mf_gt = [%value.rec "'>=' | '>'"]
and mf_lt = [%value.rec "'<=' | '<'"]

So need to handle >= and <= on the lexer

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but why as ident and not OPERATOR? or maybe a token by itself?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh i see what u mean, we can create another token and change the keyword functon on Standard.re

Comment on lines +1 to +8
open Ast;

let rec contains_ampersand = (selector: selector) => {
switch (selector) {
| SimpleSelector(Ampersand) => true
| ComplexSelector(Selector(selector)) => contains_ampersand(selector)
| ComplexSelector(Combinator({left: selector_left, right})) =>
contains_ampersand(selector_left)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we migrate tests for all of this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, should be on Render_test.t, condensed some of them though

/* space between < and = is invalid */
"@media (width < = 33px) {}",
"Parse error while reading token '=' on line 1 at position 15",
"Parse error while reading token '' on line 1 at position 7",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird error message; it should at least render the $.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh yeah, dunno why this is the case

),
//(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason for those comments?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we handle the prelude parsing with the property parser, all of this should pass the first parse

Css_property_parser.Parser.media_query_list,
prelude,
)
|> Result.map(_ => prelude);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do something better with this error here?

@davesnx davesnx merged commit 578cbb9 into main Feb 26, 2025
7 checks passed
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.

2 participants