# 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
from pymake import *
from run_tests import run_tests_list

		( "this $(  is  ) $a $test = ",  AssignmentExpression( [Expression( [Literal("this "),VarRef( [Literal("  is  ")]),Literal(" "),VarRef( [Literal("a")]),Literal(" "),VarRef( [Literal("t")]),Literal("est")]),AssignOp("="),Expression( [Literal("")])])  ),

		( "this$(is)$a$(test) : ",	   RuleExpression( [Expression( [Literal("this"),VarRef( [Literal("is")]),Literal(""),VarRef( [Literal("a")]),Literal(""),VarRef( [Literal("test")]),Literal("")]),RuleOp(":"),PrerequisiteList( [])]) ),

		( "this is a test : ",		   RuleExpression( [Expression( [Literal("this"),Literal("is"),Literal("a"),Literal("test")]),RuleOp(":"),PrerequisiteList( [])])  ),

		( "  this   is   a   test   : ", RuleExpression( [Expression( [Literal("this"),Literal("is"),Literal("a"),Literal("test")]),RuleOp(":"),PrerequisiteList( [])])  ),

		( "this $(is) $a $test : ",	  RuleExpression( [Expression( [Literal("this"),Literal(""),VarRef( [Literal("is")]),Literal(""),Literal(""),VarRef( [Literal("a")]),Literal(""),Literal(""),VarRef( [Literal("t")]),Literal("est")]),RuleOp(":"),PrerequisiteList( [])]) ),

		# yadda yadda yadda
		( "override all=foo",	AssignmentExpression( [Expression( [Literal("override all")]),AssignOp("="),Expression( [Literal("foo")])]) ),

		( "all:",	   RuleExpression( [Expression( [Literal("all")]),RuleOp(":"),PrerequisiteList( [])]) ),

		( "all:foo",	RuleExpression( [Expression( [Literal("all")]),RuleOp(":"),PrerequisiteList( [Literal("foo")])]) ),

		( "   all :   foo	", RuleExpression( [Expression( [Literal("all")]),RuleOp(":"),PrerequisiteList( [Literal("foo")])]) ),
		( "   all :   foo#comment	", RuleExpression( [Expression( [Literal("all")]),RuleOp(":"),PrerequisiteList( [Literal("foo")])]) ),

		# this line is a happy train wreck!
		( r"""   all :\
		foo2#comment2\
		comment2comment2
	bar""", RuleExpression( [Expression( [Literal("all")]),RuleOp(":"),PrerequisiteList( [Literal("foo")])]) ),

		# how about backslashes? 
		( r"""all : test-backslash-semicolon test-backslash-recipes lots-of-fore-whitespace\
lots-of-aft-whitespace backslash-in-string backslash-in-string-echo\

# 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_statement.py
import sys
from pymake import *
from run_tests import run_tests_list


		( "this $(  is  ) $a $test = ",  AssignmentExpression( [Expression( [Literal("this "),VarRef( [Literal("  is  ")]),Literal(" "),VarRef( [Literal("a")]),Literal(" "),VarRef( [Literal("t")]),Literal("est")]),AssignOp("="),Expression( [Literal("")])])  ),

		( "this$(is)$a$(test) : ",	   RuleExpression( [Expression( [Literal("this"),VarRef( [Literal("is")]),Literal(""),VarRef( [Literal("a")]),Literal(""),VarRef( [Literal("test")]),Literal("")]),RuleOp(":"),PrerequisiteList( [])]) ),

		( "this is a test : ",		   RuleExpression( [Expression( [Literal("this"),Literal("is"),Literal("a"),Literal("test")]),RuleOp(":"),PrerequisiteList( [])])  ),

		( "  this   is   a   test   : ", RuleExpression( [Expression( [Literal("this"),Literal("is"),Literal("a"),Literal("test")]),RuleOp(":"),PrerequisiteList( [])])  ),

		( "this $(is) $a $test : ",	  RuleExpression( [Expression( [Literal("this"),Literal(""),VarRef( [Literal("is")]),Literal(""),Literal(""),VarRef( [Literal("a")]),Literal(""),Literal(""),VarRef( [Literal("t")]),Literal("est")]),RuleOp(":"),PrerequisiteList( [])]) ),

		# yadda yadda yadda
		( "override all=foo",	AssignmentExpression( [Expression( [Literal("override all")]),AssignOp("="),Expression( [Literal("foo")])]) ),

		( "all:",	   RuleExpression( [Expression( [Literal("all")]),RuleOp(":"),PrerequisiteList( [])]) ),

		( "all:foo",	RuleExpression( [Expression( [Literal("all")]),RuleOp(":"),PrerequisiteList( [Literal("foo")])]) ),

		( "   all :   foo	", RuleExpression( [Expression( [Literal("all")]),RuleOp(":"),PrerequisiteList( [Literal("foo")])]) ),
		( "   all :   foo#comment	", RuleExpression( [Expression( [Literal("all")]),RuleOp(":"),PrerequisiteList( [Literal("foo")])]) ),

		# this line is a happy train wreck!
		( r"""   all :\
		foo2#comment2\
		comment2comment2
	bar""", RuleExpression( [Expression( [Literal("all")]),RuleOp(":"),PrerequisiteList( [Literal("foo")])]) ),

		# how about backslashes? 
		( r"""all : test-backslash-semicolon test-backslash-recipes lots-of-fore-whitespace\
lots-of-aft-whitespace backslash-in-string backslash-in-string-echo\

backslash-eol backslash-o-rama backslash-space-eol assignment split-assignment \