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

Cleanup Css_lexer from #372 #444

Merged
merged 10 commits into from
Mar 13, 2024
Merged

Cleanup Css_lexer from #372 #444

merged 10 commits into from
Mar 13, 2024

Conversation

davesnx
Copy link
Owner

@davesnx davesnx commented Mar 12, 2024

There were a few cleanups left after #372 to keep working towards #432

  • Unified lexing sedlexes
  • Added locations on Css_lexer.parse, moved that inside the lexer.
  • Unreachable doesn't failwith. Also, remove assert(false)
  • Rename parse to tokenize

…s. Added a few test cases, refactored lexer_renderer and moved parse and to_string inside Css_lexer
Copy link

vercel bot commented Mar 12, 2024

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

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
styled-ppx ⬜️ Ignored (Inspect) Visit Preview Mar 13, 2024 8:58am

Copy link

github-actions bot commented Mar 12, 2024

New nightly version has been published to the NPM registry: @davesnx/[email protected].
Install it with npm install @davesnx/styled-ppx@nightly or npm install @davesnx/[email protected].

packages/parser/test/css_lexer_test.re Outdated Show resolved Hide resolved
@@ -5,6 +5,8 @@ module Types = Css_types;
module Parser = Css_parser;
module Location = Ppxlib.Location;

let (let.ok) = Result.bind;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not define it near its call site?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Because we use it in a few places, it's almost everywhere.

|> String.concat(" ")
|> String.trim;

let to_debug = tokens =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be defined near its call site since it has one (call site) so far.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It's in the interface of the lexer

);
};

let to_string = tokens =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be defined in the file it is called in until there is a need to have it here.

pos.Lexing.pos_cnum - pos.Lexing.pos_bol,
);

let debug_token = ((token, loc_start, loc_end)) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instance of #444 (comment)

@davesnx davesnx merged commit 37354b8 into main Mar 13, 2024
7 checks passed
@davesnx davesnx deleted the Cleanup-lexer branch March 13, 2024 09:49
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