Browse Source

Restoring authorship annotation for Alexander Gololobov <davenger@yandex-team.com>. Commit 2 of 2.

Alexander Gololobov 3 years ago
parent
commit
fccc62e9bf

+ 6 - 6
contrib/libs/grpc/src/cpp/common/channel_arguments.cc

@@ -65,15 +65,15 @@ ChannelArguments::ChannelArguments(const ChannelArguments& other)
   }
 }
 
-ChannelArguments::~ChannelArguments() { 
+ChannelArguments::~ChannelArguments() {
   grpc_core::ExecCtx exec_ctx;
   for (auto& arg : args_) {
     if (arg.type == GRPC_ARG_POINTER) {
       arg.value.pointer.vtable->destroy(arg.value.pointer.p);
-    } 
-  } 
-} 
- 
+    }
+  }
+}
+
 void ChannelArguments::Swap(ChannelArguments& other) {
   args_.swap(other.args_);
   strings_.swap(other.strings_);
@@ -190,7 +190,7 @@ void ChannelArguments::SetPointerWithVtable(
   arg.type = GRPC_ARG_POINTER;
   strings_.push_back(key);
   arg.key = const_cast<char*>(strings_.back().c_str());
-  arg.value.pointer.p = vtable->copy(value); 
+  arg.value.pointer.p = vtable->copy(value);
   arg.value.pointer.vtable = vtable;
   args_.push_back(arg);
 }

+ 2 - 2
contrib/libs/pire/Makefile.am

@@ -1,2 +1,2 @@
-ACLOCAL_AMFLAGS = -I m4 
-SUBDIRS = pire tests pkg samples 
+ACLOCAL_AMFLAGS = -I m4
+SUBDIRS = pire tests pkg samples

+ 6 - 6
contrib/libs/pire/README

@@ -1,6 +1,6 @@
-This is PIRE, Perl Incompatible Regular Expressions library. 
- 
-For detailed information about what it is, how to build and use it, 
-see http://wiki.yandex-team.ru/DmitrijjProkopcev/pire . 
- 
-Please report bugs to dprokoptsev@yandex-team.ru or davenger@yandex-team.ru. 
+This is PIRE, Perl Incompatible Regular Expressions library.
+
+For detailed information about what it is, how to build and use it,
+see http://wiki.yandex-team.ru/DmitrijjProkopcev/pire .
+
+Please report bugs to dprokoptsev@yandex-team.ru or davenger@yandex-team.ru.

+ 47 - 47
contrib/libs/pire/configure.ac

@@ -1,47 +1,47 @@
-AC_PREREQ([2.63]) 
-AC_INIT([pire], [0.0.2], [dprokoptsev@yandex-team.ru]) 
-AM_INIT_AUTOMAKE([foreign -Wall]) 
-AC_CONFIG_SRCDIR([pire/classes.cpp]) 
-AC_CONFIG_HEADERS([config.h]) 
-AC_CONFIG_MACRO_DIR([m4]) 
- 
-AC_LANG_CPLUSPLUS 
- 
-# Require neccessary binaries to build ourselves 
-AC_PROG_CXX 
-AC_PROG_CC 
-AC_PROG_LEX 
-AC_PROG_YACC 
-AC_PROG_LIBTOOL 
- 
-# Check for cppunit 
-AM_PATH_CPPUNIT([0.0.0],[with_unittests=yes],[ 
-	AC_WARN([cppunit not found. Unit tests will not compile and run.]) 
-	with_unittests=no 
-]) 
-AM_CONDITIONAL([WITH_UNITTESTS], [test x"$with_unittests" = xyes]) 
- 
-# Just for conscience' sake 
-AC_CHECK_HEADERS([stdlib.h string.h sys/time.h]) 
-AC_HEADER_STDBOOL 
-AC_C_INLINE 
-AC_TYPE_SIZE_T 
-AC_CHECK_TYPES([ptrdiff_t]) 
-AC_FUNC_ERROR_AT_LINE 
-AC_FUNC_MALLOC 
-AC_CHECK_FUNCS([memset strchr]) 
- 
-# Require little-endian platform 
-AC_C_BIGENDIAN 
-if test x"$ac_cv_c_bigendian" = xyes; then 
-	AC_ERROR([pire has not been ported to big-endian platforms yet.]) 
-fi 
- 
-# Optional features 
-AC_ARG_ENABLE([extra], AS_HELP_STRING([--enable-extra], [Add extra functionality (capturing scanner, etc...)])) 
-AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Make Pire dump all constructed FSMs to std::clog (useless unless debugging Pire)])) 
-AM_CONDITIONAL([ENABLE_EXTRA], [test x"$enable_extra" = xyes]) 
-AM_CONDITIONAL([ENABLE_DEBUG], [test x"$enable_debug" = xyes]) 
- 
-AC_CONFIG_FILES([Makefile pire/Makefile tests/Makefile pkg/Makefile samples/Makefile samples/bench/Makefile]) 
-AC_OUTPUT 
+AC_PREREQ([2.63])
+AC_INIT([pire], [0.0.2], [dprokoptsev@yandex-team.ru])
+AM_INIT_AUTOMAKE([foreign -Wall])
+AC_CONFIG_SRCDIR([pire/classes.cpp])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+
+AC_LANG_CPLUSPLUS
+
+# Require neccessary binaries to build ourselves
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_LEX
+AC_PROG_YACC
+AC_PROG_LIBTOOL
+
+# Check for cppunit
+AM_PATH_CPPUNIT([0.0.0],[with_unittests=yes],[
+	AC_WARN([cppunit not found. Unit tests will not compile and run.])
+	with_unittests=no
+])
+AM_CONDITIONAL([WITH_UNITTESTS], [test x"$with_unittests" = xyes])
+
+# Just for conscience' sake
+AC_CHECK_HEADERS([stdlib.h string.h sys/time.h])
+AC_HEADER_STDBOOL
+AC_C_INLINE
+AC_TYPE_SIZE_T
+AC_CHECK_TYPES([ptrdiff_t])
+AC_FUNC_ERROR_AT_LINE
+AC_FUNC_MALLOC
+AC_CHECK_FUNCS([memset strchr])
+
+# Require little-endian platform
+AC_C_BIGENDIAN
+if test x"$ac_cv_c_bigendian" = xyes; then
+	AC_ERROR([pire has not been ported to big-endian platforms yet.])
+fi
+
+# Optional features
+AC_ARG_ENABLE([extra], AS_HELP_STRING([--enable-extra], [Add extra functionality (capturing scanner, etc...)]))
+AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Make Pire dump all constructed FSMs to std::clog (useless unless debugging Pire)]))
+AM_CONDITIONAL([ENABLE_EXTRA], [test x"$enable_extra" = xyes])
+AM_CONDITIONAL([ENABLE_DEBUG], [test x"$enable_debug" = xyes])
+
+AC_CONFIG_FILES([Makefile pire/Makefile tests/Makefile pkg/Makefile samples/Makefile samples/bench/Makefile])
+AC_OUTPUT

