]> granicus.if.org Git - icinga2/commitdiff
Implement abstract keyword for mkclass.
authorGunnar Beutner <gunnar@beutner.name>
Mon, 4 Nov 2013 18:30:33 +0000 (19:30 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 5 Nov 2013 07:56:25 +0000 (08:56 +0100)
Refs #4996

tools/mkclass/class_lexer.ll
tools/mkclass/class_parser.yy
tools/mkclass/classcompiler.h

index 11fcbe2d2a6f505bb8e381320c806315ed97f40c..373ad3f78bcddd4d26197903e96a7540814ebd4a 100644 (file)
@@ -118,6 +118,7 @@ static char *lb_steal(lex_buf *lb)
 class                          { return T_CLASS; }
 namespace                      { return T_NAMESPACE; }
 code                           { return T_CODE; }
+abstract                       { return T_ABSTRACT; }
 config                         { yylval->num = FAConfig; return T_FIELD_ATTRIBUTE; }
 state                          { yylval->num = FAState; return T_FIELD_ATTRIBUTE; }
 enum                           { yylval->num = FAEnum; return T_FIELD_ATTRIBUTE; }
index dbdeb536fd2cb8d697ee691d6dab95199f13a6f6..c988c3045527f9a99d8e85f4fa6061d0985bce59 100644 (file)
@@ -50,6 +50,7 @@ using namespace icinga;
 %token T_INCLUDE "include (T_INCLUDE)"
 %token T_CLASS "class (T_CLASS)"
 %token T_CODE "code (T_CODE)"
+%token T_ABSTRACT "abstract (T_ABSTRACT)"
 %token T_NAMESPACE "namespace (T_NAMESPACE)"
 %token T_STRING "string (T_STRING)"
 %token T_ANGLE_STRING "angle_string (T_ANGLE_STRING)"
@@ -72,6 +73,7 @@ using namespace icinga;
 %type <num> field_attributes
 %type <num> field_attribute_list
 %type <num> T_FIELD_ACCESSOR_TYPE
+%type <num> abstract_specifier
 %type <field> class_field
 %type <fields> class_fields
 %type <klass> class
@@ -163,20 +165,32 @@ code: T_CODE T_STRING
        }
        ;
 
-class: T_CLASS T_IDENTIFIER inherits_specifier '{' class_fields '}' ';'
+class: abstract_specifier T_CLASS T_IDENTIFIER inherits_specifier '{' class_fields '}' ';'
        {
                $$ = new Klass();
 
-               $$->Name = $2;
-               free($2);
+               $$->Name = $3;
+               free($3);
 
-               if ($3) {
-                       $$->Parent = $3;
-                       free($3);
+               if ($4) {
+                       $$->Parent = $4;
+                       free($4);
                }
 
-               $$->Fields = *$5;
-               delete $5;
+               $$->Abstract = $1;
+
+               $$->Fields = *$6;
+               delete $6;
+       }
+       ;
+
+abstract_specifier: /* empty */
+       {
+               $$ = false;
+       }
+       | T_ABSTRACT
+       {
+               $$ = true;
        }
        ;
 
index 5ee35379ecf9311a1a56d34d7f3694f003d6106f..c6298d9bcf8925a6ec7bf32eb0a44fa6a35543d9 100644 (file)
@@ -107,6 +107,7 @@ struct Klass
 {
        std::string Name;
        std::string Parent;
+       bool Abstract;
        std::vector<Field> Fields;
 };