"switch", "case", "default",
"struct", "union",
"break", "continue",
- "typedef"
+ "typedef",
+ "goto"
};
static size_t num_keywords_fg = sizeof(keywords_fg) / sizeof(keywords_fg[0]);
{
int c2;
c2 = lex_fgetc(lex);
+ /* we just used fgetc() so count lines
+ * need to offset a \n the ungetch would recognize
+ */
+ if (!lex->push_line && c2 == '\n')
+ lex->line++;
if (ch == '<' && c2 == ':')
return '[';
else if (ch == ':' && c2 == '>')
if (!strcmp(command, "push")) {
if (!strcmp(param, "line")) {
lex->push_line++;
- --line;
+ if (lex->push_line == 1)
+ --line;
}
else
goto unroll;
if (!strcmp(param, "line")) {
if (lex->push_line)
lex->push_line--;
- --line;
+ if (lex->push_line == 0)
+ --line;
}
else
goto unroll;
case 't': ch = '\t'; break;
case 'f': ch = '\f'; break;
case 'v': ch = '\v'; break;
+ case '\n': ch = '\n'; break;
default:
lexwarn(lex, WARN_UNKNOWN_CONTROL_SEQUENCE, "unrecognized control sequence: \\%c", ch);
/* so we just add the character plus backslash no matter what it actually is */
continue;
}
- lex->sline = lex->line;
- lex->tok.ctx.line = lex->sline;
- lex->tok.ctx.file = lex->name;
-
if (lex->flags.preprocessing && (ch == TOKEN_WHITE || ch == TOKEN_EOL || ch == TOKEN_FATAL)) {
return (lex->tok.ttype = ch);
}
+ lex->sline = lex->line;
+ lex->tok.ctx.line = lex->sline;
+ lex->tok.ctx.file = lex->name;
+
if (lex->eof)
return (lex->tok.ttype = TOKEN_FATAL);
*/
switch (ch)
{
+ /*
case '+':
case '-':
+ */
case '*':
case '/':
case '<':
lex_tokench(lex, ch);
lex_endtoken(lex);
+ lex->tok.ttype = TOKEN_CHARCONST;
/* It's a vector if we can successfully scan 3 floats */
#ifdef WIN32
if (sscanf_s(lex->tok.value, " %f %f %f ",
{
lex->tok.ttype = TOKEN_VECTORCONST;
}
+ else
+ {
+ if (!lex->flags.preprocessing && strlen(lex->tok.value) > 1) {
+ if (lexwarn(lex, WARN_MULTIBYTE_CHARACTER, "multibyte character: `%s`", lex->tok.value))
+ return (lex->tok.ttype = TOKEN_ERROR);
+ }
+ lex->tok.constval.i = lex->tok.value[0];
+ }
return lex->tok.ttype;
}