+ 114 - 114
contrib/libs/pire/pire/Makefile.am

@@ -1,121 +1,121 @@
- 
-AM_CXXFLAGS = -Wall 
-if ENABLE_DEBUG 
-AM_CXXFLAGS += -DPIRE_DEBUG 
-endif 
-if ENABLE_CHECKED 
-AM_CXXFLAGS += -DPIRE_CHECKED 
-endif 
- 
-lib_LTLIBRARIES = libpire.la 
-libpire_la_SOURCES = \ 
-	align.h \ 
-	any.h \ 
-	classes.cpp \ 
-	defs.h \ 
-	determine.h \ 
-	encoding.cpp \ 
-	encoding.h \ 
-	extra.h \ 
-	fsm.cpp \ 
-	fsm.h \ 
-	fwd.h \ 
-	glue.cpp \ 
-	glue.h \ 
+
+AM_CXXFLAGS = -Wall
+if ENABLE_DEBUG
+AM_CXXFLAGS += -DPIRE_DEBUG
+endif
+if ENABLE_CHECKED
+AM_CXXFLAGS += -DPIRE_CHECKED
+endif
+
+lib_LTLIBRARIES = libpire.la
+libpire_la_SOURCES = \
+	align.h \
+	any.h \
+	classes.cpp \
+	defs.h \
+	determine.h \
+	encoding.cpp \
+	encoding.h \
+	extra.h \
+	fsm.cpp \
+	fsm.h \
+	fwd.h \
+	glue.cpp \
+	glue.h \
 	minimize.h \
 	half_final_fsm.cpp \
 	half_final_fsm.h \
-	partition.h \ 
-	pire.h \ 
-	re_lexer.cpp \ 
-	re_lexer.h \ 
-	run.h \ 
-	scanner_io.cpp \ 
-	vbitset.h \ 
-	re_parser.ypp \ 
+	partition.h \
+	pire.h \
+	re_lexer.cpp \
+	re_lexer.h \
+	run.h \
+	scanner_io.cpp \
+	vbitset.h \
+	re_parser.ypp \
 	scanners/half_final.h \
-	scanners/loaded.h \ 
-	scanners/multi.h \ 
-	scanners/slow.h \ 
-	scanners/simple.h \ 
-	scanners/common.h \ 
-	scanners/pair.h \ 
-	stub/stl.h \ 
-	stub/lexical_cast.h \ 
-	stub/saveload.h \ 
-	stub/singleton.h \ 
-	stub/utf8.cpp \ 
-	stub/utf8.h \ 
-	stub/noncopyable.h \ 
-	stub/codepage_h.h \ 
-	stub/doccodes_h.h \ 
-	stub/unidata_h.h \ 
-	stub/unidata_cpp.h 
- 
-if ENABLE_EXTRA 
-libpire_la_SOURCES += \ 
-	extra/capture.cpp \ 
-	extra/capture.h \ 
-	extra/count.cpp \ 
-	extra/count.h \ 
-	extra/glyphs.cpp \ 
-	extra/glyphs.h 
-endif 
- 
-pire_hdrdir = $(includedir)/pire 
-pire_hdr_HEADERS = \ 
-	align.h \ 
-	any.h \ 
-	defs.h \ 
-	determine.h \ 
-	encoding.h \ 
-	extra.h \ 
-	fsm.h \ 
-	fwd.h \ 
-	glue.h \ 
+	scanners/loaded.h \
+	scanners/multi.h \
+	scanners/slow.h \
+	scanners/simple.h \
+	scanners/common.h \
+	scanners/pair.h \
+	stub/stl.h \
+	stub/lexical_cast.h \
+	stub/saveload.h \
+	stub/singleton.h \
+	stub/utf8.cpp \
+	stub/utf8.h \
+	stub/noncopyable.h \
+	stub/codepage_h.h \
+	stub/doccodes_h.h \
+	stub/unidata_h.h \
+	stub/unidata_cpp.h
+
+if ENABLE_EXTRA
+libpire_la_SOURCES += \
+	extra/capture.cpp \
+	extra/capture.h \
+	extra/count.cpp \
+	extra/count.h \
+	extra/glyphs.cpp \
+	extra/glyphs.h
+endif
+
+pire_hdrdir = $(includedir)/pire
+pire_hdr_HEADERS = \
+	align.h \
+	any.h \
+	defs.h \
+	determine.h \
+	encoding.h \
+	extra.h \
+	fsm.h \
+	fwd.h \
+	glue.h \
 	minimize.h \
 	half_final_fsm.h \
-	partition.h \ 
-	pire.h \ 
-	re_lexer.h \ 
-	re_parser.h \ 
-	run.h \ 
-	static_assert.h \ 
-	vbitset.h 
- 
-if ENABLE_EXTRA 
-pire_extradir = $(includedir)/pire/extra 
-pire_extra_HEADERS = \ 
-	extra/capture.h \ 
-	extra/count.h \ 
-	extra/glyphs.h 
-endif 
- 
-pire_scannersdir = $(includedir)/pire/scanners 
-pire_scanners_HEADERS = \ 
-	scanners/common.h \ 
+	partition.h \
+	pire.h \
+	re_lexer.h \
+	re_parser.h \
+	run.h \
+	static_assert.h \
+	vbitset.h
+
+if ENABLE_EXTRA
+pire_extradir = $(includedir)/pire/extra
+pire_extra_HEADERS = \
+	extra/capture.h \
+	extra/count.h \
+	extra/glyphs.h
+endif
+
+pire_scannersdir = $(includedir)/pire/scanners
+pire_scanners_HEADERS = \
+	scanners/common.h \
 	scanners/half_final.h \
