Java Doc for production.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 Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java_cup.production

All known Subclasses:   java_cup.action_production,
production
public class production (Code)
This class represents a production in the grammar. It contains a LHS non terminal, and an array of RHS symbols. As various transformations are done on the RHS of the production, it may shrink. As a result a separate length is always maintained to indicate how much of the RHS array is still valid.

I addition to construction and manipulation operations, productions provide methods for factoring out actions (see remove_embedded_actions()), for computing the nullability of the production (i.e., can it derive the empty string, see check_nullable()), and operations for computing its first set (i.e., the set of terminals that could appear at the beginning of some string derived from the production, see check_first_set()).
See Also:   java_cup.production_part
See Also:   java_cup.symbol_part
See Also:   java_cup.action_part
version:
   last updated: 7/3/96
author:
   Frank Flannery



Field Summary
protected  action_part_action
     An action_part containing code for the action to be performed when we reduce with this production.
protected static  Hashtable_all
     Table of all productions.
protected  terminal_set_first_set
     First set of the production.
protected  int_index
     Index number of the production.
protected  symbol_part_lhs
     The left hand side non-terminal.
protected  boolean_nullable
     Nullability of the production (can it derive the empty string).
protected  boolean_nullable_known
    
protected  int_num_reductions
     Count of number of reductions using this production.
protected  production_part_rhs
     A collection of parts for the right hand side.
protected  int_rhs_assoc
    
protected  int_rhs_length
     How much of the right hand side array we are presently using.
protected  int_rhs_prec
    
protected static  intnext_index
     Static counter for assigning unique index numbers.

Constructor Summary
public  production(non_terminal lhs_sym, production_part rhs_parts, int rhs_l, String action_str)
     Full constructor.
public  production(non_terminal lhs_sym, production_part rhs_parts, int rhs_l)
     Constructor with no action string.
public  production(non_terminal lhs_sym, production_part rhs_parts, int rhs_l, String action_str, int prec_num, int prec_side)
    
public  production(non_terminal lhs_sym, production_part rhs_parts, int rhs_l, int prec_num, int prec_side)
    

Method Summary
public  action_partaction()
     An action_part containing code for the action to be performed when we reduce with this production.
public static  Enumerationall()
     Access to all productions.
public  terminal_setcheck_first_set()
     Update (and return) the first set based on current NT firsts.
public  booleancheck_nullable()
     Check to see if the production (now) appears to be nullable.
public static  voidclear()
    
protected  Stringdeclare_labels(production_part rhs, int rhs_len, String final_action)
     Declare label names as valid variables within the action string
Parameters:
  rhs - array of RHS parts.
Parameters:
  rhs_len - how much of rhs to consider valid.
Parameters:
  final_action - the final action string of the production.
public  booleanequals(production other)
     Equality comparison.
public  booleanequals(Object other)
     Generic equality comparison.
public static  productionfind(int indx)
     Lookup a production by index.
public  terminal_setfirst_set()
     First set of the production.
public  inthashCode()
     Produce a hash code.
public  intindex()
     Index number of the production.
protected static  booleanis_id_char(char c)
     Determine if a character can be in a label id.
protected static  booleanis_id_start(char c)
     Determine if a given character can be a label id starter.
public  symbol_partlhs()
     The left hand side non-terminal.
protected  Stringmake_declaration(String labelname, String stack_type, int offset)
    
protected  intmerge_adjacent_actions(production_part rhs_parts, int len)
     Helper routine to merge adjacent actions in a set of RHS parts
Parameters:
  rhs_parts - array of RHS parts.
Parameters:
  len - amount of that array that is valid.
public  voidnote_reduction_use()
    
public  booleannullable()
     Nullability of the production (can it derive the empty string).
public  booleannullable_known()
    
public  intnum_reductions()
     Count of number of reductions using this production.
public static  intnumber()
     Total number of productions.
public  intprecedence_num()
    
public  intprecedence_side()
    
protected  voidremove_embedded_actions()
     Remove all embedded actions from a production by factoring them out into individual action production using new non terminals.
public  production_partrhs(int indx)
     Access to the collection of parts for the right hand side.
public  intrhs_length()
     How much of the right hand side array we are presently using.
 booleanset_nullable(boolean v)
    
public  voidset_precedence_num(int prec_num)
    
public  voidset_precedence_side(int prec_side)
    
protected  action_partstrip_trailing_action(production_part rhs_parts, int len)
     Helper routine to strip a trailing action off rhs and return it
Parameters:
  rhs_parts - array of RHS parts.
Parameters:
  len - how many of those are valid.
public  StringtoString()
     Convert to a string.
public  Stringto_simple_string()
     Convert to a simpler string.

Field Detail
_action
protected action_part _action(Code)
An action_part containing code for the action to be performed when we reduce with this production.



_all
protected static Hashtable _all(Code)
Table of all productions. Elements are stored using their index as the key.



_first_set
protected terminal_set _first_set(Code)
First set of the production. This is the set of terminals that could appear at the front of some string derived from this production.



_index
protected int _index(Code)
Index number of the production.



_lhs
protected symbol_part _lhs(Code)
The left hand side non-terminal.



_nullable
protected boolean _nullable(Code)
Nullability of the production (can it derive the empty string).



_nullable_known
protected boolean _nullable_known(Code)
Is the nullability of the production known or unknown?



_num_reductions
protected int _num_reductions(Code)
Count of number of reductions using this production.



_rhs
protected production_part _rhs(Code)
A collection of parts for the right hand side.



_rhs_assoc
protected int _rhs_assoc(Code)



_rhs_length
protected int _rhs_length(Code)
How much of the right hand side array we are presently using.



