Skip to content

Commit

Permalink
lexer::parse_name
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Aug 30, 2020
1 parent 5104f2f commit 8d20c39
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions css/parser/src/lexer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
//! https://www.w3.org/TR/selectors-3/#lex

use crate::{Input, PResult};
use crate::{util::PResultExt, Input, PResult};
use nom::bytes::complete::take_while1;
use swc_css_ast::*;

pub(crate) fn parse_ident(i: Input) -> PResult<Text> {}
// pub(crate) fn parse_ident(i: Input) -> PResult<Text> {}

pub(crate) fn parse_name(i: Input) -> PResult<Text> {
take_while1(is_name_char)(i).map_from()
}

/// `[_a-z0-9-]|{nonascii}|{escape}`
fn is_name_char(c: char) -> bool {
match c {
'_' | 'a'..='z' | 'A'..='Z' | '0'..='9' | '-' => true,
// TODO: nonascii
// TODO: escape
_ => false,
}
}

0 comments on commit 8d20c39

Please sign in to comment.