-	scanners/multi.h \ 
-	scanners/slow.h \ 
-	scanners/simple.h \ 
-	scanners/loaded.h \ 
-	scanners/pair.h 
- 
-pire_stubdir = $(includedir)/pire/stub 
-pire_stub_HEADERS = \ 
-	stub/stl.h \ 
-	stub/defaults.h \ 
-	stub/singleton.h \ 
-	stub/saveload.h \ 
-	stub/lexical_cast.h 
- 
-bin_PROGRAMS = pire_inline  
- 
-pire_inline_SOURCES = inline.lpp stub/hacks.h stub/memstreams.h 
-pire_inline_LDADD = libpire.la 
- 
-BUILT_SOURCES = re_parser.h re_parser.cpp 
-CLEANFILES    = re_parser.h re_parser.cpp 
- 
-AM_YFLAGS = -d 
- 
+	scanners/multi.h \
+	scanners/slow.h \
+	scanners/simple.h \
+	scanners/loaded.h \
+	scanners/pair.h
+
+pire_stubdir = $(includedir)/pire/stub
+pire_stub_HEADERS = \
+	stub/stl.h \
+	stub/defaults.h \
+	stub/singleton.h \
+	stub/saveload.h \
+	stub/lexical_cast.h
+
+bin_PROGRAMS = pire_inline 
+
+pire_inline_SOURCES = inline.lpp stub/hacks.h stub/memstreams.h
+pire_inline_LDADD = libpire.la
+
+BUILT_SOURCES = re_parser.h re_parser.cpp
+CLEANFILES    = re_parser.h re_parser.cpp
+
+AM_YFLAGS = -d
+

+ 99 - 99
contrib/libs/pire/pire/align.h

@@ -1,103 +1,103 @@
-/* 
- * align.h -- functions for positioning streams and memory pointers 
- *            to word boundaries 
+/*
+ * align.h -- functions for positioning streams and memory pointers
+ *            to word boundaries
+ *
+ * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>,
+ *                          Alexander Gololobov <agololobov@gmail.com>
+ *
+ * This file is part of Pire, the Perl Incompatible
+ * Regular Expressions library.
+ *
+ * Pire is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
  * 
- * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>, 
- *                          Alexander Gololobov <agololobov@gmail.com> 
- * 
- * This file is part of Pire, the Perl Incompatible 
- * Regular Expressions library. 
- * 
- * Pire is free software: you can redistribute it and/or modify 
- * it under the terms of the GNU Lesser Public License as published by 
- * the Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- *  
- * Pire is distributed in the hope that it will be useful, 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- * GNU Lesser Public License for more details. 
- * You should have received a copy of the GNU Lesser Public License 
- * along with Pire.  If not, see <http://www.gnu.org/licenses>. 
- */ 
- 
- 
-#ifndef PIRE_ALIGN_H 
-#define PIRE_ALIGN_H 
- 
+ * Pire is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser Public License for more details.
+ * You should have received a copy of the GNU Lesser Public License
+ * along with Pire.  If not, see <http://www.gnu.org/licenses>.
+ */
+
+
+#ifndef PIRE_ALIGN_H
+#define PIRE_ALIGN_H
+
 #include <contrib/libs/pire/pire/stub/stl.h>
 #include <contrib/libs/pire/pire/stub/saveload.h>
 
-#include "platform.h" 
- 
-namespace Pire { 
-	 
-	namespace Impl { 
- 
-		template<class T> 
-		inline T AlignUp(T t, size_t bound) 
-		{ 
-			return (T) (((size_t) t + (bound-1)) & ~(bound-1)); 
-		} 
- 
-		template<class T> 
-		inline T AlignDown(T t, size_t bound) 
-		{ 
-			return (T) ((size_t) t & ~(bound-1)); 
-		} 
-		 
-		inline void AlignSave(yostream* s, size_t size) 
-		{ 
-			size_t tail = AlignUp(size, sizeof(size_t)) - size; 
-			if (tail) { 
-				static const char buf[sizeof(MaxSizeWord)] = {0}; 
-				SavePodArray(s, buf, tail); 
-			} 
-		} 
- 
-		inline void AlignLoad(yistream* s, size_t size) 
-		{ 
-			size_t tail = AlignUp(size, sizeof(size_t)) - size; 
-			if (tail) { 
-				char buf[sizeof(MaxSizeWord)]; 
-				LoadPodArray(s, buf, tail); 
-			} 
-		} 
-		 
-		template<class T> 
-		inline void AlignedSaveArray(yostream* s, const T* array, size_t count) 
-		{ 
-			SavePodArray(s, array, count); 
-			AlignSave(s, sizeof(*array) * count); 
-		} 
- 
-		template<class T> 
-		inline void AlignedLoadArray(yistream* s, T* array, size_t count) 
-		{ 
-			LoadPodArray(s, array, count); 
-			AlignLoad(s, sizeof(*array) * count); 
-		} 
- 
-		template<class T> 
-		inline bool IsAligned(T t, size_t bound) 
-		{ 
-			return ((size_t) t & (bound-1)) == 0; 
-		} 
-		 
-		inline const void* AlignPtr(const size_t*& p, size_t& size) 
-		{ 
-			if (!IsAligned(p, sizeof(size_t))) { 
-				const size_t* next = AlignUp(p, sizeof(size_t)); 
-				if (next > p+size) 
-					throw Error("EOF reached in NPire::Impl::align"); 
-				size -= (next - p); 
-				p = next; 
-			} 
-			return (const void*) p; 
-		} 
- 
-	} 
-	 
-} 
- 
-#endif 
+#include "platform.h"
+
+namespace Pire {
+	
+	namespace Impl {
+
+		template<class T>
+		inline T AlignUp(T t, size_t bound)
+		{
+			return (T) (((size_t) t + (bound-1)) & ~(bound-1));
+		}
+
+		template<class T>
+		inline T AlignDown(T t, size_t bound)
+		{
+			return (T) ((size_t) t & ~(bound-1));
+		}
+		
+		inline void AlignSave(yostream* s, size_t size)
+		{
+			size_t tail = AlignUp(size, sizeof(size_t)) - size;
+			if (tail) {
+				static const char buf[sizeof(MaxSizeWord)] = {0};
+				SavePodArray(s, buf, tail);
+			}
+		}
+
+		inline void AlignLoad(yistream* s, size_t size)
+		{
+			size_t tail = AlignUp(size, sizeof(size_t)) - size;
+			if (tail) {
+				char buf[sizeof(MaxSizeWord)];
+				LoadPodArray(s, buf, tail);
+			}
+		}
+		
+		template<class T>
+		inline void AlignedSaveArray(yostream* s, const T* array, size_t count)
+		{
+			SavePodArray(s, array, count);
+			AlignSave(s, sizeof(*array) * count);
+		}
+
+		template<class T>
+		inline void AlignedLoadArray(yistream* s, T* array, size_t count)
+		{
+			LoadPodArray(s, array, count);
+			AlignLoad(s, sizeof(*array) * count);
+		}
+
+		template<class T>
+		inline bool IsAligned(T t, size_t bound)
+		{
+			return ((size_t) t & (bound-1)) == 0;
+		}
+		
+		inline const void* AlignPtr(const size_t*& p, size_t& size)
+		{
+			if (!IsAligned(p, sizeof(size_t))) {
+				const size_t* next = AlignUp(p, sizeof(size_t));
+				if (next > p+size)
+					throw Error("EOF reached in NPire::Impl::align");
+				size -= (next - p);
+				p = next;
+			}
+			return (const void*) p;
+		}
+
+	}
+	
+}
+
+#endif

