~alexreg/mathtexdotnet/0.1

« back to all changes in this revision

Viewing changes to TexDotNet/Token.cs

  • Committer: Alex Regueiro
  • Date: 2009-08-07 23:14:32 UTC
  • Revision ID: alexreg@gmail.com-20090807231432-b4enxrxowf8ertnj
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Collections.Generic;
 
3
using System.Linq;
 
4
using System.Text;
 
5
 
 
6
namespace TexDotNet
 
7
{
 
8
    public struct Token
 
9
    {
 
10
        public static Token FromNumber(double value)
 
11
        {
 
12
            return new Token(TokenKind.Number, value);
 
13
        }
 
14
 
 
15
        public static Token FromKind(TokenKind kind)
 
16
        {
 
17
            return new Token(kind);
 
18
        }
 
19
 
 
20
        public static Token FromValue(TokenKind kind, object value)
 
21
        {
 
22
            return new Token(kind, value);
 
23
        }
 
24
 
 
25
        public readonly TokenKind Kind;
 
26
        public readonly object Value;
 
27
 
 
28
        private Token(TokenKind kind)
 
29
            : this(kind, null)
 
30
        {
 
31
        }
 
32
 
 
33
        private Token(TokenKind kind, object value)
 
34
        {
 
35
            this.Kind = kind;
 
36
            this.Value = value;
 
37
        }
 
38
 
 
39
        public override string ToString()
 
40
        {
 
41
            return this.Kind + (this.Value == null ? string.Empty :
 
42
                "(" + this.Value.ToString() + ")");
 
43
        }
 
44
    }
 
45
 
 
46
    public enum TokenKind
 
47
    {
 
48
        UnknownSymbol,
 
49
 
 
50
        Number,
 
51
        Letter,
 
52
        GreekLetter,
 
53
        Text,
 
54
        Prime,
 
55
        Colon,
 
56
        RaiseToIndex,
 
57
        LowerToIndex,
 
58
 
 
59
        #region Brackets
 
60
        GroupOpen,
 
61
        GroupClose,
 
62
        RoundBracketOpen,
 
63
        RoundBracketClose,
 
64
        SquareBracketOpen,
 
65
        SquareBracketClose,
 
66
        CurlyBracketOpen,
 
67
        CurlyBracketClose,
 
68
        AngleBracketOpen,
 
69
        AngleBracketClose,
 
70
        FloorBracketOpen,
 
71
        FloorBracketClose,
 
72
        CeilingBracketOpen,
 
73
        CeilingBracketClose,
 
74
        ModulusBracket,
 
75
        NormBracket,
 
76
        #endregion
 
77
 
 
78
        #region Relations
 
79
        Equals,
 
80
        NotEquals,
 
81
        DotEquals,
 
82
        Approximates,
 
83
        Equivalent,
 
84
        LessThan,
 
85
        LessThanOrEqualTo,
 
86
        GreaterThan,
 
87
        GreaterThanOrEqualTo,
 
88
        MuchLessThan,
 
89
        MuchGreaterThan,
 
90
        Proportional,
 
91
        Asymptotic,
 
92
        Bowtie,
 
93
        Models,
 
94
        Precedes,
 
95
        PrecedesOrEquals,
 
96
        Succedes,
 
97
        SuccedesOrEquals,
 
98
        Congruent,
 
99
        Similar,
 
100
        SimilarOrEquals,
 
101
        Perpendicular,
 
102
        Parallel,
 
103
        Middle,
 
104
        Subset,
 
105
        SubsetOrEqualTo,
 
106
        Superset,
 
107
        SupersetOrEqualTo,
 
108
        SquareSubset,
 
109
        SquareSubsetOrEqualTo,
 
110
        SquareSuperset,
 
111
        SquareSupersetOrEqualTo,
 
112
        Member,
 
113
        NotMember,
 
114
        Contains,
 
115
        NotContains,
 
116
        Smile,
 
117
        Frown,
 
118
        VLineDash,
 
119
        DashVLine,
 
120
        #endregion
 
121
 
 
122
        #region Operators
 
123
        Plus,
 
124
        Minus,
 
125
        PlusMinus,
 
126
        MinusPlus,
 
127
        Cross,
 
128
        Dot,
 
129
        Divide,
 
130
        Factorial,
 
131
        Fraction,
 
132
        Root,
 
133
        Sine,
 
134
        Cosine,
 
135
        Tangent,
 
136
        Secant,
 
137
        Cosecant,
 
138
        Cotangent,
 
139
        ArcSine,
 
140
        ArcCosine,
 
141
        ArcTangent,
 
142
        ArcSecant,
 
143
        ArcCosecant,
 
144
        ArcCotangent,
 
145
        HSine,
 
146
        HCosine,
 
147
        HTangent,
 
148
        HSecant,
 
149
        HCosecant,
 
150
        HCotangent,
 
151
        ArHSine,
 
152
        ArHCosine,
 
153
        ArHTangent,
 
154
        ArHSecant,
 
155
        ArHCosecant,
 
156
        ArHCotangent,
 
157
        InlineModulo,
 
158
        IdentityModulo,
 
159
        Sum,
 
160
        Product,
 
161
        Coproduct,
 
162
        Integral,
 
163
        DoubleIntegral,
 
164
        TripleIntegral,
 
165
        QuadrupleIntegral,
 
166
        NtupleIntegral,
 
167
        ClosedIntegral,
 
168
        ClosedDoubleIntegral,
 
169
        ClosedTripleIntegral,
 
170
        ClosedQuadrupleIntegral,
 
171
        ClosedNtupleIntegral,
 
172
        BigOPlus,
 
173
        BigOTimes,
 
174
        BigODot,
 
175
        BigCup,
 
176
        BigCap,
 
177
        BigCupPlus,
 
178
        BigSquareCup,
 
179
        BigSquareCap,
 
180
        BigVee,
 
181
        BigWedge,
 
182
        #endregion
 
183
 
 
184
        #region Formatting
 
185
        Left,
 
186
        Right,
 
187
        #endregion
 
188
    }
 
189
}