From 525591758ce178e44da6aa3a11d557fd75b232e7 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 5 Mar 2018 14:18:35 +0800 Subject: refactoring some codes. --- MoonParser/parser.hpp | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'MoonParser/parser.hpp') diff --git a/MoonParser/parser.hpp b/MoonParser/parser.hpp index b280155..66d6067 100644 --- a/MoonParser/parser.hpp +++ b/MoonParser/parser.hpp @@ -13,8 +13,23 @@ #include #include #include +#include +#include +///type of the parser's input. +typedef std::basic_string input; +typedef input::iterator input_it; + +template +struct deletable_facet : Facet +{ + template + deletable_facet(Args&& ...args): Facet(std::forward(args)...) {} + ~deletable_facet() {} +}; +typedef std::wstring_convert>, input::value_type> Converter; + namespace parserlib { @@ -24,9 +39,6 @@ class _context; class rule; -///type of the parser's input. -typedef std::u32string input; -typedef input::iterator input_it; struct item_t { input_it begin; @@ -65,18 +77,13 @@ public: /** character terminal constructor. @param c character. */ - expr(int c); + expr(char c); /** null-terminated string terminal constructor. @param s null-terminated string. */ expr(const char *s); - /** null-terminated wide string terminal constructor. - @param s null-terminated string. - */ - expr(const wchar_t *s); - /** rule reference constructor. @param r rule. */ @@ -195,18 +202,13 @@ public: /** character terminal constructor. @param c character. */ - rule(int c); + rule(char c); /** null-terminated string terminal constructor. @param s null-terminated string. */ rule(const char *s); - /** null-terminated wide string terminal constructor. - @param s null-terminated string. - */ - rule(const wchar_t *s); - /** constructor from expression. @param e expression. */ @@ -330,13 +332,6 @@ expr term(const expr &e); expr set(const char *s); -/** creates a set expression from a null-terminated wide string. - @param s null-terminated string with characters of the set. - @return an expression which parses a single character out of a set. - */ -expr set(const wchar_t *s); - - /** creates a range expression. @param min min character. @param max max character. -- cgit v1.2.3-55-g6feb