_rhs_prec
protected int _rhs_prec(Code)
The precedence of the rule



next_index
protected static int next_index(Code)
Static counter for assigning unique index numbers.




Constructor Detail
production
public production(non_terminal lhs_sym, production_part rhs_parts, int rhs_l, String action_str) throws internal_error(Code)
Full constructor. This constructor accepts a LHS non terminal, an array of RHS parts (including terminals, non terminals, and actions), and a string for a final reduce action. It does several manipulations in the process of creating a production object. After some validity checking it translates labels that appear in actions into code for accessing objects on the runtime parse stack. It them merges adjacent actions if they appear and moves any trailing action into the final reduce actions string. Next it removes any embedded actions by factoring them out with new action productions. Finally it assigns a unique index to the production.

Factoring out of actions is accomplished by creating new "hidden" non terminals. For example if the production was originally:

 A ::= B {action} C D
 
then it is factored into two productions:
 A ::= B X C D
 X ::= {action}
 
(where X is a unique new non terminal). This has the effect of placing all actions at the end where they can be handled as part of a reduce by the parser.



production
public production(non_terminal lhs_sym, production_part rhs_parts, int rhs_l) throws internal_error(Code)
Constructor with no action string.



production
public production(non_terminal lhs_sym, production_part rhs_parts, int rhs_l, String action_str, int prec_num, int prec_side) throws internal_error(Code)



production
public production(non_terminal lhs_sym, production_part rhs_parts, int rhs_l, int prec_num, int prec_side) throws internal_error(Code)




Method Detail
action
public action_part action()(Code)
An action_part containing code for the action to be performed when we reduce with this production.



all
public static Enumeration all()(Code)
Access to all productions.



check_first_set
public terminal_set check_first_set() throws internal_error(Code)
Update (and return) the first set based on current NT firsts. This assumes that nullability has already been computed for all non terminals and productions.



check_nullable
public boolean check_nullable() throws internal_error(Code)
Check to see if the production (now) appears to be nullable. A production is nullable if its RHS could derive the empty string. This results when the RHS is empty or contains only non terminals which themselves are nullable.



clear
public static void clear()(Code)



declare_labels
protected String declare_labels(production_part rhs, int rhs_len, String final_action)(Code)
Declare label names as valid variables within the action string
Parameters:
  rhs - array of RHS parts.
Parameters:
  rhs_len - how much of rhs to consider valid.
Parameters:
  final_action - the final action string of the production.
Parameters:
  lhs_type - the object type associated with the LHS symbol.



equals
public boolean equals(production other)(Code)
Equality comparison.



equals
public boolean equals(Object other)(Code)
Generic equality comparison.



find
public static production find(int indx)(Code)
Lookup a production by index.



first_set
public terminal_set first_set()(Code)
First set of the production. This is the set of terminals that could appear at the front of some string derived from this production.



hashCode
public int hashCode()(Code)
Produce a hash code.



index
public int index()(Code)
Index number of the production.



is_id_char
protected static boolean is_id_char(char c)(Code)
Determine if a character can be in a label id.
Parameters:
  c - the character in question.



is_id_start
protected static boolean is_id_start(char c)(Code)
Determine if a given character can be a label id starter.
Parameters:
  c - the character in question.



lhs
public symbol_part lhs()(Code)
The left hand side non-terminal.



make_declaration
protected String make_declaration(String labelname, String stack_type, int offset)(Code)
Return label declaration code
Parameters:
  labelname - the label name
Parameters:
  stack_type - the stack type of label?
author:
   frankf



merge_adjacent_actions
protected int merge_adjacent_actions(production_part rhs_parts, int len)(Code)
Helper routine to merge adjacent actions in a set of RHS parts
Parameters:
  rhs_parts - array of RHS parts.
Parameters:
  len - amount of that array that is valid. remaining valid length.



note_reduction_use
public void note_reduction_use()(Code)
Increment the count of reductions with this non-terminal



nullable
public boolean nullable()(Code)
Nullability of the production (can it derive the empty string).



nullable_known
public boolean nullable_known()(Code)
Is the nullability of the production known or unknown?



num_reductions
public int num_reductions()(Code)
Count of number of reductions using this production.



number
public static int number()(Code)
Total number of productions.



precedence_num
public int precedence_num()(Code)
Access to the precedence of the rule



precedence_side
public int precedence_side()(Code)



remove_embedded_actions
protected void remove_embedded_actions() throws internal_error(Code)
Remove all embedded actions from a production by factoring them out into individual action production using new non terminals. if the original production was:
 A ::= B {action1} C {action2} D 
 
then it will be factored into:
 A ::= B NT$1 C NT$2 D
 NT$1 ::= {action1}
 NT$2 ::= {action2}
 
where NT$1 and NT$2 are new system created non terminals.



rhs
public production_part rhs(int indx) throws internal_error(Code)
Access to the collection of parts for the right hand side.



rhs_length
public int rhs_length()(Code)
How much of the right hand side array we are presently using.



set_nullable
boolean set_nullable(boolean v)(Code)
set (and return) nullability



set_precedence_num
public void set_precedence_num(int prec_num)(Code)
Setting the precedence of a rule



set_precedence_side
public void set_precedence_side(int prec_side)(Code)



strip_trailing_action
protected action_part strip_trailing_action(production_part rhs_parts, int len)(Code)
Helper routine to strip a trailing action off rhs and return it
Parameters:
  rhs_parts - array of RHS parts.
Parameters:
  len - how many of those are valid. the removed action part.



toString
public String toString()(Code)
Convert to a string.



to_simple_string
public String to_simple_string() throws internal_error(Code)
Convert to a simpler string.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.