Source Code Cross Referenced for TclToken.java in  » Scripting » jacl » tcl » lang » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » jacl » tcl.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * TclToken.java --
003:         *
004:         *	For each word of a command, and for each piece of a word such as a
005:         * 	variable reference, a TclToken is used to describe the word.
006:         *
007:         * 	Note: TclToken is designed to be write-once with respect to 
008:         * 	setting the script and size variables.  Failure to do this 
009:         * 	may lead to inconsistencies in calls to getTokenString(). 
010:         *
011:         * Copyright (c) 1997 by Sun Microsystems, Inc.
012:         *
013:         * See the file "license.terms" for information on usage and redistribution
014:         * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
015:         *
016:         * RCS: @(#) $Id: TclToken.java,v 1.5 2005/10/29 00:27:43 mdejong Exp $
017:         */
018:
019:        package tcl.lang;
020:
021:        class TclToken {
022:
023:            // Contains an array the references the script from where the
024:            // token originates from and an index to the first character
025:            // of the token inside the script.
026:
027:            char[] script_array;
028:            // FIXME: Might be better to rename this as start so that
029:            // the Java impl looks more like the C impl in source code.
030:            int script_index;
031:
032:            // Number of bytes in token. 
033:
034:            int size;
035:
036:            // Type of token, such as TCL_TOKEN_WORD;  See Parse.java 
037:            // for valid types. 
038:
039:            int type;
040:
041:            // If this token is composed of other tokens, this field 
042:            // tells how many of them there are (including components
043:            // of components, etc.).  The component tokens immediately
044:            // follow this one.
045:
046:            int numComponents;
047:
048:            /*
049:             *----------------------------------------------------------------------
050:             *
051:             * Tcl_Token -> TclToken
052:             *
053:             *	All class variables are accessed directly for speed.  The 
054:             *	consrructor only needs to allocate memory for the script.
055:             *
056:             * Side effects:
057:             *	None.
058:             *
059:             *----------------------------------------------------------------------
060:             */
061:
062:            TclToken() {
063:                script_array = null;
064:                script_index = -1;
065:            }
066:
067:            /*
068:             *----------------------------------------------------------------------
069:             *
070:             * getTokenString --
071:             *
072:             *	The token string is a substring in the script.  The beginning
073:             * 	is deliminated by script_index, and the offset is the size
074:             * 	variable.  The first time this method is called the substring
075:             *	is cached in the str variable.
076:             *
077:             * 	Note: TclToken is designed to be write-once with respect to 
078:             * 	setting the script and size variables.  Failure to do this 
079:             * 	may lead to inconsistencies in str cache. 
080:             *
081:             * Results:
082:             *	The String representing the token.
083:             *
084:             * Side effects:
085:             *	None.
086:             *
087:             *----------------------------------------------------------------------
088:             */
089:
090:            String getTokenString() {
091:                final boolean debug = false;
092:
093:                if (debug && ((script_index + size) > script_array.length)) {
094:                    System.out.println();
095:                    System.out.println("Entered TclToken.getTokenString()");
096:                    System.out.println("hashCode() is " + hashCode());
097:                    System.out.println("script_array.length is "
098:                            + script_array.length);
099:                    System.out.println("script_index is " + script_index);
100:                    System.out.println("size is " + size);
101:
102:                    System.out.print("the string is \"");
103:                    for (int k = 0; k < script_array.length; k++) {
104:                        System.out.print(script_array[k]);
105:                    }
106:                    System.out.println("\"");
107:                }
108:
109:                return (new String(script_array, script_index, size));
110:            }
111:
112:            /*
113:             *----------------------------------------------------------------------
114:             *
115:             * toString --
116:             *
117:             *	Prints debug information about the TclToken.
118:             *
119:             * Results:
120:             *	A String containing the info.
121:             *
122:             * Side effects:
123:             *	None.
124:             *
125:             *----------------------------------------------------------------------
126:             */
127:
128:            public String toString() {
129:                StringBuffer sbuf = new StringBuffer();
130:                switch (type) {
131:                case Parser.TCL_TOKEN_WORD: {
132:                    sbuf.append("\n  Token Type: TCL_TOKEN_WORD");
133:                    break;
134:                }
135:                case Parser.TCL_TOKEN_SIMPLE_WORD: {
136:                    sbuf.append("\n  Token Type: TCL_TOKEN_SIMPLE_WORD");
137:                    break;
138:                }
139:                case Parser.TCL_TOKEN_TEXT: {
140:                    sbuf.append("\n  Token Type: TCL_TOKEN_TEXT");
141:                    break;
142:                }
143:                case Parser.TCL_TOKEN_BS: {
144:                    sbuf.append("\n  Token Type: TCL_TOKEN_BS");
145:                    break;
146:                }
147:                case Parser.TCL_TOKEN_COMMAND: {
148:                    sbuf.append("\n  Token Type: TCL_TOKEN_COMMAND");
149:                    break;
150:                }
151:                case Parser.TCL_TOKEN_VARIABLE: {
152:                    sbuf.append("\n  Token Type: TCL_TOKEN_VARIABLE");
153:                    break;
154:                }
155:                case Parser.TCL_TOKEN_SUB_EXPR: {
156:                    sbuf.append("\n  Token Type: TCL_TOKEN_SUB_EXPR");
157:                    break;
158:                }
159:                case Parser.TCL_TOKEN_OPERATOR: {
160:                    sbuf.append("\n  Token Type: TCL_TOKEN_OPERATOR");
161:                    break;
162:                }
163:                }
164:
165:                String ts = getTokenString();
166:                sbuf.append("\n  String:      " + ts);
167:                sbuf.append("\n  String Size: " + ts.length());
168:                sbuf.append("\n  ScriptIndex: " + script_index);
169:                sbuf.append("\n  NumComponents: " + numComponents);
170:                sbuf.append("\n  Token Size: " + size);
171:                return sbuf.toString();
172:            }
173:
174:        } // end TclToken
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.