Source Code Cross Referenced for parse_action_row.java in  » Parser » CUP-develop » java_cup » 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 » Parser » CUP develop » java_cup 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package java_cup;
002:
003:        /** This class represents one row (corresponding to one machine state) of the 
004:         *  parse action table.
005:         */
006:        public class parse_action_row {
007:
008:            /*-----------------------------------------------------------*/
009:            /*--- Constructor(s) ----------------------------------------*/
010:            /*-----------------------------------------------------------*/
011:
012:            /** Simple constructor.  Note: this should not be used until the number of
013:             *  terminals in the grammar has been established.
014:             */
015:            public parse_action_row() {
016:                /* make sure the size is set */
017:                if (_size <= 0)
018:                    _size = terminal.number();
019:
020:                /* allocate the array */
021:                under_term = new parse_action[size()];
022:
023:                /* set each element to an error action */
024:                for (int i = 0; i < _size; i++)
025:                    under_term[i] = new parse_action();
026:            }
027:
028:            /*-----------------------------------------------------------*/
029:            /*--- (Access to) Static (Class) Variables ------------------*/
030:            /*-----------------------------------------------------------*/
031:
032:            /** Number of columns (terminals) in every row. */
033:            protected static int _size = 0;
034:
035:            /** Number of columns (terminals) in every row. */
036:            public static int size() {
037:                return _size;
038:            }
039:
040:            //Hm Added clear  to clear all static fields
041:            public static void clear() {
042:                _size = 0;
043:                reduction_count = null;
044:            }
045:
046:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
047:
048:            /** Table of reduction counts (reused by compute_default()). */
049:            protected static int reduction_count[] = null;
050:
051:            /*-----------------------------------------------------------*/
052:            /*--- (Access to) Instance Variables ------------------------*/
053:            /*-----------------------------------------------------------*/
054:
055:            /** Actual action entries for the row. */
056:            public parse_action under_term[];
057:
058:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
059:
060:            /** Default (reduce) action for this row.  -1 will represent default 
061:             *  of error. 
062:             */
063:            public int default_reduce;
064:
065:            /*-----------------------------------------------------------*/
066:            /*--- General Methods ---------------------------------------*/
067:            /*-----------------------------------------------------------*/
068:
069:            /** Compute the default (reduce) action for this row and store it in 
070:             *  default_reduce.  In the case of non-zero default we will have the 
071:             *  effect of replacing all errors by that reduction.  This may cause 
072:             *  us to do erroneous reduces, but will never cause us to shift past 
073:             *  the point of the error and never cause an incorrect parse.  -1 will 
074:             *  be used to encode the fact that no reduction can be used as a 
075:             *  default (in which case error will be used).
076:             */
077:            public void compute_default() {
078:                int i, prod, max_prod, max_red;
079:
080:                /* if we haven't allocated the count table, do so now */
081:                if (reduction_count == null)
082:                    reduction_count = new int[production.number()];
083:
084:                /* clear the reduction count table and maximums */
085:                for (i = 0; i < production.number(); i++)
086:                    reduction_count[i] = 0;
087:                max_prod = -1;
088:                max_red = 0;
089:
090:                /* walk down the row and look at the reduces */
091:                for (i = 0; i < size(); i++)
092:                    if (under_term[i].kind() == parse_action.REDUCE) {
093:                        /* count the reduce in the proper production slot and keep the 
094:                           max up to date */
095:                        prod = ((reduce_action) under_term[i]).reduce_with()
096:                                .index();
097:                        reduction_count[prod]++;
098:                        if (reduction_count[prod] > max_red) {
099:                            max_red = reduction_count[prod];
100:                            max_prod = prod;
101:                        }
102:                    }
103:
104:                /* record the max as the default (or -1 for not found) */
105:                default_reduce = max_prod;
106:            }
107:
108:            /*-----------------------------------------------------------*/
109:
110:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.