Class: IndentCode::Cleaner
- Inherits:
-
Object
- Object
- IndentCode::Cleaner
- Includes:
- IndentCode
- Defined in:
- lib/indent_code/cleaner.rb
Constant Summary
Constants included from IndentCode
Instance Method Summary collapse
-
#clean(c) ⇒ Object
clean method handler.
-
#initialize ⇒ Cleaner
constructor
A new instance of Cleaner.
Methods included from IndentCode
Constructor Details
#initialize ⇒ Cleaner
Returns a new instance of Cleaner.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/indent_code/cleaner.rb', line 8 def initialize @parser = Iparser::Machine.new @st_idle = Iparser::State.new('idle') @st_cline = Iparser::State.new('comment-line') @st_cblock = Iparser::State.new('comment-block') @st_string = Iparser::State.new('string') @st_screen = Iparser::State.new('screen') @st_cpp = Iparser::State.new('cpp') @parser.addstate @st_idle @parser.addstate @st_cpp @parser.addstate @st_cline @parser.addstate @st_cblock @parser.addstate @st_string @parser.addstate @st_screen # Setting idle state. @st_idle.ignore << ' ' @st_idle.branches << @parser.state_index( @st_cpp ) @st_idle.branches << @parser.state_index( @st_cline ) @st_idle.branches << @parser.state_index( @st_cblock ) @st_idle.branches << @parser.state_index( @st_string ) # Setting comment-line state. @st_cline.entry << '/' @st_cline.entry << '/' @st_cline.leave << /[\n\r]/ # Setting comment-block state. @st_cblock.entry << '/' @st_cblock.entry << '*' @st_cblock.leave << '*' @st_cblock.leave << '/' # Setting string state. @st_string.entry << '"' @st_string.leave << '"' @st_string.branches << @parser.state_index( @st_screen ) # Setting screen state. @st_screen.entry << '\\' @st_screen.leave << /./ # Setting preprocessor handler state. @st_cpp.entry << '#' @st_cpp.entry << 'i' @st_cpp.entry << 'f' @st_cpp.entry << '0' @st_cpp.leave << '#' @st_cpp.leave << 'e' @st_cpp.leave << 'n' @st_cpp.leave << 'd' @st_cpp.leave << 'i' @st_cpp.leave << 'f' @st_cpp.ignore << ' ' @st_cpp.branches << @parser.state_index( @st_cline ) @st_cpp.branches << @parser.state_index( @st_cblock ) @st_cpp.branches << @parser.state_index( @st_string ) @st_cpp.init( method( :cpp_init ) ) @st_cpp.fini( method( :cpp_fini ) ) @parser.prestart end |
Instance Method Details
#clean(c) ⇒ Object
clean method handler.
85 86 87 |
# File 'lib/indent_code/cleaner.rb', line 85 def clean ( c ) return @parser.parse( c ) end |