PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/regular_expression/example2.e

http://github.com/tybor/Liberty
Specman e | 39 lines | 24 code | 3 blank | 12 comment | 0 complexity | 50d69bbd42d2f0296bcc952879b39db5 MD5 | raw file
 1class EXAMPLE2
 2   --
 3   -- How to do substitution with Liberty Eiffel:
 4   --
 5   --            compile -o example2 -boost example2
 6   --
 7
 8create {ANY}
 9   make
10
11feature {ANY}
12   make
13      local
14         factory: REGULAR_EXPRESSION_BUILDER; se: REGULAR_EXPRESSION
15      do
16         -- Use "LibertyEiffel" as spelling.
17         -- Create the regular expression from the pattern.
18         se := factory.convert_posix_pattern("[lL]iberty.?[eE]iffel")
19         check
20         -- The given pattern is valid. Else, consult
21         -- factory.last_error_message and factory.last_error_position
22            se /= Void
23         end
24         -- Defines the substitution
25         se.prepare_substitution("LibertyEiffel")
26         check
27         -- This substitution pattern is valid!
28            se.substitution_pattern_ready
29         end
30         io.put_string("Please write some text.%N")
31         io.read_line
32         -- Translate to the proper speeling.
33         se.substitute_all_in(io.last_string)
34         io.put_string("The proper spelling is: ")
35         io.put_string(io.last_string)
36         io.put_new_line
37      end
38
39end -- class EXAMPLE2