Explorar el Código

ncd: NCDConfigTokenizer: recognize Foreach and As tokens

ambrop7 hace 13 años
padre
commit
698c757010
Se han modificado 3 ficheros con 14 adiciones y 0 borrados
  1. 6 0
      examples/ncd_tokenizer_test.c
  2. 6 0
      ncd/NCDConfigTokenizer.c
  3. 2 0
      ncd/NCDConfigTokenizer.h

+ 6 - 0
examples/ncd_tokenizer_test.c

@@ -105,6 +105,12 @@ static int tokenizer_output (void *user, int token, char *value, size_t value_le
         case NCD_TOKEN_ELSE:
             printf("else\n");
             break;
+        case NCD_TOKEN_FOREACH:
+            printf("foreach\n");
+            break;
+        case NCD_TOKEN_AS:
+            printf("as\n");
+            break;
         default:
             ASSERT(0);
     }

+ 6 - 0
ncd/NCDConfigTokenizer.c

@@ -123,6 +123,12 @@ void NCDConfigTokenizer_Tokenize (char *str, size_t left, NCDConfigTokenizer_out
         else if (l = data_begins_with(str, left, "else")) {
             token = NCD_TOKEN_ELSE;
         }
+        else if (l = data_begins_with(str, left, "Foreach")) {
+            token = NCD_TOKEN_FOREACH;
+        }
+        else if (l = data_begins_with(str, left, "As")) {
+            token = NCD_TOKEN_AS;
+        }
         else if (is_name_first_char(*str)) {
             l = 1;
             while (l < left && is_name_char(str[l])) {

+ 2 - 0
ncd/NCDConfigTokenizer.h

@@ -52,6 +52,8 @@
 #define NCD_TOKEN_IF 16
 #define NCD_TOKEN_ELIF 17
 #define NCD_TOKEN_ELSE 18
+#define NCD_TOKEN_FOREACH 19
+#define NCD_TOKEN_AS 20
 
 typedef int (*NCDConfigTokenizer_output) (void *user, int token, char *value, size_t value_len, size_t line, size_t line_char);