# Path: run_tests.py
# def run_tests_list(tests_list,tokenizer):
# 	for idx,test in enumerate(tests_list) :
# 		s,validate = test
# 		print("test={0}".format(test))
# 
# 		file_lines = s.split("\n")
# 		lines = [ line+"\n" for line in file_lines ]
# 		# if empty line at end, kill it (supposed to be cleaned out of vline
# 		# before sent to parser)
# 		if lines[-1]=='\n':
# 			lines = lines[:-1]
# 		print( "split={0}".format(s.split("\n")))
# 		print( "lines={0} len={1}".format(lines,len(lines)),end="")
# 
# 		vline = VirtualLine(lines,idx)
# 		my_iter = iter(vline) 
# 
# 		print("vline={0}".format(str(vline)))
# 		tokens = tokenizer(my_iter)
# 		print( "  tokens={0}".format(str(tokens)) )
# 		print( "validate={0}".format(str(validate)) )
# 
# 		assert tokens==validate, (idx,)
# 
# 		print( tokens.makefile() )
# 		print("\n")


import sys
import hexdump
import vline
from pymake import *
from run_tests import run_tests_list

# the next line is <tab><tab>. Is valid. The tabs are eaten.
		@echo tab tab

# the next line is <tab><space><tab>. Is valid. The tabs/spaces are eaten.
	 	@echo tab space tab

# the next line is <tab><space><tab><space><space><space>. Is valid. The tabs/spaces are eaten.
	 	   @echo tab space tab space space space

# the next line is has trailing <tab>s and <space>s; can see the whitespace on a hexdump of this output
# the trailing whitespace is preserved
	@echo I have trailing whitespacespaces				  	   	

# this line ends the recipe; note can be interpretted as either an assignment or a shell recipe
 	foo=bar printenv "foo"

""", 
		RecipeList( [Recipe( [Literal("@echo lots of spaces in weird places ")]),Recipe( [Literal("")]),Recipe( [Literal("foo=bar printenv \"foo\"")]),Recipe( [Literal("@echo I am still inside "),VarRef( [Literal("@")]),Literal("")]),Recipe( [Literal("@echo tab tab")]),Recipe( [Literal("@echo tab space tab")]),Recipe( [Literal("@echo tab space tab space space space")]),Recipe( [Literal("@echo I have trailing whitespacespaces				  \t   \t")])])
		),

#------
	# from the Linux kernel 3.12.5 clean rule (removed the 'rm' to make safe)
			(r"""
	@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
		\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
		-o -name '*.ko.*' \
		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
		-o -name '*.symtypes' -o -name 'modules.order' \
		-o -name modules.builtin -o -name '.tmp_*.o.*' \

# Path: run_tests.py
# def run_tests_list(tests_list,tokenizer):
# 	for idx,test in enumerate(tests_list) :
# 		s,validate = test
# 		print("test={0}".format(test))
# 
# 		file_lines = s.split("\n")
# 		lines = [ line+"\n" for line in file_lines ]
# 		# if empty line at end, kill it (supposed to be cleaned out of vline
# 		# before sent to parser)
# 		if lines[-1]=='\n':
# 			lines = lines[:-1]
# 		print( "split={0}".format(s.split("\n")))
# 		print( "lines={0} len={1}".format(lines,len(lines)),end="")
# 
# 		vline = VirtualLine(lines,idx)
# 		my_iter = iter(vline) 
# 
# 		print("vline={0}".format(str(vline)))
# 		tokens = tokenizer(my_iter)
# 		print( "  tokens={0}".format(str(tokens)) )
# 		print( "validate={0}".format(str(validate)) )
# 
# 		assert tokens==validate, (idx,)
# 
# 		print( tokens.makefile() )
# 		print("\n")


# Path: test_recipe.py
import sys
import hexdump
import vline
from pymake import *
from run_tests import run_tests_list


# the next line is <tab><tab>. Is valid. The tabs are eaten.
		@echo tab tab

# the next line is <tab><space><tab>. Is valid. The tabs/spaces are eaten.
	 	@echo tab space tab

# the next line is <tab><space><tab><space><space><space>. Is valid. The tabs/spaces are eaten.
	 	   @echo tab space tab space space space

# the next line is has trailing <tab>s and <space>s; can see the whitespace on a hexdump of this output
# the trailing whitespace is preserved
	@echo I have trailing whitespacespaces				  	   	

# this line ends the recipe; note can be interpretted as either an assignment or a shell recipe
 	foo=bar printenv "foo"

""", 
		RecipeList( [Recipe( [Literal("@echo lots of spaces in weird places ")]),Recipe( [Literal("")]),Recipe( [Literal("foo=bar printenv \"foo\"")]),Recipe( [Literal("@echo I am still inside "),VarRef( [Literal("@")]),Literal("")]),Recipe( [Literal("@echo tab tab")]),Recipe( [Literal("@echo tab space tab")]),Recipe( [Literal("@echo tab space tab space space space")]),Recipe( [Literal("@echo I have trailing whitespacespaces				  \t   \t")])])
		),

#------
	# from the Linux kernel 3.12.5 clean rule (removed the 'rm' to make safe)
			(r"""
	@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
		\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
		-o -name '*.ko.*' \
		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
		-o -name '*.symtypes' -o -name 'modules.order' \
		-o -name modules.builtin -o -name '.tmp_*.o.*' \

		-o -name '*.gcno' \) -type f -print | xargs 