Class Generator
In: EFL.rb
Parent: Object
  • Generators are specified using substititions (with the sub and gsub methods), productions (with the prod method) and generations (with the gen method).
  • Generators can be combined in a sequential orden or mixed using the add (with the + and add methods) and the superposition (with the << and sup! methods).

Methods

+   <<   add   add?   after   before   del   extract   extract_dollar   gafter   gbefore   gdel   gen   gen?   gsub   prod   prod?   sub   sup!   sup?  

Public Instance methods

Adds self and generator. Returns a new Generator which substitutions and productions are the union of the substitutions and the productions of self and generator. Collisions between the substitutions of self and generator will be detected automatically calling the method add? (internally, + calls add?)

Superpose generator to self. << actualizes the substitutions and productions of self with the substitutions and productions of generator. The substitutions and productions of generator with a common name in self are overwritten in self. The others are added to self. Collisions between the substitutions of self and generator will be detected automatically calling the method sup (internally, << calls sup?)

Prefix notation for +

Returns if it is possible to add self and generator (see + and add)

Specifies a kind of substitution that inserts the text string after the first occurrence of the pattern expressed by the reg_exp regular expression. Optionally, this substitution can be named using the name string. To express complex ‘after inserts’, the regular expressions can be combined using the zoom operator (Regexp#>).

Specifies a kind of substitution that inserts the text string before the first occurrence of the pattern expressed by the reg_exp regular expression. Optionally, this substitution can be named using the name string. To express complex ‘before inserts’, the regular expressions can be combined using the zoom operator (Regexp#>).

Specifies a kind of substitution that deletes the first occurrence of the pattern expressed by the reg_exp regular expression. Optionally, this substitution can be named using the name string. To express complex deletes, the regular expressions can be combined using the zoom operator (Regexp#>).

Returns an array of the strings resulted on matching the reg_exp regular expression on the input file file

Returns an array of the strings grouped by the parenthesis number when the reg_exp regular expression is matched on the input file.

For example. if the content of myfile.txt is:

This is my code

The result of execute:

g = generator

puts "$1 = " + g.extract_dollar(‘myfile.txt’, /(This).*?(code).*?/, 1).to_s

puts "$2 = " + g.extract_dollar(‘myfile.txt’, /(This).*?(code).*?/, 2).to_s

would be

$1 = This

$2 = code

Specifies a kind of substitution that inserts the text string after all the occurrences of the pattern expressed by the reg_exp regular expression. Optionally, this substitution can be named using the name string. To express complex ‘global after inserts’, the regular expressions can be combined using the zoom operator (Regexp#>).def gbefore(reg_exp, text, name = nil)

Specifies a kind of substitution that inserts the text string before all the occurrences of the pattern expressed by the reg_exp regular expression. Optionally, this substitution can be named using the name string. To express complex ‘global before inserts’, the regular expressions can be combined using the zoom operator (Regexp#>).def gbefore(reg_exp, text, name = nil)

Specifies a kind of substitution that deletes all the occurrence of the pattern expressed by the reg_exp regular expression. Optionally, this substitution can be named using the name string. To express complex deletes, the regular expressions can be combined using the zoom operator (Regexp#>).

Specifies the execution of the set of productions prod_list.

  • If prod_list is not specified, it will contain implicitly all the productions defined before the current generation.
  • The order of the productions in prod_list is irrelevant.
  • It is posible that several substitutions included in the productions of sub_list try to make different changes over the same area of the exemplar. This kind of collisions will be detected automatically calling the method gen? (internally, gen calls gen?).

Returns if it is possible to execute a generation (see gen)

Specifies the change of all the occurrences of the pattern expressed by the reg_exp regular expression to the text string. Optionally, a substitution can be named using the name string. To build complex substitution patterns, the regular expressions can be combined using the zoom operator (Regexp#>).

Specifies the application of a set of substitutions (sub_list) on an input file (i_file) to produce an output file (o_file).

  • Optionally, a production can be named using the name string.
  • If sub_list is not specified, it will contain implicitly all the substitutions defined before the current production.
  • The order of the substitutions in sub_list is irrelevant.
  • It is posible that several substitutions of sub_list try to make different changes over the same area of the exemplar. This kind of collisions will be detected automatically calling the method prod? (internally, prod calls prod?).

Returns if it is possible to execute a production (see prod)

Specifies the change of the first occurrence of the pattern expressed by the reg_exp regular expression to the text string. Optionally, a substitution can be named using the name string. To build complex substitution patterns, the regular expressions can be combined using the zoom operator (Regexp#>).

Prefix notation for <<

Returns if it is possible to superpose self to generator (see << and sup!)

[Validate]