summaryrefslogtreecommitdiff
path: root/src/lines.cpp
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2019-11-08 19:49:40 +0300
committerAleksey Veresov <aleksey@veresov.pro>2019-11-08 19:49:40 +0300
commited7a63015c1583d5544ac18bbaccaedc95f3e5e3 (patch)
tree9648d5a74bae9cbd90670a8bfa0af47189e4536f /src/lines.cpp
parentc6419eed96f2832b1de2b94d711552efaa9b172d (diff)
downloadtexo-ed7a63015c1583d5544ac18bbaccaedc95f3e5e3.tar
texo-ed7a63015c1583d5544ac18bbaccaedc95f3e5e3.tar.xz
texo-ed7a63015c1583d5544ac18bbaccaedc95f3e5e3.zip
[texo] Full rewrite of inner representation.
Diffstat (limited to 'src/lines.cpp')
-rw-r--r--src/lines.cpp52
1 files changed, 29 insertions, 23 deletions
diff --git a/src/lines.cpp b/src/lines.cpp
index bacf048..c7b605b 100644
--- a/src/lines.cpp
+++ b/src/lines.cpp
@@ -1,85 +1,91 @@
#include "lines.hpp"
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Texo Lines Producer
+ */
TexoProducerLines::TexoProducerLines(TexoExporter &exporter):
TexoProducer(exporter), newline(true)
{}
-void TexoProducerLines::End()
+
+bool TexoProducerLines::End()
{
if (!newline) {
exporter.Put('\n');
newline = true;
}
+ return true;
}
-void TexoProducerLines::Put(const Texo &piece)
+
+bool TexoProducerLines::Put(char c)
{
- if (piece.c == '\n') {
+ if (c == '\n') {
if (!newline) {
exporter.Put(' ');
newline = true;
}
} else {
- exporter.Put(piece.c);
+ exporter.Put(c);
newline = false;
}
+ return true;
}
-void TexoProducerLines::Put(const TexoParagraph &piece)
+
+bool TexoProducerLines::Paragraph()
{
if (!newline) {
exporter.Put('\n');
newline = true;
}
+ return true;
}
-void TexoProducerLines::Put(const TexoQuote &piece)
+bool TexoProducerLines::Quote()
{
if (!newline) {
exporter.Put('\n');
}
exporter.Put("> ");
newline = false;
+ return true;
}
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Texo Lines Importer
+ */
TexoImporterLines::TexoImporterLines(TexoProducer &producer):
TexoImporter(producer), newline(true), quote(false)
{}
-void TexoImporterLines::Put(char c)
+
+bool TexoImporterLines::TruePut(char c)
{
if (c == '\n') {
if (!newline) {
newline = true;
quote = false;
}
+ return true;
} else if (newline) {
+ newline = false;
if (c == '>') {
- producer.Put(TexoQuote());
quote = true;
+ return producer.Quote();
} else {
- producer.Put(TexoParagraph());
- producer.Put(c);
+ return producer.Paragraph() && producer.Put(c);
}
- newline = false;
} else if (quote) {
if (c != ' ') {
quote = false;
- producer.Put(c);
+ return producer.Put(c);
+ } else {
+ return true;
}
} else {
- producer.Put(c);
+ return producer.Put(c);
}
}
-
-void TexoImporterLines::Put(const ScriptVariable &str)
-{
- TexoImporter::Put(str);
-}
-
-void TexoImporterLines::Put(FILE *file)
-{
- TexoImporter::Put(file);
-}