Class: Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/xamplr-pp/examples/parse.rb,
lib/xamplr-pp/examples/parse-wf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



6
7
8
# File 'lib/xamplr-pp/examples/parse.rb', line 6

def count
  @count
end

Instance Method Details

#parse(filename) ⇒ Object



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
# File 'lib/xamplr-pp/examples/parse.rb', line 8

def parse(filename)
	@xpp = Xampl_PP.new
	@xpp.input = File.new(filename)

	@count = 0

#printf("__________________________________")
	while not @xpp.endDocument? do
		event = @xpp.nextEvent
if(0 == (@count % 10001)) then
 printf("count: %d\n", count)
end
#printf("\nEVENT: %s\n", event)
		case event
		#case @xpp.nextEvent
      when Xampl_PP::START_DOCUMENT
				@count += 1
       when Xampl_PP::END_DOCUMENT
				@count += 1
       when Xampl_PP::START_ELEMENT
				@count += 1
       when Xampl_PP::END_ELEMENT
				@count += 1
       when Xampl_PP::TEXT
				@count += 1
       when Xampl_PP::CDATA_SECTION
				@count += 1
       when Xampl_PP::ENTITY_REF
				@count += 1
       when Xampl_PP::IGNORABLE_WHITESPACE
				@count += 1
       when Xampl_PP::PROCESSING_INSTRUCTION
				@count += 1
       when Xampl_PP::COMMENT
				@count += 1
       when Xampl_PP::DOCTYPE
				@count += 1
		end
	end
end