summaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/document_p.cpp20
-rw-r--r--src/parser/document_p.h26
-rw-r--r--src/parser/text_p.cpp31
-rw-r--r--src/parser/text_p.h34
4 files changed, 111 insertions, 0 deletions
diff --git a/src/parser/document_p.cpp b/src/parser/document_p.cpp
new file mode 100644
index 0000000..875211c
--- /dev/null
+++ b/src/parser/document_p.cpp
@@ -0,0 +1,20 @@
+/*
+Copyright (c) 2010, Grégoire Duchêne <gduchene@fastmail.net>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+#include "document_p.h"
+
+document_p::document_p() : document_p::base_type(document_) {
+ document_ = +text_;
+}
diff --git a/src/parser/document_p.h b/src/parser/document_p.h
new file mode 100644
index 0000000..fc6530e
--- /dev/null
+++ b/src/parser/document_p.h
@@ -0,0 +1,26 @@
+/*
+Copyright (c) 2010, Grégoire Duchêne <gduchene@fastmail.net>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+#ifndef _MPPDOWN_DOCUMENT_P
+#define _MPPDOWN_DOCUMENT_P
+#include "text_p.h"
+
+struct document_p : qi::grammar<iiterator, document_t()> {
+ qi::rule<iiterator, document_t()> document_;
+ text_p text_;
+
+ document_p();
+};
+#endif
diff --git a/src/parser/text_p.cpp b/src/parser/text_p.cpp
new file mode 100644
index 0000000..4d44e66
--- /dev/null
+++ b/src/parser/text_p.cpp
@@ -0,0 +1,31 @@
+/*
+Copyright (c) 2010, Grégoire Duchêne <gduchene@fastmail.net>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+#include "text_p.h"
+
+text_p::text_p() : text_p::base_type(text_) {
+ using namespace qi;
+ using qi::standard_wide::char_;
+
+ text_ = stext_ | ptext_;
+
+ stext_ = lit("***") >> attr(VSEMPH) >> +text_ >> "***"
+ | lit("**") >> attr(SEMPH) >> +text_ >> "**"
+ | lit('*') >> attr(EMPH) >> +text_ >> '*';
+
+ ptext_ = +(echar_ | rchar_);
+ echar_ = lit('\\') >> char_;
+ rchar_ = char_ - char_(L"*");
+}
diff --git a/src/parser/text_p.h b/src/parser/text_p.h
new file mode 100644
index 0000000..83ef54f
--- /dev/null
+++ b/src/parser/text_p.h
@@ -0,0 +1,34 @@
+/*
+Copyright (c) 2010, Grégoire Duchêne <gduchene@fastmail.net>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+#ifndef _MPPDOWN_TEXT_P
+#define _MPPDOWN_TEXT_P
+#include <boost/spirit/include/qi.hpp>
+#include <boost/spirit/include/support_standard_wide.hpp>
+#include <string>
+#include "../elements.h"
+
+namespace qi = boost::spirit::qi;
+
+struct text_p : qi::grammar<iiterator, text_t()> {
+ qi::rule<iiterator, text_t()> text_;
+ qi::rule<iiterator, stext_t()> stext_;
+ qi::rule<iiterator, std::wstring()> ptext_;
+ qi::rule<iiterator, wchar_t()> echar_;
+ qi::rule<iiterator, wchar_t()> rchar_;
+
+ text_p();
+};
+#endif