Convert this primitive into an item in a character class. If this primitive is not a legal item (i.e., an assertion or a dot), then return an error.
(
self,
p: &ParserI<P>,
)
| 67 | /// If this primitive is not a legal item (i.e., an assertion or a dot), |
| 68 | /// then return an error. |
| 69 | fn into_class_set_item<P: Borrow<Parser>>( |
| 70 | self, |
| 71 | p: &ParserI<P>, |
| 72 | ) -> Result<ast::ClassSetItem> { |
| 73 | use ast::ClassSetItem; |
| 74 | use self::Primitive::*; |
| 75 | |
| 76 | match self { |
| 77 | Literal(lit) => Ok(ClassSetItem::Literal(lit)), |
| 78 | Perl(cls) => Ok(ClassSetItem::Perl(cls)), |
| 79 | Unicode(cls) => Ok(ClassSetItem::Unicode(cls)), |
| 80 | x => Err(p.error(*x.span(), ast::ErrorKind::ClassEscapeInvalid)), |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /// Convert this primitive into a literal in a character class. In |
| 85 | /// particular, literals are the only valid items that can appear in |
no test coverage detected