Skip to content

Commit

Permalink
Cleanup Css_lexer from #372 (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx authored Mar 13, 2024
1 parent aaf4610 commit 37354b8
Show file tree
Hide file tree
Showing 14 changed files with 569 additions and 530 deletions.
3 changes: 3 additions & 0 deletions packages/parser/lib/Parser_location.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let to_ppxlib_location ?(loc_ghost = false) (start_pos : Lexing.position)
(end_pos : Lexing.position) : Ppxlib.Location.t =
{ loc_start = start_pos; loc_end = end_pos; loc_ghost }
10 changes: 6 additions & 4 deletions packages/parser/lib/Tokens.re
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
module Parser = Css_parser;

[@deriving show({with_path: false})]
type token =
| EOF
| IDENT(string) // <ident-token>
| BAD_IDENT // TODO: this is needed?
| BAD_IDENT // TODO: Since we don't allow broken syntax, is this needed?
| FUNCTION(string) // <function-token>
| AT_KEYWORD(string) // <at-keyword-token>
| HASH(string, [ | `ID | `UNRESTRICTED]) // <hash-token>
| STRING(string) // <string-token>
| URL(string) // <url-token>
| BAD_URL // <bad-url-token>
| BAD_URL // <bad-url-token> TODO: Since we don't allow broken syntax, is this needed?
| DELIM(string) // <delim-token>
| NUMBER(float) // <number-token>
| PERCENTAGE(float) // <percentage-token>
Expand Down Expand Up @@ -64,8 +66,7 @@ let humanize =
| LEFT_BRACE => "{"
| RIGHT_BRACE => "}";

module Parser = Css_parser;

/* TODO: This should render Token, not Parser.token */
let token_to_string =
fun
| Parser.EOF => ""
Expand Down Expand Up @@ -113,6 +114,7 @@ let token_to_string =
| BAD_URL => "bad url"
| BAD_IDENT => "bad indent";

/* TODO: This should print Token, not Parser.token */
let token_to_debug =
fun
| Parser.EOF => "EOF"
Expand Down
Loading

0 comments on commit 37354b8

Please sign in to comment.