[icinga-checkins] icinga.org: icinga2/next: Implement abstract keyword for mkclass.

git at icinga.org git at icinga.org
Tue Nov 5 08:56:54 CET 2013


Module: icinga2
Branch: next
Commit: 84b873fb4e1198de39bbfabe340698b39120cc6a
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=84b873fb4e1198de39bbfabe340698b39120cc6a

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Mon Nov  4 19:30:33 2013 +0100

Implement abstract keyword for mkclass.

Refs #4996

---

 tools/mkclass/class_lexer.ll  |    1 +
 tools/mkclass/class_parser.yy |   30 ++++++++++++++++++++++--------
 tools/mkclass/classcompiler.h |    1 +
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/tools/mkclass/class_lexer.ll b/tools/mkclass/class_lexer.ll
index 11fcbe2..373ad3f 100644
--- a/tools/mkclass/class_lexer.ll
+++ b/tools/mkclass/class_lexer.ll
@@ -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; }
diff --git a/tools/mkclass/class_parser.yy b/tools/mkclass/class_parser.yy
index dbdeb53..c988c30 100644
--- a/tools/mkclass/class_parser.yy
+++ b/tools/mkclass/class_parser.yy
@@ -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;
 	}
 	;
 
diff --git a/tools/mkclass/classcompiler.h b/tools/mkclass/classcompiler.h
index 5ee3537..c6298d9 100644
--- a/tools/mkclass/classcompiler.h
+++ b/tools/mkclass/classcompiler.h
@@ -107,6 +107,7 @@ struct Klass
 {
 	std::string Name;
 	std::string Parent;
+	bool Abstract;
 	std::vector<Field> Fields;
 };
 





More information about the icinga-checkins mailing list