core: lexer: Add operational tokens
Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
+21
-4
@@ -304,6 +304,18 @@ lexer_nom(struct cescal_state *state, struct token *res)
|
||||
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 '#':
|
||||
if ((c = lexer_consume_single(state, true)) == '\0') {
|
||||
return -1;
|
||||
@@ -318,21 +330,26 @@ lexer_nom(struct cescal_state *state, struct token *res)
|
||||
|
||||
return 0;
|
||||
case '/':
|
||||
if (lexer_consume_single(state, true) == '/') {
|
||||
if ((c = lexer_consume_single(state, true)) == '/') {
|
||||
res->type = TT_COMMENT;
|
||||
res->c = c;
|
||||
lexer_skip_comment(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
lexer_putback(state, c);
|
||||
res->type = TT_SLASH;
|
||||
return 0;
|
||||
case '-':
|
||||
res->c = c;
|
||||
if (lexer_consume_single(state, true) == '>') {
|
||||
if ((c = lexer_consume_single(state, true)) == '>') {
|
||||
res->type = TT_ARROW;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
|
||||
lexer_putback(state, c);
|
||||
res->type = TT_MINUS;
|
||||
return 0;
|
||||
default:
|
||||
if (lexer_scan_ident(state, c, res) == 0) {
|
||||
lexer_check_kw(state, res);
|
||||
|
||||
@@ -39,6 +39,11 @@ static const char *toktab[] = {
|
||||
[TT_COMMA] = qtok(","),
|
||||
[TT_COLON] = qtok(":"),
|
||||
[TT_ARROW] = qtok("->"),
|
||||
[TT_PLUS] = qtok("+"),
|
||||
[TT_MINUS] = qtok("-"),
|
||||
[TT_SLASH] = qtok("/"),
|
||||
[TT_STAR] = qtok("*"),
|
||||
[TT_EQUALS] = qtok("="),
|
||||
[TT_DEFINE] = qtok("#define"),
|
||||
[TT_IFNDEF] = qtok("#ifndef"),
|
||||
[TT_IFDEF] = qtok("#ifdef"),
|
||||
|
||||
@@ -19,6 +19,11 @@ typedef enum {
|
||||
TT_COMMA, /* ',' */
|
||||
TT_COLON, /* ':' */
|
||||
TT_ARROW, /* '->' */
|
||||
TT_PLUS, /* '+' */
|
||||
TT_MINUS, /* '-' */
|
||||
TT_SLASH, /* '/' */
|
||||
TT_STAR, /* '*' */
|
||||
TT_EQUALS, /* '=' */
|
||||
TT_DEFINE, /* '#define' */
|
||||
TT_IFNDEF, /* '#ifndef' */
|
||||
TT_IFDEF, /* '#ifdef' */
|
||||
|
||||
Reference in New Issue
Block a user