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
|
# File 'lib/indent_code/indent_cpp.rb', line 8
def initialize
@parser = Iparser::Machine.new
@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_scope = Iparser::State.new('scope')
@parser.addstate @st_scope
@parser.addstate @st_cline
@parser.addstate @st_cblock
@parser.addstate @st_string
@parser.addstate @st_screen
@st_cline.entry << '/'
@st_cline.entry << '/'
@st_cline.leave << /[\n\r]/
@st_cblock.entry << '/'
@st_cblock.entry << '*'
@st_cblock.leave << '*'
@st_cblock.leave << '/'
@st_cblock.handler( method( :cblock_handler ) )
@st_cblock.fini( method( :cblock_fini ) )
@st_string.entry << '"'
@st_string.leave << '"'
@st_string.branches << @parser.state_index( @st_screen )
@st_screen.entry << '\\'
@st_screen.leave << /./
@st_scope.entry << '{'
@st_scope.leave << '}'
@st_scope.branches << @parser.state_index( @st_scope )
@st_scope.branches << @parser.state_index( @st_cline )
@st_scope.branches << @parser.state_index( @st_cblock )
@st_scope.branches << @parser.state_index( @st_string )
@st_scope.init( method( :scope_init ) )
@st_scope.fini( method( :scope_fini ) )
@parser.prestart
end
|