+ 123 - 123
contrib/libs/pire/pire/any.h

@@ -1,131 +1,131 @@
-/* 
- * any.h -- a wrapper capable of holding a value of arbitrary type. 
+/*
+ * any.h -- a wrapper capable of holding a value of arbitrary type.
+ *
+ * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>,
+ *                          Alexander Gololobov <agololobov@gmail.com>
+ *
+ * This file is part of Pire, the Perl Incompatible
+ * Regular Expressions library.
+ *
+ * Pire is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
  * 
- * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>, 
- *                          Alexander Gololobov <agololobov@gmail.com> 
- * 
- * This file is part of Pire, the Perl Incompatible 
- * Regular Expressions library. 
- * 
- * Pire is free software: you can redistribute it and/or modify 
- * it under the terms of the GNU Lesser Public License as published by 
- * the Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- *  
- * Pire is distributed in the hope that it will be useful, 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- * GNU Lesser Public License for more details. 
- * You should have received a copy of the GNU Lesser Public License 
- * along with Pire.  If not, see <http://www.gnu.org/licenses>. 
- */ 
- 
- 
-#ifndef PIRE_ANY_H 
-#define PIRE_ANY_H 
- 
- 
-#include <typeinfo> 
- 
+ * Pire is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser Public License for more details.
+ * You should have received a copy of the GNU Lesser Public License
+ * along with Pire.  If not, see <http://www.gnu.org/licenses>.
+ */
+
+
+#ifndef PIRE_ANY_H
+#define PIRE_ANY_H
+
+
+#include <typeinfo>
+
 #include <contrib/libs/pire/pire/stub/stl.h>
- 
-namespace Pire { 
- 
-class Any { 
- 
-public: 
+
+namespace Pire {
+
+class Any {
+
+public:
 	Any() = default;
- 
-	Any(const Any& any) 
-	{ 
-		if (any.h) 
-			h = any.h->Duplicate(); 
-	} 
- 
-	Any& operator= (Any any) 
-	{ 
-		any.Swap(*this); 
-		return *this; 
-	} 
- 
-	template <class T> 
-	Any(const T& t) 
-		: h(new Holder<T>(t)) 
-	{ 
-	} 
- 
-	bool Empty() const { 
-		return !h; 
-	} 
-	template <class T> 
-	bool IsA() const { 
-		return h && h->IsA(typeid(T)); 
-	} 
- 
-	template <class T> 
-	T& As() 
-	{ 
-		if (h && IsA<T>()) 
-			return *reinterpret_cast<T*>(h->Ptr()); 
-		else 
-			throw Pire::Error("type mismatch"); 
-	} 
- 
-	template <class T> 
-	const T& As() const 
-	{ 
-		if (h && IsA<T>()) 
-			return *reinterpret_cast<const T*>(h->Ptr()); 
-		else 
-			throw Pire::Error("type mismatch"); 
-	} 
- 
+
+	Any(const Any& any)
+	{
+		if (any.h)
+			h = any.h->Duplicate();
+	}
+
+	Any& operator= (Any any)
+	{
+		any.Swap(*this);
+		return *this;
+	}
+
+	template <class T>
+	Any(const T& t)
+		: h(new Holder<T>(t))
+	{
+	}
+
+	bool Empty() const {
+		return !h;
+	}
+	template <class T>
+	bool IsA() const {
+		return h && h->IsA(typeid(T));
+	}
+
+	template <class T>
+	T& As()
+	{
+		if (h && IsA<T>())
+			return *reinterpret_cast<T*>(h->Ptr());
+		else
+			throw Pire::Error("type mismatch");
+	}
+
+	template <class T>
+	const T& As() const
+	{
+		if (h && IsA<T>())
+			return *reinterpret_cast<const T*>(h->Ptr());
+		else
+			throw Pire::Error("type mismatch");
+	}
+
 	void Swap(Any& a) noexcept {
-		DoSwap(h, a.h); 
-	} 
- 
-private: 
- 
-	struct AbstractHolder { 
-		virtual ~AbstractHolder() { 
-		} 
+		DoSwap(h, a.h);
+	}
+
+private:
+
+	struct AbstractHolder {
+		virtual ~AbstractHolder() {
+		}
 		virtual THolder<AbstractHolder> Duplicate() const = 0;
-		virtual bool IsA(const std::type_info& id) const = 0; 
-		virtual void* Ptr() = 0; 
-		virtual const void* Ptr() const = 0; 
-	}; 
- 
-	template <class T> 
-	struct Holder: public AbstractHolder { 
-		Holder(T t) 
-			: d(t) 
-		{ 
-		} 
+		virtual bool IsA(const std::type_info& id) const = 0;
+		virtual void* Ptr() = 0;
+		virtual const void* Ptr() const = 0;
+	};
+
+	template <class T>
+	struct Holder: public AbstractHolder {
+		Holder(T t)
+			: d(t)
+		{
+		}
 		THolder<AbstractHolder> Duplicate() const {
 			return THolder<AbstractHolder>(new Holder<T>(d));
-		} 
-		bool IsA(const std::type_info& id) const { 
-			return id == typeid(T); 
-		} 
-		void* Ptr() { 
-			return &d; 
-		} 
-		const void* Ptr() const { 
-			return &d; 
-		} 
-	private: 
-		T d; 
-	}; 
- 
+		}
+		bool IsA(const std::type_info& id) const {
+			return id == typeid(T);
+		}
+		void* Ptr() {
+			return &d;
+		}
+		const void* Ptr() const {
+			return &d;
+		}
+	private:
+		T d;
+	};
+
 	THolder<AbstractHolder> h;
-}; 
- 
-} 
- 
-namespace std { 
-	inline void swap(Pire::Any& a, Pire::Any& b) { 
-		a.Swap(b); 
-	} 
-} 
- 
-#endif 
+};
+
+}
+
+namespace std {
+	inline void swap(Pire::Any& a, Pire::Any& b) {
+		a.Swap(b);
+	}
+}
+
+#endif

+ 130 - 130
contrib/libs/pire/pire/classes.cpp

