refactor: utils macros

This commit is contained in:
PoiScript 2019-01-14 14:10:12 +08:00
parent 93ed18602a
commit 75362bd2a8
16 changed files with 70 additions and 91 deletions

View file

@ -15,9 +15,9 @@ impl<'a> Macros<'a> {
pub fn parse(src: &'a str) -> Option<(Macros<'a>, usize)> {
starts_with!(src, "{{{");
expect!(src, 3, |c: u8| c.is_ascii_alphabetic());
expect!(src, 3, |c: u8| c.is_ascii_alphabetic())?;
let name = until_while!(src, 3, |c| c == b'}' || c == b'(', valid_name);
let name = until_while!(src, 3, |c| c == b'}' || c == b'(', valid_name)?;
if src.as_bytes()[name] == b'}' {
expect!(src, name + 1, b'}')?;