wasCSharpSQLite – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #undef DEBUG |
2 | /* |
||
3 | * TclToken.java -- |
||
4 | * |
||
5 | * For each word of a command, and for each piece of a word such as a |
||
6 | * variable reference, a TclToken is used to describe the word. |
||
7 | * |
||
8 | * Note: TclToken is designed to be write-once with respect to |
||
9 | * setting the script and size variables. Failure to do this |
||
10 | * may lead to inconsistencies in calls to getTokenString(). |
||
11 | * |
||
12 | * Copyright (c) 1997 by Sun Microsystems, Inc. |
||
13 | * |
||
14 | * See the file "license.terms" for information on usage and redistribution |
||
15 | * of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
||
16 | * |
||
17 | * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart |
||
18 | * |
||
19 | * RCS @(#) $Id: TclToken.java,v 1.2 1999/05/09 01:34:50 dejong Exp $ |
||
20 | */ |
||
21 | using System.Text; |
||
22 | namespace tcl.lang |
||
23 | { |
||
24 | |||
25 | public class TclToken |
||
26 | { |
||
27 | internal string TokenString |
||
28 | { |
||
29 | get |
||
30 | { |
||
31 | #if DEBUG |
||
32 | if ((script_index + size) > script_array.Length) |
||
33 | { |
||
34 | System.Diagnostics.Debug.WriteLine("Entered TclToken.getTokenString()"); |
||
35 | System.Diagnostics.Debug.WriteLine("hashCode() is " + GetHashCode()); |
||
36 | System.Diagnostics.Debug.WriteLine("script_array.length is " + script_array.Length); |
||
37 | System.Diagnostics.Debug.WriteLine("script_index is " + script_index); |
||
38 | System.Diagnostics.Debug.WriteLine("size is " + size); |
||
39 | |||
40 | System.Diagnostics.Debug.Write("the string is \""); |
||
41 | for (int k = 0; k < script_array.Length; k++) |
||
42 | { |
||
43 | System.Diagnostics.Debug.Write(script_array[k]); |
||
44 | } |
||
45 | System.Diagnostics.Debug.WriteLine("\""); |
||
46 | } |
||
47 | #endif |
||
48 | |||
49 | return ( new string( script_array, script_index, size ) ); |
||
50 | } |
||
51 | |||
52 | } |
||
53 | |||
54 | // Contains an array the references the script from where the |
||
55 | // token originates from and an index to the first character |
||
56 | // of the token inside the script. |
||
57 | |||
58 | |||
59 | internal char[] script_array; |
||
60 | internal int script_index; |
||
61 | |||
62 | // Number of bytes in token. |
||
63 | |||
64 | public int size; |
||
65 | |||
66 | // Type of token, such as TCL_TOKEN_WORD; See Parse.java |
||
67 | // for valid types. |
||
68 | |||
69 | internal int type; |
||
70 | |||
71 | // If this token is composed of other tokens, this field |
||
72 | // tells how many of them there are (including components |
||
73 | // of components, etc.). The component tokens immediately |
||
74 | // follow this one. |
||
75 | |||
76 | internal int numComponents; |
||
77 | internal TclToken() |
||
78 | { |
||
79 | script_array = null; |
||
80 | script_index = -1; |
||
81 | } |
||
82 | public override string ToString() |
||
83 | { |
||
84 | StringBuilder sbuf = new StringBuilder(); |
||
85 | switch ( type ) |
||
86 | { |
||
87 | |||
88 | case Parser.TCL_TOKEN_WORD: |
||
89 | { |
||
90 | sbuf.Append( "\n Token Type: TCL_TOKEN_WORD" ); |
||
91 | break; |
||
92 | } |
||
93 | |||
94 | case Parser.TCL_TOKEN_SIMPLE_WORD: |
||
95 | { |
||
96 | sbuf.Append( "\n Token Type: TCL_TOKEN_SIMPLE_WORD" ); |
||
97 | break; |
||
98 | } |
||
99 | |||
100 | case Parser.TCL_TOKEN_EXPAND_WORD: |
||
101 | { |
||
102 | sbuf.Append( "\n Token Type: TCL_TOKEN_EXPAND_WORD" ); |
||
103 | break; |
||
104 | } |
||
105 | |||
106 | case Parser.TCL_TOKEN_TEXT: |
||
107 | { |
||
108 | sbuf.Append( "\n Token Type: TCL_TOKEN_TEXT" ); |
||
109 | break; |
||
110 | } |
||
111 | |||
112 | case Parser.TCL_TOKEN_BS: |
||
113 | { |
||
114 | sbuf.Append( "\n Token Type: TCL_TOKEN_BS" ); |
||
115 | break; |
||
116 | } |
||
117 | |||
118 | case Parser.TCL_TOKEN_COMMAND: |
||
119 | { |
||
120 | sbuf.Append( "\n Token Type: TCL_TOKEN_COMMAND" ); |
||
121 | break; |
||
122 | } |
||
123 | |||
124 | case Parser.TCL_TOKEN_VARIABLE: |
||
125 | { |
||
126 | sbuf.Append( "\n Token Type: TCL_TOKEN_VARIABLE" ); |
||
127 | break; |
||
128 | } |
||
129 | } |
||
130 | sbuf.Append( "\n String: " + TokenString ); |
||
131 | sbuf.Append( "\n String Size: " + TokenString.Length ); |
||
132 | sbuf.Append( "\n ScriptIndex: " + script_index ); |
||
133 | sbuf.Append( "\n NumComponents: " + numComponents ); |
||
134 | sbuf.Append( "\n Token Size: " + size ); |
||
135 | return sbuf.ToString(); |
||
136 | } |
||
137 | } // end TclToken |
||
138 | } |