@@ -1,152 +1,152 @@
-/* 
- * classes.cpp -- implementation for Pire::CharClasses feature. 
+/*
+ * classes.cpp -- implementation for Pire::CharClasses feature.
+ *
+ * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>,
+ *                          Alexander Gololobov <agololobov@gmail.com>
+ *
+ * This file is part of Pire, the Perl Incompatible
+ * Regular Expressions library.
+ *
+ * Pire is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
  * 
- * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>, 
- *                          Alexander Gololobov <agololobov@gmail.com> 
- * 
- * This file is part of Pire, the Perl Incompatible 
- * Regular Expressions library. 
- * 
- * Pire is free software: you can redistribute it and/or modify 
- * it under the terms of the GNU Lesser Public License as published by 
- * the Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- *  
- * Pire is distributed in the hope that it will be useful, 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- * GNU Lesser Public License for more details. 
- * You should have received a copy of the GNU Lesser Public License 
- * along with Pire.  If not, see <http://www.gnu.org/licenses>. 
- */ 
- 
- 
+ * Pire is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser Public License for more details.
+ * You should have received a copy of the GNU Lesser Public License
+ * along with Pire.  If not, see <http://www.gnu.org/licenses>.
+ */
+
+
 #include <contrib/libs/pire/pire/stub/stl.h>
 #include <contrib/libs/pire/pire/stub/singleton.h>
 #include <contrib/libs/pire/pire/stub/noncopyable.h>
 #include <contrib/libs/pire/pire/stub/utf8.h>
 
-#include "re_lexer.h" 
- 
-namespace Pire { 
- 
-namespace { 
- 
-	class CharClassesTable: private NonCopyable { 
-	private: 
-		class CharClass { 
-		public: 
-			CharClass() {} 
-			explicit CharClass(wchar32 ch) { m_bounds.push_back(ymake_pair(ch, ch)); } 
-			CharClass(wchar32 lower, wchar32 upper) { m_bounds.push_back(ymake_pair(lower, upper)); } 
- 
-			CharClass& operator |= (const CharClass& cc) 
-			{ 
-				std::copy(cc.m_bounds.begin(), cc.m_bounds.end(), std::back_inserter(m_bounds)); 
-				return *this; 
-			} 
- 
-			CharClass  operator |  (const CharClass& cc) const 
-			{ 
-				CharClass r(*this); 
-				r |= cc; 
-				return r; 
-			} 
- 
+#include "re_lexer.h"
+
+namespace Pire {
+
+namespace {
+
+	class CharClassesTable: private NonCopyable {
+	private:
+		class CharClass {
+		public:
+			CharClass() {}
+			explicit CharClass(wchar32 ch) { m_bounds.push_back(ymake_pair(ch, ch)); }
+			CharClass(wchar32 lower, wchar32 upper) { m_bounds.push_back(ymake_pair(lower, upper)); }
+
+			CharClass& operator |= (const CharClass& cc)
+			{
+				std::copy(cc.m_bounds.begin(), cc.m_bounds.end(), std::back_inserter(m_bounds));
+				return *this;
+			}
+
+			CharClass  operator |  (const CharClass& cc) const
+			{
+				CharClass r(*this);
+				r |= cc;
+				return r;
+			}
+
 			TSet<wchar32> ToSet() const
-			{ 
+			{
 				TSet<wchar32> ret;
 				for (auto&& bound : m_bounds)
 					for (wchar32 c = bound.first; c <= bound.second; ++c)
-						ret.insert(c); 
-				return ret; 
-			} 
- 
-		private: 
+						ret.insert(c);
+				return ret;
+			}
+
+		private:
 			TVector<ypair<wchar32, wchar32> > m_bounds;
-		}; 
- 
-	public: 
-		bool Has(wchar32 wc) const 
-		{ 
-			return (m_classes.find(to_lower(wc & ~ControlMask)) != m_classes.end()); 
-		} 
- 
+		};
+
+	public:
+		bool Has(wchar32 wc) const
+		{
+			return (m_classes.find(to_lower(wc & ~ControlMask)) != m_classes.end());
+		}
+
 		TSet<wchar32> Get(wchar32 wc) const
-		{ 
+		{
 			auto it = m_classes.find(to_lower(wc & ~ControlMask));
-			if (it == m_classes.end()) 
-				throw Error("Unknown character class"); 
-			return it->second.ToSet(); 
-		} 
- 
-		CharClassesTable() 
-		{ 
-			m_classes['l'] = CharClass('A', 'Z') | CharClass('a', 'z'); 
-			m_classes['c'] 
-				= CharClass(0x0410, 0x044F) // Russian capital A to Russan capital YA, Russian small A to Russian small YA 
-				| CharClass(0x0401)         // Russian capital Yo 
-				| CharClass(0x0451)         // Russian small Yo 
-				; 
- 
-			m_classes['w'] = m_classes['l'] | m_classes['c']; 
-			m_classes['d'] = CharClass('0', '9'); 
-			m_classes['s'] 
-				= CharClass(' ') | CharClass('\t') | CharClass('\r') | CharClass('\n') 
-				| CharClass(0x00A0)         // Non-breaking space 
-				; 
- 
-			// A few special classes which do not have any negation 
-			m_classes['n'] = CharClass('\n'); 
-			m_classes['r'] = CharClass('\r'); 
-			m_classes['t'] = CharClass('\t'); 
-		} 
- 
+			if (it == m_classes.end())
+				throw Error("Unknown character class");
+			return it->second.ToSet();
+		}
+
+		CharClassesTable()
+		{
+			m_classes['l'] = CharClass('A', 'Z') | CharClass('a', 'z');
+			m_classes['c']
+				= CharClass(0x0410, 0x044F) // Russian capital A to Russan capital YA, Russian small A to Russian small YA
+				| CharClass(0x0401)         // Russian capital Yo
+				| CharClass(0x0451)         // Russian small Yo
+				;
+
+			m_classes['w'] = m_classes['l'] | m_classes['c'];
+			m_classes['d'] = CharClass('0', '9');
+			m_classes['s']
+				= CharClass(' ') | CharClass('\t') | CharClass('\r') | CharClass('\n')
+				| CharClass(0x00A0)         // Non-breaking space
+				;
+
+			// A few special classes which do not have any negation
+			m_classes['n'] = CharClass('\n');
+			m_classes['r'] = CharClass('\r');
+			m_classes['t'] = CharClass('\t');
+		}
+
 		TMap<wchar32, CharClass> m_classes;
-	}; 
- 
-	class CharClassesImpl: public Feature { 
-	public: 
-		CharClassesImpl(): m_table(Singleton<CharClassesTable>()) {} 
-		int Priority() const { return 10; } 
- 
-		void Alter(Term& t) 
-		{ 
-			if (t.Value().IsA<Term::CharacterRange>()) { 
-				const Term::CharacterRange& range = t.Value().As<Term::CharacterRange>(); 
-				typedef Term::CharacterRange::first_type CharSet; 
-				const CharSet& old = range.first; 
-				CharSet altered; 
-				bool pos = false; 
-				bool neg = false; 
+	};
+
+	class CharClassesImpl: public Feature {
+	public:
+		CharClassesImpl(): m_table(Singleton<CharClassesTable>()) {}
+		int Priority() const { return 10; }
+
+		void Alter(Term& t)
+		{
+			if (t.Value().IsA<Term::CharacterRange>()) {
+				const Term::CharacterRange& range = t.Value().As<Term::CharacterRange>();
+				typedef Term::CharacterRange::first_type CharSet;
+				const CharSet& old = range.first;
+				CharSet altered;
+				bool pos = false;
+				bool neg = false;
 				for (auto&& i : old)
 					if (i.size() == 1 && (i[0] & ControlMask) == Control && m_table->Has(i[0])) {
 						if (is_upper(i[0] & ~ControlMask))
-							neg = true; 
-						else 
-							pos = true; 
- 
+							neg = true;
+						else
+							pos = true;
+
 						TSet<wchar32> klass = m_table->Get(i[0]);
 						for (auto&& j : klass)
 							altered.insert(Term::String(1, j));
-					} else 
+					} else
 						altered.insert(i);
- 
-				if (neg && (pos || range.second)) 
-					Error("Positive and negative character ranges mixed"); 
-				t = Term(t.Type(), Term::CharacterRange(altered, neg || range.second)); 
-			} 
-		} 
- 
-	private: 
-		CharClassesTable* m_table; 
-	}; 
- 
-} 
- 
-namespace Features { 
+
+				if (neg && (pos || range.second))
+					Error("Positive and negative character ranges mixed");
+				t = Term(t.Type(), Term::CharacterRange(altered, neg || range.second));
+			}
+		}
+
+	private:
+		CharClassesTable* m_table;
+	};
+
+}
+
+namespace Features {
 	Feature::Ptr CharClasses() { return Feature::Ptr(new CharClassesImpl); }
-} 
- 
-} 
- 
+}
+
+}
+

