Compare commits
3 Commits
a6f776e1f2
...
5f72602471
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f72602471 | |||
| 2ec8122a91 | |||
| 07859d3735 |
+27
-6
@@ -73,11 +73,11 @@ lexer_consume_single(struct cescal_state *state, bool skip_ws)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((c = lexer_putback_pop(state)) != '\0') {
|
if ((c = lexer_putback_pop(state)) != '\0') {
|
||||||
if (!skip_ws) {
|
if (skip_ws && !lexer_is_ws(c)) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skip_ws && !lexer_is_ws(c)) {
|
if (!skip_ws && lexer_is_ws(c)) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,6 +300,22 @@ lexer_nom(struct cescal_state *state, struct token *res)
|
|||||||
res->type = TT_COMMA;
|
res->type = TT_COMMA;
|
||||||
res->c = c;
|
res->c = c;
|
||||||
return 0;
|
return 0;
|
||||||
|
case ':':
|
||||||
|
res->type = TT_COLON;
|
||||||
|
res->c = c;
|
||||||
|
return 0;
|
||||||
|
case '+':
|
||||||
|
res->type = TT_PLUS;
|
||||||
|
res->c = c;
|
||||||
|
return 0;
|
||||||
|
case '*':
|
||||||
|
res->type = TT_STAR;
|
||||||
|
res->c = c;
|
||||||
|
return 0;
|
||||||
|
case '=':
|
||||||
|
res->type = TT_EQUALS;
|
||||||
|
res->c = c;
|
||||||
|
return 0;
|
||||||
case '#':
|
case '#':
|
||||||
if ((c = lexer_consume_single(state, true)) == '\0') {
|
if ((c = lexer_consume_single(state, true)) == '\0') {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -314,21 +330,26 @@ lexer_nom(struct cescal_state *state, struct token *res)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
case '/':
|
case '/':
|
||||||
if (lexer_consume_single(state, true) == '/') {
|
if ((c = lexer_consume_single(state, true)) == '/') {
|
||||||
res->type = TT_COMMENT;
|
res->type = TT_COMMENT;
|
||||||
res->c = c;
|
res->c = c;
|
||||||
lexer_skip_comment(state);
|
lexer_skip_comment(state);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
lexer_putback(state, c);
|
||||||
|
res->type = TT_SLASH;
|
||||||
|
return 0;
|
||||||
case '-':
|
case '-':
|
||||||
res->c = c;
|
res->c = c;
|
||||||
if (lexer_consume_single(state, true) == '>') {
|
if ((c = lexer_consume_single(state, true)) == '>') {
|
||||||
res->type = TT_ARROW;
|
res->type = TT_ARROW;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
|
lexer_putback(state, c);
|
||||||
|
res->type = TT_MINUS;
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
if (lexer_scan_ident(state, c, res) == 0) {
|
if (lexer_scan_ident(state, c, res) == 0) {
|
||||||
lexer_check_kw(state, res);
|
lexer_check_kw(state, res);
|
||||||
|
|||||||
@@ -37,7 +37,13 @@ static const char *toktab[] = {
|
|||||||
[TT_LPAREN] = qtok("("),
|
[TT_LPAREN] = qtok("("),
|
||||||
[TT_RPAREN] = qtok(")"),
|
[TT_RPAREN] = qtok(")"),
|
||||||
[TT_COMMA] = qtok(","),
|
[TT_COMMA] = qtok(","),
|
||||||
|
[TT_COLON] = qtok(":"),
|
||||||
[TT_ARROW] = qtok("->"),
|
[TT_ARROW] = qtok("->"),
|
||||||
|
[TT_PLUS] = qtok("+"),
|
||||||
|
[TT_MINUS] = qtok("-"),
|
||||||
|
[TT_SLASH] = qtok("/"),
|
||||||
|
[TT_STAR] = qtok("*"),
|
||||||
|
[TT_EQUALS] = qtok("="),
|
||||||
[TT_DEFINE] = qtok("#define"),
|
[TT_DEFINE] = qtok("#define"),
|
||||||
[TT_IFNDEF] = qtok("#ifndef"),
|
[TT_IFNDEF] = qtok("#ifndef"),
|
||||||
[TT_IFDEF] = qtok("#ifdef"),
|
[TT_IFDEF] = qtok("#ifdef"),
|
||||||
|
|||||||
@@ -17,7 +17,13 @@ typedef enum {
|
|||||||
TT_LPAREN, /* '(' */
|
TT_LPAREN, /* '(' */
|
||||||
TT_RPAREN, /* '( */
|
TT_RPAREN, /* '( */
|
||||||
TT_COMMA, /* ',' */
|
TT_COMMA, /* ',' */
|
||||||
|
TT_COLON, /* ':' */
|
||||||
TT_ARROW, /* '->' */
|
TT_ARROW, /* '->' */
|
||||||
|
TT_PLUS, /* '+' */
|
||||||
|
TT_MINUS, /* '-' */
|
||||||
|
TT_SLASH, /* '/' */
|
||||||
|
TT_STAR, /* '*' */
|
||||||
|
TT_EQUALS, /* '=' */
|
||||||
TT_DEFINE, /* '#define' */
|
TT_DEFINE, /* '#define' */
|
||||||
TT_IFNDEF, /* '#ifndef' */
|
TT_IFNDEF, /* '#ifndef' */
|
||||||
TT_IFDEF, /* '#ifdef' */
|
TT_IFDEF, /* '#ifdef' */
|
||||||
|
|||||||
Reference in New Issue
Block a user