Module: Build::Makefile::Parser

Defined in:
lib/build/makefile.rb

Constant Summary collapse

SOURCE_PATH =
/(\\\s|[^\s])+/
SOURCE_SEPARATOR =
/((:?\\\n|\s|\n)+)/

Class Method Summary collapse

Class Method Details

.parse(scanner) ⇒ Object



89
90
91
92
93
# File 'lib/build/makefile.rb', line 89

def self.parse(scanner)
	while definition = parse_statement(scanner)
		yield definition
	end
end

.parse_rule(scanner) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/build/makefile.rb', line 62

def self.parse_rule(scanner)
	if scanner.scan(/(.*):/)
		rule = [:rule]
	
		target = scanner[1].strip
		rule << target
	
		# Parse dependencies:
		dependencies = []
		until scanner.scan(/\s*\n/) or scanner.eos?
			scanner.scan(/(\s|\\\n)*/)
		
			scanner.scan(SOURCE_PATH)
			
			# Need to remove escaped whitespace from path:
			dependencies << scanner[0].gsub(/\\ /, ' ')
		end
		rule << dependencies
	
		return rule
	end
end

.parse_statement(scanner) ⇒ Object



85
86
87
# File 'lib/build/makefile.rb', line 85

def self.parse_statement(scanner)
	parse_rule(scanner)
end