Support for if and endif preprocessor lines.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 28 Feb 2009 22:14:17 +0000 (23:14 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 28 Feb 2009 22:14:17 +0000 (23:14 +0100)
lex.l
parse_adm.y
python/tests/__init__.py

diff --git a/lex.l b/lex.l
index 1b4a9ab1d303f95ba37e4dc548a25b7d809d361c..0b4ff9c2074fe844aeb320ce4be18cdb247d83a5 100644 (file)
--- a/lex.l
+++ b/lex.l
@@ -80,6 +80,9 @@ VALUEOFF { return VALUEOFF; }
 =              { return EQUALS; }
 \[strings\]    { return STRINGSSECTION; }
 
+^#endif[\r\t ]+\n      { return ENDIF; }
+^#if([^\n]+)\n { lineno++; yylval.text = strdup((const char *)yytext); return IF; }
+
 [0-9]+ {
        char *e, *y = yytext;
        yylval.integer = strtol((const char *)yytext, &e, 0);
index 23c5e7730e8e067be7babba7a27e2a0f640c400b..9780684450a1b03ab188c5a7328908551a374cf5 100644 (file)
@@ -63,6 +63,8 @@ extern int yylex (void);
 %token SPIN
 %token EQUALS
 %token STRINGSSECTION
+%token <text> IF
+%token ENDIF
 
 %start admfile
 
@@ -70,7 +72,9 @@ extern int yylex (void);
 
 admfile: classes strings;
 
-classes: /* empty */ | class classes;
+preprocessor: IF | ENDIF;
+
+classes: /* empty */ | class classes | preprocessor classes;
 
 class: CLASS classvalue categories;
 classvalue: CLASS_USER|CLASS_MACHINE;
index 6c2ef79c216ce6b224e58ed8c82ad4ffbeaeeb4a..f7608e519e30df2b0a639e81a92293d6749a812e 100644 (file)
@@ -4,4 +4,5 @@ import unittest
 class AdmTests(unittest.TestCase):
 
     def test_simple(self):
+        self.assertEquals(True, True)