+ 112 - 112
contrib/libs/pire/pire/defs.h

@@ -1,112 +1,112 @@
-/* 
- * defs.h -- common Pire definitions. 
- * 
- * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>, 
- *                          Alexander Gololobov <agololobov@gmail.com> 
- * 
- * This file is part of Pire, the Perl Incompatible 
- * Regular Expressions library. 
- * 
- * Pire is free software: you can redistribute it and/or modify 
- * it under the terms of the GNU Lesser Public License as published by 
- * the Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * Pire is distributed in the hope that it will be useful, 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- * GNU Lesser Public License for more details. 
- * You should have received a copy of the GNU Lesser Public License 
- * along with Pire.  If not, see <http://www.gnu.org/licenses>. 
- */ 
- 
- 
-#ifndef PIRE_DEFS_H 
-#define PIRE_DEFS_H 
- 
-#ifndef PIRE_NO_CONFIG 
-#include <pire/config.h> 
-#endif 
-#include <stdlib.h> 
- 
-#if defined(_MSC_VER) 
-#define PIRE_HAVE_DECLSPEC_ALIGN 
-#else 
-#define PIRE_HAVE_ALIGNAS 
-#endif 
- 
-#define PIRE_HAVE_LAMBDAS 
- 
-namespace Pire { 
- 
-#ifdef PIRE_DEBUG 
-#	define PIRE_IFDEBUG(x) x 
-#else 
-#	define PIRE_IFDEBUG(x) 
-#endif 
- 
-#ifdef PIRE_CHECKED 
-#	define PIRE_IF_CHECKED(e) e 
-#else 
-#	define PIRE_IF_CHECKED(e) 
-#endif 
- 
- 
-	typedef unsigned short Char; 
- 
-	namespace SpecialChar { 
-	enum { 
-		Epsilon = 257, 
-		BeginMark = 258, 
-		EndMark = 259, 
- 
-		// Actual size of input alphabet 
-		MaxCharUnaligned = 260, 
- 
-		// Size of letter transition tables, must be a multiple of the machine word size 
-		MaxChar = (MaxCharUnaligned + (sizeof(void*)-1)) & ~(sizeof(void*)-1) 
-	}; 
-	} 
- 
-	using namespace SpecialChar; 
- 
-	namespace Impl { 
-#ifndef PIRE_WORDS_BIGENDIAN 
-		inline size_t ToLittleEndian(size_t val) { return val; } 
-#else 
-		template<unsigned N> 
-		inline size_t SwapBytes(size_t val) 
-		{ 
-			static const size_t Mask = (1 << (N/2)) - 1; 
-			return ((SwapBytes<N/2>(val) & Mask) << (N/2)) | SwapBytes<N/2>(val >> (N/2)); 
-		} 
- 
-		template<> 
-		inline size_t SwapBytes<8>(size_t val) { return val & 0xFF; } 
- 
-		inline size_t ToLittleEndian(size_t val) { return SwapBytes<sizeof(val)*8>(val); } 
-#endif 
- 
-        struct Struct { void* p; }; 
-	} 
-} 
- 
-#ifndef PIRE_ALIGNED_DECL 
-#	if defined(PIRE_HAVE_ALIGNAS) 
-#		define PIRE_ALIGNED_DECL(x) alignas(::Pire::Impl::Struct) static const char x[] 
-#	elif defined(PIRE_HAVE_ATTR_ALIGNED) 
-#		define PIRE_ALIGNED_DECL(x) static const char x[] __attribute__((aligned(sizeof(void*)))) 
-#	elif defined(PIRE_HAVE_DECLSPEC_ALIGN) 
-#		define PIRE_ALIGNED_DECL(x) __declspec(align(8)) static const char x[] 
-#	endif 
-#endif 
- 
-#ifndef PIRE_LITERAL 
-#	if defined(PIRE_HAVE_LAMBDAS) 
-#		define PIRE_LITERAL(data) ([]() -> const char* { PIRE_ALIGNED_DECL(__pire_regexp__) = data; return __pire_regexp__; })() 
-#	elif defined(PIRE_HAVE_SCOPED_EXPR) 
-#		define PIRE_LITERAL(data) ({ PIRE_ALIGNED_DECL(__pire_regexp__) = data; __pire_regexp__; }) 
-#	endif 
-#endif 
- 
-#endif 
+/*
+ * defs.h -- common Pire definitions.
+ *
+ * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>,
+ *                          Alexander Gololobov <agololobov@gmail.com>
+ *
+ * This file is part of Pire, the Perl Incompatible
+ * Regular Expressions library.
+ *
+ * Pire is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pire is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser Public License for more details.
+ * You should have received a copy of the GNU Lesser Public License
+ * along with Pire.  If not, see <http://www.gnu.org/licenses>.
+ */
+
+
+#ifndef PIRE_DEFS_H
+#define PIRE_DEFS_H
+
+#ifndef PIRE_NO_CONFIG
+#include <pire/config.h>
+#endif
+#include <stdlib.h>
+
+#if defined(_MSC_VER)
+#define PIRE_HAVE_DECLSPEC_ALIGN
+#else
+#define PIRE_HAVE_ALIGNAS
+#endif
+
+#define PIRE_HAVE_LAMBDAS
+
+namespace Pire {
+
+#ifdef PIRE_DEBUG
+#	define PIRE_IFDEBUG(x) x
+#else
+#	define PIRE_IFDEBUG(x)
+#endif
+
+#ifdef PIRE_CHECKED
+#	define PIRE_IF_CHECKED(e) e
+#else
+#	define PIRE_IF_CHECKED(e)
+#endif
+
+
+	typedef unsigned short Char;
+
+	namespace SpecialChar {
+	enum {
+		Epsilon = 257,
+		BeginMark = 258,
+		EndMark = 259,
+
+		// Actual size of input alphabet
+		MaxCharUnaligned = 260,
+
+		// Size of letter transition tables, must be a multiple of the machine word size
+		MaxChar = (MaxCharUnaligned + (sizeof(void*)-1)) & ~(sizeof(void*)-1)
+	};
+	}
+
+	using namespace SpecialChar;
+
+	namespace Impl {
+#ifndef PIRE_WORDS_BIGENDIAN
+		inline size_t ToLittleEndian(size_t val) { return val; }
+#else
+		template<unsigned N>
+		inline size_t SwapBytes(size_t val)
+		{
+			static const size_t Mask = (1 << (N/2)) - 1;
+			return ((SwapBytes<N/2>(val) & Mask) << (N/2)) | SwapBytes<N/2>(val >> (N/2));
+		}
+
+		template<>
+		inline size_t SwapBytes<8>(size_t val) { return val & 0xFF; }
+
+		inline size_t ToLittleEndian(size_t val) { return SwapBytes<sizeof(val)*8>(val); }
+#endif
+
+        struct Struct { void* p; };
+	}
+}
+
+#ifndef PIRE_ALIGNED_DECL
+#	if defined(PIRE_HAVE_ALIGNAS)
+#		define PIRE_ALIGNED_DECL(x) alignas(::Pire::Impl::Struct) static const char x[]
+#	elif defined(PIRE_HAVE_ATTR_ALIGNED)
+#		define PIRE_ALIGNED_DECL(x) static const char x[] __attribute__((aligned(sizeof(void*))))
+#	elif defined(PIRE_HAVE_DECLSPEC_ALIGN)
+#		define PIRE_ALIGNED_DECL(x) __declspec(align(8)) static const char x[]
+#	endif
+#endif
+
+#ifndef PIRE_LITERAL
+#	if defined(PIRE_HAVE_LAMBDAS)
+#		define PIRE_LITERAL(data) ([]() -> const char* { PIRE_ALIGNED_DECL(__pire_regexp__) = data; return __pire_regexp__; })()
+#	elif defined(PIRE_HAVE_SCOPED_EXPR)
+#		define PIRE_LITERAL(data) ({ PIRE_ALIGNED_DECL(__pire_regexp__) = data; __pire_regexp__; })
+#	endif
+#endif
+
+#endif

