Class: Preprocessor::AllTokens

Inherits:
Object
  • Object
show all
Includes:
CTokenizer
Defined in:
lib/caphir/define.rb

Constant Summary

Constants included from CTokenizer

CTokenizer::CP_RESERVED, CTokenizer::C_RESERVED, CTokenizer::EOF_TOKEN

Instance Method Summary collapse

Methods included from CTokenizer

#collect, #each, #error, error, line_count, #parse_error, #to_a, #token_error, #unmatched_error, #warning

Constructor Details

#initialize(source, macro_tokens) ⇒ AllTokens

Returns a new instance of AllTokens.



14
15
16
17
# File 'lib/caphir/define.rb', line 14

def initialize(source, macro_tokens)
	@source = source
	@macro_tokens = macro_tokens
end

Instance Method Details

#args_given?Boolean

Returns:

  • (Boolean)


51
52
53
54
55
56
57
# File 'lib/caphir/define.rb', line 51

def args_given?
	if t = @macro_tokens.peek_nonspace
		t[1] == '('
	else
		@source.match?(/\s*\(/)
	end
end

#empty?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/caphir/define.rb', line 47

def empty?
	@source.empty? and @macro_tokens.empty?
end

#fileObject



59
# File 'lib/caphir/define.rb', line 59

def file; @source.file end

#lineObject



60
# File 'lib/caphir/define.rb', line 60

def line; @source.line end

#resolvingObject



28
29
30
# File 'lib/caphir/define.rb', line 28

def resolving
	@macro_tokens.resolving
end

#resolving?(t_str) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/caphir/define.rb', line 32

def resolving?(t_str)
	@macro_tokens.resolving?(t_str)
end

#shiftObject



19
20
21
22
23
24
25
26
# File 'lib/caphir/define.rb', line 19

def shift
	if @macro_tokens.empty?
#raise "still resolving? - impossible" unless @macro_tokens.resolving.empty?
		@source.shift
	else
		@macro_tokens.shift
	end
end

#shift_and_filterObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/caphir/define.rb', line 36

def shift_and_filter
	if @macro_tokens.empty?
#raise "still resolving? - impossible" unless @macro_tokens.resolving.empty?
		@source.shift
	else
		t = @macro_tokens.shift
		t = self.shift_and_filter if t[0] == :RESOLVING
		t
	end
end