Class: PlusElement
- Inherits:
-
OperatorElement
- Object
- Element
- OperatorElement
- PlusElement
- Defined in:
- lib/rpdf2txt-rockit/grammar.rb
Instance Attribute Summary
Attributes inherited from OperatorElement
Attributes inherited from Element
#sub_elements, #tree_specification
Instance Method Summary collapse
- #inspect ⇒ Object
-
#normalize(productions) ⇒ Object
NT -> a b (se1 … sen)+ c d.
Methods inherited from OperatorElement
#==, #initialize, #name, #to_src
Methods inherited from Element
Methods included from SourceCodeDumpable
as_code, as_method_named, as_module_method_named, #create_new, indent_lines, name_hash, #new_of_my_type, #parameter_named, #to_compact_src, #to_src_in_module, #type_to_src
Constructor Details
This class inherits a constructor from OperatorElement
Instance Method Details
#inspect ⇒ Object
129 130 131 |
# File 'lib/rpdf2txt-rockit/grammar.rb', line 129 def inspect "#{inspect_sub_elements}+" end |
#normalize(productions) ⇒ Object
NT -> a b (se1 … sen)+ c d
is normalized to
NT -> a b NT-Plus-X c d NT-Plus-X -> NT-Plus-X se1 … sen
| se1 ... sen
140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/rpdf2txt-rockit/grammar.rb', line 140 def normalize(productions) temp_nonterm = temp_nonterminal("Plus", productions.first) num_sub_elements = @sub_elements.length temp_production1 = Production.new(temp_nonterm, [temp_nonterm].concat(@sub_elements), ArrayNodeBuilder.new((1..num_sub_elements).to_a, 0)) temp_production2 = Production.new(temp_nonterm, @sub_elements, ArrayNodeBuilder.new((0...num_sub_elements).to_a)) [clone_and_substitute_productions(productions, [temp_nonterm]), temp_production1.normalize + temp_production2.normalize] end |