'*******************************************************************************
' EverEdit Syntax File
' Language:    makefile
' Maintainer:  lwn
' History:
'   2012/12/9 Create
'   2013/1/18 Modified some regular expression
'*******************************************************************************

Include(".\const.mac")

Set make = CreateParser()

'variable name
Set iVarName = make.CreateItem(COLOR_WORD3, "^\w+(?=(\s*:?=))", True)
make.AddItem(iVarName)

'target
Set iTarget = make.CreateItem(COLOR_WORD2, "^(\w|\$\(([^()]|(?R))*\)|%.\w)+:(?!=)", True)
make.AddItem(iTarget)

'variable reference
Set iVarRef = make.CreateItem(COLOR_WORD3, "\$\(([^()]|(?R))*\)", True)
make.AddItem(iVarRef)

'preprogress
Set rRrePrg = make.CreateRegion(COLOR_WORD4, "+!+", "\b", True)
make.AddRegion(rRrePrg)

'pattern
Set iOther = make.CreateItem(COLOR_STRING1, "[*%]{1}\.[a-z]+|(\.[a-z]+){2}", True)
make.AddItem(iOther)

'automatic variable
Set iAutoVar = make.CreateItem(COLOR_WORD3, "\$\@|\$\<|\$\?|\$\^|\$\+|\$\%|\$\*", True)
make.AddItem(iAutoVar)

'comment
Set rLineComment = make.CreateRegion(COLOR_COMMENT1, "+#+", "$", True)
make.AddRegion(rLineComment)

'Reserved words
make.AddWord(make.CreateWord(COLOR_WORD1, "define endif ifdef ifndef ifeq ifneq echo else endif include -include sinclude override endef export unexport vpath", True))

'builtin function
make.AddWord(make.CreateWord(COLOR_FUNCTION, "addprefix addsuffix basename call dir error eval filter filter-out findstring firstword foreach if join notdir origin patsubst shell sort strip subst suffix value warning wildcard word words wordlist ", True))

'environment variable
Set iEnVar = make.CreateWord(COLOR_FUNCTION, "MAKEFILES MAKEFILES_LIST VPATH SHELL MAKESHELL MAKE MAKELEVEL MAKEFLAGS MAKECMDGOALS CURDIR SUFFIXES LIBPATTERNS PHONY", True)
make.AddWord(iEnVar)

'number
make.AddItem(make.CreateItem(COLOR_NUMBER, "\b\d+\b", False))

'single quote string
Set rString1 = make.CreateStringRegion(COLOR_STRING1, "'", "\", False)
make.AddRegion(rString1)

Set rString2 = make.CreateStringRegion(COLOR_STRING2, """", "\", False)
make.AddRegion(rString2)

make.FoldingMethod="indent"
make.SetPairs "(){}[]""""''"
make.CommentLine "#"
make.IndentText ":$", False
make.AddCallTip "cmake.ecp", False, "", " (", " ", ")"
