aboutsummaryrefslogtreecommitdiffstatsci
path: root/Samples/CrowIDE/src/Editors/CodeBuffer/Token.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2019-08-03 19:49:15 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2019-08-03 19:49:15 +0200
commite6030fa04a8de3fdae1dc19d081bf5feb3d3d73c (patch)
tree89f392cd974d1109a203ade305da467bd378ee48 /Samples/CrowIDE/src/Editors/CodeBuffer/Token.cs
parentcad504c62d45952b4651603579f34df0d230841e (diff)
sample directory
Diffstat (limited to 'Samples/CrowIDE/src/Editors/CodeBuffer/Token.cs')
-rw-r--r--Samples/CrowIDE/src/Editors/CodeBuffer/Token.cs71
1 files changed, 71 insertions, 0 deletions
diff --git a/Samples/CrowIDE/src/Editors/CodeBuffer/Token.cs b/Samples/CrowIDE/src/Editors/CodeBuffer/Token.cs
new file mode 100644
index 00000000..8b4df5e5
--- /dev/null
+++ b/Samples/CrowIDE/src/Editors/CodeBuffer/Token.cs
@@ -0,0 +1,71 @@
+//
+// Token.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2017 jp
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program 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 General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+using System;
+
+namespace Crow.Coding
+{
+ public struct Token
+ {
+ public BufferParser.TokenType Type;
+ public string Content;
+ public Point Start;
+ public Point End;
+
+ public string PrintableContent {
+ get { return string.IsNullOrEmpty(Content) ? "" : Content.Replace("\t", new String(' ', Interface.TabSize)); }
+ }
+
+// public Token (TokenType tokType, string content = ""){
+// Type = tokType;
+// Content = content;
+// }
+
+ public bool IsNull { get { return IsEmpty && Type == BufferParser.TokenType.Unknown; }}
+ public bool IsEmpty { get { return string.IsNullOrEmpty(Content); }}
+
+ public static bool operator == (Token t, System.Enum tt){
+ return Convert.ToInt32(t.Type) == Convert.ToInt32(tt);
+ }
+ public static bool operator != (Token t, System.Enum tt){
+ return Convert.ToInt32(t.Type) != Convert.ToInt32(tt);
+ }
+ public static bool operator == (System.Enum tt, Token t){
+ return Convert.ToInt32(t.Type) == Convert.ToInt32(tt);
+ }
+ public static bool operator != (System.Enum tt, Token t){
+ return Convert.ToInt32(t.Type) != Convert.ToInt32(tt);
+ }
+
+ public static Token operator +(Token t, char c){
+ t.Content += c;
+ return t;
+ }
+ public static Token operator +(Token t, string s){
+ t.Content += s;
+ return t;
+ }
+ public override string ToString ()
+ {
+ return string.Format ("[Tok{2}->{3}:{0}: {1}]", Type,Content,Start,End);
+ }
+ }
+}
+