diff --git a/acat/src/acat.cpp b/acat/src/acat.cpp
index e15151df2409aec0d8fe22f4b0edce64aca5d5a5..e2b2cac849cb581d2ead14ba0dcf3ee0b1f299d7 100644
--- a/acat/src/acat.cpp
+++ b/acat/src/acat.cpp
@@ -15,7 +15,6 @@
 #include "regexp/RegExpParser.h"
 #include "automaton/AutomatonParser.h"
 #include "grammar/GrammarParser.h"
-#include "grammar/RightRegularGrammar.h"
 #include "sax/SaxInterface.h"
 #include "sax/ParserException.h"
 
diff --git a/alib/src/GrammarFactory.h b/alib/src/GrammarFactory.h
index 3eb5e1e7cbb399b443c469ecdf463f366f1a932d..d622843f5e249f29149475150ef0a14c2996a9f0 100644
--- a/alib/src/GrammarFactory.h
+++ b/alib/src/GrammarFactory.h
@@ -10,14 +10,13 @@
 
 #include "sax/Token.h"
 #include "grammar/UnknownGrammar.h"
-#include "grammar/RightRegularGrammar.h"
-#include "grammar/LeftRegularGrammar.h"
-#include "grammar/RightLinearGrammar.h"
-#include "grammar/LeftLinearGrammar.h"
-#include "grammar/ContextFreeGrammar.h"
-#include "grammar/ContextSensitiveGrammar.h"
-
-#include "grammar/UnrestrictedGrammar.h"
+#include "grammar/Regular/RightRegularGrammar.h"
+#include "grammar/Regular/LeftRegularGrammar.h"
+#include "grammar/Linear/RightLinearGrammar.h"
+#include "grammar/Linear/LeftLinearGrammar.h"
+#include "grammar/ContextFree/ContextFreeGrammar.h"
+#include "grammar/ContextSensitive/ContextSensitiveGrammar.h"
+#include "grammar/Unrestricted/UnrestrictedGrammar.h"
 
 namespace grammar {
 
diff --git a/alib/src/grammar/ContextFreeGrammar.cpp b/alib/src/grammar/ContextFree/ContextFreeGrammar.cpp
similarity index 100%
rename from alib/src/grammar/ContextFreeGrammar.cpp
rename to alib/src/grammar/ContextFree/ContextFreeGrammar.cpp
diff --git a/alib/src/grammar/ContextFreeGrammar.h b/alib/src/grammar/ContextFree/ContextFreeGrammar.h
similarity index 98%
rename from alib/src/grammar/ContextFreeGrammar.h
rename to alib/src/grammar/ContextFree/ContextFreeGrammar.h
index febbb040c62d641e38d2b0a9203013800700fb6e..5c481e1b055199b5c99358832cfca8cdd1c46cc9 100644
--- a/alib/src/grammar/ContextFreeGrammar.h
+++ b/alib/src/grammar/ContextFree/ContextFreeGrammar.h
@@ -8,7 +8,7 @@
 #ifndef CONTEXTFREEGRAMMAR_H_
 #define CONTEXTFREEGRAMMAR_H_
 
-#include "Grammar.h"
+#include "../Grammar.h"
 
 namespace grammar {
 
diff --git a/alib/src/grammar/ContextSensitiveGrammar.cpp b/alib/src/grammar/ContextSensitive/ContextSensitiveGrammar.cpp
similarity index 100%
rename from alib/src/grammar/ContextSensitiveGrammar.cpp
rename to alib/src/grammar/ContextSensitive/ContextSensitiveGrammar.cpp
diff --git a/alib/src/grammar/ContextSensitiveGrammar.h b/alib/src/grammar/ContextSensitive/ContextSensitiveGrammar.h
similarity index 98%
rename from alib/src/grammar/ContextSensitiveGrammar.h
rename to alib/src/grammar/ContextSensitive/ContextSensitiveGrammar.h
index d41d68f272fc84275beafb4caeea210db2805004..4b6d8d62c48707fd6fcfd38b86e429fc2ca20494 100644
--- a/alib/src/grammar/ContextSensitiveGrammar.h
+++ b/alib/src/grammar/ContextSensitive/ContextSensitiveGrammar.h
@@ -8,7 +8,7 @@
 #ifndef CONTEXTSENSITIVEGRAMMAR_H_
 #define CONTEXTSENSITIVEGRAMMAR_H_
 
-#include "Grammar.h"
+#include "../Grammar.h"
 
 namespace grammar {
 
diff --git a/alib/src/grammar/LeftLinearGrammar.cpp b/alib/src/grammar/Linear/LeftLinearGrammar.cpp
similarity index 94%
rename from alib/src/grammar/LeftLinearGrammar.cpp
rename to alib/src/grammar/Linear/LeftLinearGrammar.cpp
index f64fd515e2f323fd6a0bf6e8817d59c9fcfed139..325b652b339bcb832871d6a8424b6b8db4a08c79 100644
--- a/alib/src/grammar/LeftLinearGrammar.cpp
+++ b/alib/src/grammar/Linear/LeftLinearGrammar.cpp
@@ -10,12 +10,12 @@
 namespace grammar {
 
 LeftLinearGrammar::LeftLinearGrammar() :
-		Grammar() {
+		LinearGrammar() {
 }
 
 LeftLinearGrammar::LeftLinearGrammar(const set<Symbol>& nonTerminalSymbols, const set<Symbol>& terminalSymbols,
 		const Symbol& startSymbol) :
-		Grammar(nonTerminalSymbols, terminalSymbols, startSymbol) {
+		LinearGrammar(nonTerminalSymbols, terminalSymbols, startSymbol) {
 }
 
 bool LeftLinearGrammar::isValidRule(const Rule& rule) const {
diff --git a/alib/src/grammar/LeftLinearGrammar.h b/alib/src/grammar/Linear/LeftLinearGrammar.h
similarity index 93%
rename from alib/src/grammar/LeftLinearGrammar.h
rename to alib/src/grammar/Linear/LeftLinearGrammar.h
index c82113d3d368414de81d62f72f4475527eac1882..c81f09d022102b2ae1d1cd9dcd78d4f44f6c4c5a 100644
--- a/alib/src/grammar/LeftLinearGrammar.h
+++ b/alib/src/grammar/Linear/LeftLinearGrammar.h
@@ -8,14 +8,14 @@
 #ifndef LEFTLINEARGRAMMAR_H_
 #define LEFTLINEARGRAMMAR_H_
 
-#include "Grammar.h"
+#include "LinearGrammar.h"
 
 namespace grammar {
 
 /**
  * Left linear grammar. Produces regular language.
  */
-class LeftLinearGrammar: public Grammar {
+class LeftLinearGrammar: public LinearGrammar {
 private:
 	/**
 	 * Checks that left side of the Rule contains one symbol which is nonterminal.
diff --git a/alib/src/grammar/Linear/LinearGrammar.cpp b/alib/src/grammar/Linear/LinearGrammar.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..21e534224ed168c1df1991cbb3615e2896bb28db
--- /dev/null
+++ b/alib/src/grammar/Linear/LinearGrammar.cpp
@@ -0,0 +1,20 @@
+/*
+ * LinearGrammar.cpp
+ *
+ *  Created on: Jan 1, 2014
+ *      Author: martin
+ */
+
+#include "LinearGrammar.h"
+
+namespace grammar {
+
+LinearGrammar::LinearGrammar() :
+		Grammar() {
+}
+
+LinearGrammar::LinearGrammar(const set<Symbol>& nonTerminalSymbols, const set<Symbol>& terminalSymbols,
+		const Symbol& startSymbol) :
+		Grammar(nonTerminalSymbols, terminalSymbols, startSymbol) {
+}
+} /* namespace grammar */
diff --git a/alib/src/grammar/Linear/LinearGrammar.h b/alib/src/grammar/Linear/LinearGrammar.h
new file mode 100644
index 0000000000000000000000000000000000000000..9c3a95f736a680a7a80ae74b666ea0791dff08e8
--- /dev/null
+++ b/alib/src/grammar/Linear/LinearGrammar.h
@@ -0,0 +1,26 @@
+/*
+ * LinearGrammar.h
+ *
+ *  Created on: Jan 1, 2014
+ *      Author: Martin Zak
+ */
+
+#ifndef LINEARGRAMMAR_H_
+#define LINEARGRAMMAR_H_
+
+#include "../Grammar.h"
+
+namespace grammar {
+
+/**
+ * Abstract class for linear grammars.
+ */
+class LinearGrammar: public Grammar {
+public:
+	LinearGrammar();
+	LinearGrammar(const set<Symbol>& nonTerminalSymbols, const set<Symbol>& terminalSymbols,
+			const Symbol& startSymbol);
+};
+
+} /* namespace grammar */
+#endif /* LINEARGRAMMAR_H_ */
diff --git a/alib/src/grammar/RightLinearGrammar.cpp b/alib/src/grammar/Linear/RightLinearGrammar.cpp
similarity index 95%
rename from alib/src/grammar/RightLinearGrammar.cpp
rename to alib/src/grammar/Linear/RightLinearGrammar.cpp
index e32612d742d28d779ca2f027a5dff2f552a84ed3..10d34e1fbf4a28d6288df618723c1d183e7f68b3 100644
--- a/alib/src/grammar/RightLinearGrammar.cpp
+++ b/alib/src/grammar/Linear/RightLinearGrammar.cpp
@@ -10,12 +10,12 @@
 namespace grammar {
 
 RightLinearGrammar::RightLinearGrammar() :
-		Grammar() {
+		LinearGrammar() {
 }
 
 RightLinearGrammar::RightLinearGrammar(const set<Symbol>& nonTerminalSymbols, const set<Symbol>& terminalSymbols,
 		const Symbol& startSymbol) :
-		Grammar(nonTerminalSymbols, terminalSymbols, startSymbol) {
+		LinearGrammar(nonTerminalSymbols, terminalSymbols, startSymbol) {
 }
 
 bool RightLinearGrammar::isValidRule(const Rule& rule) const {
diff --git a/alib/src/grammar/RightLinearGrammar.h b/alib/src/grammar/Linear/RightLinearGrammar.h
similarity index 93%
rename from alib/src/grammar/RightLinearGrammar.h
rename to alib/src/grammar/Linear/RightLinearGrammar.h
index 7f0ec1a2092ce907448434401174ebf881654594..8397ece746b750102ad70d73c1a5b7f6f75f4969 100644
--- a/alib/src/grammar/RightLinearGrammar.h
+++ b/alib/src/grammar/Linear/RightLinearGrammar.h
@@ -8,14 +8,14 @@
 #ifndef RIGHTLINEARGRAMMAR_H_
 #define RIGHTLINEARGRAMMAR_H_
 
-#include "Grammar.h"
+#include "LinearGrammar.h"
 
 namespace grammar {
 
 /**
  * Right regular grammar. Produces regular language.
  */
-class RightLinearGrammar: public Grammar {
+class RightLinearGrammar: public LinearGrammar {
 private:
 	/**
 	 * Checks that left side of the Rule contains one symbol which is nonterminal.
diff --git a/alib/src/grammar/LeftRegularGrammar.cpp b/alib/src/grammar/Regular/LeftRegularGrammar.cpp
similarity index 100%
rename from alib/src/grammar/LeftRegularGrammar.cpp
rename to alib/src/grammar/Regular/LeftRegularGrammar.cpp
diff --git a/alib/src/grammar/LeftRegularGrammar.h b/alib/src/grammar/Regular/LeftRegularGrammar.h
similarity index 100%
rename from alib/src/grammar/LeftRegularGrammar.h
rename to alib/src/grammar/Regular/LeftRegularGrammar.h
diff --git a/alib/src/grammar/RegularGrammar.cpp b/alib/src/grammar/Regular/RegularGrammar.cpp
similarity index 100%
rename from alib/src/grammar/RegularGrammar.cpp
rename to alib/src/grammar/Regular/RegularGrammar.cpp
diff --git a/alib/src/grammar/RegularGrammar.h b/alib/src/grammar/Regular/RegularGrammar.h
similarity index 94%
rename from alib/src/grammar/RegularGrammar.h
rename to alib/src/grammar/Regular/RegularGrammar.h
index daa090e269c6a1268118b70dc747f8ee3dc7947b..639326417c1a20b1070b679613ba11d8d756dd76 100644
--- a/alib/src/grammar/RegularGrammar.h
+++ b/alib/src/grammar/Regular/RegularGrammar.h
@@ -8,10 +8,13 @@
 #ifndef REGULARGRAMMAR_H_
 #define REGULARGRAMMAR_H_
 
-#include "Grammar.h"
+#include "../Grammar.h"
 
 namespace grammar {
 
+/**
+ * Abstract class for regular grammars.
+ */
 class RegularGrammar: public Grammar {
 protected:
 	/**
diff --git a/alib/src/grammar/RightRegularGrammar.cpp b/alib/src/grammar/Regular/RightRegularGrammar.cpp
similarity index 100%
rename from alib/src/grammar/RightRegularGrammar.cpp
rename to alib/src/grammar/Regular/RightRegularGrammar.cpp
diff --git a/alib/src/grammar/RightRegularGrammar.h b/alib/src/grammar/Regular/RightRegularGrammar.h
similarity index 100%
rename from alib/src/grammar/RightRegularGrammar.h
rename to alib/src/grammar/Regular/RightRegularGrammar.h
diff --git a/alib/src/grammar/UnrestrictedGrammar.cpp b/alib/src/grammar/Unrestricted/UnrestrictedGrammar.cpp
similarity index 100%
rename from alib/src/grammar/UnrestrictedGrammar.cpp
rename to alib/src/grammar/Unrestricted/UnrestrictedGrammar.cpp
diff --git a/alib/src/grammar/UnrestrictedGrammar.h b/alib/src/grammar/Unrestricted/UnrestrictedGrammar.h
similarity index 97%
rename from alib/src/grammar/UnrestrictedGrammar.h
rename to alib/src/grammar/Unrestricted/UnrestrictedGrammar.h
index 9bd424f3c306708d16c2d7fcee7ff0816afa43d4..eb9802d07bfa8b6e6aa5b649f3cabe65c8f5dcd9 100644
--- a/alib/src/grammar/UnrestrictedGrammar.h
+++ b/alib/src/grammar/Unrestricted/UnrestrictedGrammar.h
@@ -8,7 +8,7 @@
 #ifndef UNRESTRICTEDGRAMMAR_H_
 #define UNRESTRICTEDGRAMMAR_H_
 
-#include "Grammar.h"
+#include "../Grammar.h"
 
 namespace grammar {