Source Code Cross Referenced for Rule.java in  » IDE-Netbeans » cnd » antlr » preprocessor » 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 » IDE Netbeans » cnd » antlr.preprocessor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package antlr.preprocessor;
002:
003:        /* ANTLR Translator Generator
004:         * Project led by Terence Parr at http://www.cs.usfca.edu
005:         * Software rights: http://www.antlr.org/license.html
006:         */
007:
008:        import antlr.collections.impl.IndexedVector;
009:
010:        import java.util.Hashtable;
011:        import java.util.Enumeration;
012:
013:        class Rule {
014:            protected String name;
015:            protected String block;
016:            protected String args;
017:            protected String returnValue;
018:            protected String throwsSpec;
019:            protected String initAction;
020:            protected IndexedVector options;
021:            protected String visibility;
022:            protected Grammar enclosingGrammar;
023:            protected boolean bang = false;
024:
025:            public Rule(String n, String b, IndexedVector options, Grammar gr) {
026:                name = n;
027:                block = b;
028:                this .options = options;
029:                setEnclosingGrammar(gr);
030:            }
031:
032:            public String getArgs() {
033:                return args;
034:            }
035:
036:            public boolean getBang() {
037:                return bang;
038:            }
039:
040:            public String getName() {
041:                return name;
042:            }
043:
044:            public String getReturnValue() {
045:                return returnValue;
046:            }
047:
048:            public String getVisibility() {
049:                return visibility;
050:            }
051:
052:            /** If 'rule' narrows the visible of 'this', return true;
053:             *  For example, 'this' is public and 'rule' is private,
054:             *  true is returned.  You cannot narrow the vis. of
055:             *  a rule.
056:             */
057:            public boolean narrowerVisibility(Rule rule) {
058:                if (visibility.equals("public")) {
059:                    if (!rule.equals("public")) {
060:                        return true; // everything narrower than public
061:                    }
062:                    return false;
063:                } else if (visibility.equals("protected")) {
064:                    if (rule.equals("private")) {
065:                        return true; // private narrower than protected
066:                    }
067:                    return false;
068:                } else if (visibility.equals("private")) {
069:                    return false; // nothing is narrower than private
070:                }
071:                return false;
072:            }
073:
074:            /** Two rules have the same signature if they have:
075:             *  	same name
076:             *		same return value
077:             *		same args
078:             *	I do a simple string compare now, but later
079:             *	the type could be pulled out so it is insensitive
080:             *	to names of args etc...
081:             */
082:            public boolean sameSignature(Rule rule) {
083:                boolean nSame = true;
084:                boolean aSame = true;
085:                boolean rSame = true;
086:
087:                nSame = name.equals(rule.getName());
088:                if (args != null) {
089:                    aSame = args.equals(rule.getArgs());
090:                }
091:                if (returnValue != null) {
092:                    rSame = returnValue.equals(rule.getReturnValue());
093:                }
094:                return nSame && aSame && rSame;
095:            }
096:
097:            public void setArgs(String a) {
098:                args = a;
099:            }
100:
101:            public void setBang() {
102:                bang = true;
103:            }
104:
105:            public void setEnclosingGrammar(Grammar g) {
106:                enclosingGrammar = g;
107:            }
108:
109:            public void setInitAction(String a) {
110:                initAction = a;
111:            }
112:
113:            public void setOptions(IndexedVector options) {
114:                this .options = options;
115:            }
116:
117:            public void setReturnValue(String ret) {
118:                returnValue = ret;
119:            }
120:
121:            public void setThrowsSpec(String t) {
122:                throwsSpec = t;
123:            }
124:
125:            public void setVisibility(String v) {
126:                visibility = v;
127:            }
128:
129:            public String toString() {
130:                String s = "";
131:                String retString = returnValue == null ? "" : "returns "
132:                        + returnValue;
133:                String argString = args == null ? "" : args;
134:                String bang = getBang() ? "!" : "";
135:
136:                s += visibility == null ? "" : visibility + " ";
137:                s += name + bang + argString + " " + retString + throwsSpec;
138:                if (options != null) {
139:                    s += System.getProperty("line.separator") + "options {"
140:                            + System.getProperty("line.separator");
141:                    for (Enumeration e = options.elements(); e
142:                            .hasMoreElements();) {
143:                        s += (Option) e.nextElement()
144:                                + System.getProperty("line.separator");
145:                    }
146:                    s += "}" + System.getProperty("line.separator");
147:                }
148:                if (initAction != null) {
149:                    s += initAction + System.getProperty("line.separator");
150:                }
151:                s += block;
152:                return s;
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.