本文整理汇总了C++中tokenizer::token_error方法的典型用法代码示例。如果您正苦于以下问题:C++ tokenizer::token_error方法的具体用法?C++ tokenizer::token_error怎么用?C++ tokenizer::token_error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tokenizer
的用法示例。
在下文中一共展示了tokenizer::token_error方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: consume
token number::consume(tokenizer &tokens, void *data)
{
token result;
result.type = tokens.token_type<number>();
result.start = tokens.offset+1;
char character = tokens.peek_char(1);
while (character == '-' || character == '+')
{
tokens.next_char();
character = tokens.peek_char(1);
}
enum
{
hexidecimal = 3,
decimal = 2,
octal = 1,
binary = 0,
} type = decimal;
if (tokens.peek_char(1) == '0' && tokens.peek_char(2) == 'x')
{
type = hexidecimal;
tokens.next_char();
tokens.next_char();
}
else if (tokens.peek_char(1) == '0' && tokens.peek_char(2) == 'o')
{
type = octal;
tokens.next_char();
tokens.next_char();
}
else if (tokens.peek_char(1) == '0' && tokens.peek_char(2) == 'b')
{
type = binary;
tokens.next_char();
tokens.next_char();
}
while ((type == hexidecimal && ((character >= '0' && character <= '9') || (character >= 'a' && character <= 'f') || (character >= 'A' && character <= 'F'))) ||
(type == decimal && (character >= '0' && character <= '9')) ||
(type == octal && (character >= '0' && character <= '7')) ||
(type == binary && (character >= '0' && character <= '1')))
{
tokens.next_char();
character = tokens.peek_char(1);
}
if (type == decimal && character == '.' && tokens.peek_char(2) >= '0' && tokens.peek_char(2) <= '9')
{
tokens.next_char();
character = tokens.peek_char(1);
while (character >= '0' && character <= '9')
{
tokens.next_char();
character = tokens.peek_char(1);
}
}
if (type == decimal && (character == 'e' || character == 'E') && (tokens.peek_char(2) == '-' || (tokens.peek_char(2) >= '0' && tokens.peek_char(2) <= '9')))
{
tokens.next_char();
character = tokens.peek_char(1);
if (character == '-')
{
tokens.next_char();
character = tokens.peek_char(1);
}
if (character < '0' || character > '9')
tokens.token_error((string)"exponent has no digits", __FILE__, __LINE__);
while (character >= '0' && character <= '9')
{
tokens.next_char();
character = tokens.peek_char(1);
}
}
result.end = tokens.offset+1;
return result;
}