+ 126 - 126
contrib/libs/pire/pire/determine.h

@@ -1,145 +1,145 @@
-/* 
- * determine.h -- the FSM determination routine. 
+/*
+ * determine.h -- the FSM determination routine.
+ *
+ * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>,
+ *                          Alexander Gololobov <agololobov@gmail.com>
+ *
+ * This file is part of Pire, the Perl Incompatible
+ * Regular Expressions library.
+ *
+ * Pire is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
  * 
- * Copyright (c) 2007-2010, Dmitry Prokoptsev <dprokoptsev@gmail.com>, 
- *                          Alexander Gololobov <agololobov@gmail.com> 
- * 
- * This file is part of Pire, the Perl Incompatible 
- * Regular Expressions library. 
- * 
- * Pire is free software: you can redistribute it and/or modify 
- * it under the terms of the GNU Lesser Public License as published by 
- * the Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- *  
- * Pire is distributed in the hope that it will be useful, 
- * but WITHOUT ANY WARRANTY; without even the implied warranty of 
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- * GNU Lesser Public License for more details. 
- * You should have received a copy of the GNU Lesser Public License 
- * along with Pire.  If not, see <http://www.gnu.org/licenses>. 
- */ 
- 
- 
-#ifndef PIRE_DETERMINE_H 
-#define PIRE_DETERMINE_H 
- 
+ * Pire is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser Public License for more details.
+ * You should have received a copy of the GNU Lesser Public License
+ * along with Pire.  If not, see <http://www.gnu.org/licenses>.
+ */
+
+
+#ifndef PIRE_DETERMINE_H
+#define PIRE_DETERMINE_H
+
 #include <contrib/libs/pire/pire/stub/stl.h>
 
