]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/mathml_editor/src/TLexerPull.cc
Initial revision
[helm.git] / helm / DEVEL / mathml_editor / src / TLexerPull.cc
diff --git a/helm/DEVEL/mathml_editor/src/TLexerPull.cc b/helm/DEVEL/mathml_editor/src/TLexerPull.cc
new file mode 100644 (file)
index 0000000..0eb3a3c
--- /dev/null
@@ -0,0 +1,35 @@
+
+#include "TCharStream.hh"
+#include "TCharStreamString.hh"
+
+TToken
+TLexerPull::pop(TCharStream& stream)
+{
+  if (stream.more())
+    {
+      TChar ch = stream.next();
+      if (ch == '\\')
+       {
+         if (stream.more())
+           {
+             if (isUnicodeAlpha(stream.look()))
+               {
+                 TString s;
+                 while (stream.more() && isUnicodeAlpha(stream.look()))
+                   s.push_back(stream.next());
+                 TToken res(TToken::CONTROL, s);
+                 while (stream.more() && isUnicodeSpace(stream.look()))
+                   stream.next();
+                 return res;
+               }
+             else
+               return TToken(TToken::CONTROL, TString(1, stream.next()));
+           }
+         else
+           return TToken(TToken::INVALID_CHAR, TString(1, ch));
+       }
+      else return TToken(ch);
+    }
+  else return TToken(TToken::END_OF_BUFFER);
+}
+