-#include "partition.h" 
- 
-namespace Pire { 
-	namespace Impl { 
- 
-		/** 
-		 * An interface of a determination task. 
-		 * You don't have to derive from this class; it is just a start point template. 
-		 */ 
-		class DetermineTask { 
-		private: 
-			struct ImplementationSpecific1; 
-			struct ImplementationSpecific2; 
- 
-		public: 
-			/// A type representing a new state (may be a set of old states, a pair of them, etc...) 
-			typedef ImplementationSpecific1 State; 
- 
-			/// A type of letter equivalence classes table. 
-			typedef Partition<char, ImplementationSpecific2> LettersTbl; 
- 
-			/// A container used for storing map of states to thier indices. 
+#include "partition.h"
+
+namespace Pire {
+	namespace Impl {
+
+		/**
+		 * An interface of a determination task.
+		 * You don't have to derive from this class; it is just a start point template.
+		 */
+		class DetermineTask {
+		private:
+			struct ImplementationSpecific1;
+			struct ImplementationSpecific2;
+
+		public:
+			/// A type representing a new state (may be a set of old states, a pair of them, etc...)
+			typedef ImplementationSpecific1 State;
+
+			/// A type of letter equivalence classes table.
+			typedef Partition<char, ImplementationSpecific2> LettersTbl;
+
+			/// A container used for storing map of states to thier indices.
 			typedef TMap<State, size_t> InvStates;
- 
-			/// Should return used letters' partition. 
-			const LettersTbl& Letters() const; 
- 
-			/// Should return initial state (surprise!) 
-			State Initial() const; 
- 
-			/// Should calculate next state, given the current state and a letter. 
-			State Next(State state, Char letter) const; 
- 
-			/// Should return true iff the state need to be processed. 
-			bool IsRequired(const State& /*state*/) const { return true; } 
- 
-			/// Called when the set of new states is closed. 
+
+			/// Should return used letters' partition.
+			const LettersTbl& Letters() const;
+
+			/// Should return initial state (surprise!)
+			State Initial() const;
+
+			/// Should calculate next state, given the current state and a letter.
+			State Next(State state, Char letter) const;
+
+			/// Should return true iff the state need to be processed.
+			bool IsRequired(const State& /*state*/) const { return true; }
+
+			/// Called when the set of new states is closed.
 			void AcceptStates(const TVector<State>& newstates);
- 
-			/// Called for each transition from one new state to another. 
-			void Connect(size_t from, size_t to, Char letter); 
- 
-			typedef bool Result; 
-			Result Success() { return true; } 
-			Result Failure() { return false; } 
-		}; 
- 
-		/** 
-		 * A helper function for FSM determining and all determine-like algorithms 
-		 * like scanners' agglutination. 
-		 * 
-		 * Given an indirectly specified automaton (through Task::Initial() and Task::Next() 
-		 * functions, see above), performs a breadth-first traversal, finding and enumerating 
-		 * all effectively reachable states. Then passes all found states and transitions 
-		 * between them back to the task. 
-		 * 
-		 * Initial state is always placed at zero position. 
-		 * 
-		 * Please note that the function does not take care of any payload (including final flags); 
-		 * it is the task's responsibility to agglutinate them properly. 
-		 * 
-		 * Returns task.Succeed() if everything was done; task.Failure() if maximum limit of state count was reached. 
-		 */ 
-		template<class Task> 
-		typename Task::Result Determine(Task& task, size_t maxSize) 
-		{ 
-			typedef typename Task::State State; 
-			typedef typename Task::InvStates InvStates; 
+
+			/// Called for each transition from one new state to another.
+			void Connect(size_t from, size_t to, Char letter);
+
+			typedef bool Result;
+			Result Success() { return true; }
+			Result Failure() { return false; }
+		};
+
+		/**
+		 * A helper function for FSM determining and all determine-like algorithms
+		 * like scanners' agglutination.
+		 *
+		 * Given an indirectly specified automaton (through Task::Initial() and Task::Next()
+		 * functions, see above), performs a breadth-first traversal, finding and enumerating
+		 * all effectively reachable states. Then passes all found states and transitions
+		 * between them back to the task.
+		 *
+		 * Initial state is always placed at zero position.
+		 *
+		 * Please note that the function does not take care of any payload (including final flags);
+		 * it is the task's responsibility to agglutinate them properly.
+		 *
+		 * Returns task.Succeed() if everything was done; task.Failure() if maximum limit of state count was reached.
+		 */
+		template<class Task>
+		typename Task::Result Determine(Task& task, size_t maxSize)
+		{
+			typedef typename Task::State State;
+			typedef typename Task::InvStates InvStates;
 			typedef TDeque< TVector<size_t> > TransitionTable;
- 
+
 			TVector<State> states;
-			InvStates invstates; 
-			TransitionTable transitions; 
+			InvStates invstates;
+			TransitionTable transitions;
 			TVector<size_t> stateIndices;
- 
-			states.push_back(task.Initial()); 
-			invstates.insert(typename InvStates::value_type(states[0], 0)); 
- 
-			for (size_t stateIdx = 0; stateIdx < states.size(); ++stateIdx) { 
-				if (!task.IsRequired(states[stateIdx])) 
-					continue; 
-				TransitionTable::value_type row(task.Letters().Size()); 
+
+			states.push_back(task.Initial());
+			invstates.insert(typename InvStates::value_type(states[0], 0));
+
+			for (size_t stateIdx = 0; stateIdx < states.size(); ++stateIdx) {
+				if (!task.IsRequired(states[stateIdx]))
+					continue;
+				TransitionTable::value_type row(task.Letters().Size());
 				for (auto&& letter : task.Letters()) {
 					State newState = task.Next(states[stateIdx], letter.first);
 					auto i = invstates.find(newState);
-					if (i == invstates.end()) { 
-						if (!maxSize--) 
-							return task.Failure(); 
-						i = invstates.insert(typename InvStates::value_type(newState, states.size())).first; 
-						states.push_back(newState); 
-					} 
+					if (i == invstates.end()) {
+						if (!maxSize--)
+							return task.Failure();
+						i = invstates.insert(typename InvStates::value_type(newState, states.size())).first;
+						states.push_back(newState);
+					}
 					row[letter.second.first] = i->second;
-				} 
-				transitions.push_back(row); 
-				stateIndices.push_back(stateIdx); 
-			} 
- 
+				}
+				transitions.push_back(row);
+				stateIndices.push_back(stateIdx);
+			}
+
 			TVector<Char> invletters(task.Letters().Size());
 			for (auto&& letter : task.Letters())
 				invletters[letter.second.first] = letter.first;
- 
-			task.AcceptStates(states); 
-			size_t from = 0; 
-			for (TransitionTable::iterator i = transitions.begin(), ie = transitions.end(); i != ie; ++i, ++from) { 
+
+			task.AcceptStates(states);
+			size_t from = 0;
+			for (TransitionTable::iterator i = transitions.begin(), ie = transitions.end(); i != ie; ++i, ++from) {
 				TVector<Char>::iterator l = invletters.begin();
-				for (TransitionTable::value_type::iterator j = i->begin(), je = i->end(); j != je; ++j, ++l) 
-					task.Connect(stateIndices[from], *j, *l); 
-			} 
-			return task.Success(); 
-		} 
+				for (TransitionTable::value_type::iterator j = i->begin(), je = i->end(); j != je; ++j, ++l)
+					task.Connect(stateIndices[from], *j, *l);
+			}
+			return task.Success();
+		}
 
 		// Faster transition table representation for determined FSM
 		typedef TVector<size_t> DeterminedTransitions;
-	} 
-} 
- 
-#endif 
+	}
+}
+
+#endif

Some files were not shown because too many files changed in this diff