'*******************************************************************************
' EverEdit Syntax File
' Author:		Morler <morler@163.com>
' Language:		OpenEuphoria v4.0.5
' Maintainer:	moofly.net/blog  
' History:
'   2012/07/19	First Version
'	2013/04/20	updated
'	2013/04/24	updating (un)fold and (un)indent texts methods
'			support more numbers formats(like '0b111 0t456 0xAB4')
'	2013/04/27	支持更多数字格式，完善字符串格式
'   2013/05/13  完善缩进语法
'*******************************************************************************

Include( ".\const.mac" )

Set euphoria=CreateParser()

'定义行注释
Set LineComment=euphoria.CreateRegion(COLOR_COMMENT1, "+--+", "$", True)

'定义块注释
Set BlockComment=euphoria.CreateRegion(COLOR_COMMENT1, "+/*+", "+*/+", True)

'标明文本字符串
Set regionString1=euphoria.CreateStringRegion( COLOR_STRING1, """", "\", False )
Set regionString2=euphoria.CreateStringRegion( COLOR_STRING1, "''", "\", False )

'Raw strings
euphoria.AddRegion( euphoria.CreateRegion( COLOR_STRING1, "+`+", "+`+", False ) )
euphoria.AddRegion( euphoria.CreateRegion( COLOR_STRING1, "(?<!\\)[""]{3}", "(?<!\\)[""]{3}", False ) )


'binary & hexadecimal strings
euphoria.AddRegion( euphoria.CreateRegion(COLOR_STRING1, "[bx]""", """", True) )

'operators
euphoria.AddItem( euphoria.CreateItem(COLOR_OPERATOR, "[\{\}\(\)\+\-\*\\=%&\^!~\|<>?\.,:;\/\[\]\$]",False ) )

'function
euphoria.AddItem( euphoria.CreateItem(COLOR_FUNCTION, "[\w_][\w\d_]*(?=\()", False) )

'Keywords
Set eu_words2=euphoria.CreateWord( COLOR_WORD1, "and as break by case constant continue do else elsdef elsif elsifdef end entry enum exit export fallthru for function global goto if ifdef elsedef include label loop namespace not or override procedure public retry return routine switch then to type until while with without xor", False, "" )

'Fuctions
Set eu_words3=euphoria.CreateWord( COLOR_WORD2, "? abort and_bits append arctan atom c_func c_proc call call_func call_proc clear_screen close command_line compare cos date delete delete_routine equal find find_from floor get_key get_pixel getc getenv gets hash head include_paths insert integer length log machine_func machine_proc match match_from mem_copy mem_set not_bits object open option_switches or_bits peek peek2s peek2u peek4s peek4u peek_string peeks pixel platform poke poke2 poke4 position power prepend print printf profile profile_time puts rand remainder remove repeat replace routine_id sequence sin splice sprintf sqrt system system_exec tail tan task_clock_start task_clock_stop task_create task_list task_schedule task_self task_status task_suspend task_yield time trace warning xor_bits", False, "-?" )

'Numbers
Set eu_words4=euphoria.CreateItem( COLOR_NUMBER, "(?<!\w)[+-]?([0-9_]+\.?[0-9_]*|0(b[01_]+|t[0-7_]+|d[0-9_]+|x[0-9A-Fa-f_]+)|[0-9_]+e-?[0-9_]+|#[0-9A-Fa-f_]+)(?!\w)", False )

'Constants
euphoria.AddItem( euphoria.CreateItem(COLOR_NUMBER, "\b[A-Z_][A-Z0-9_]*\b",True ) )


'TODO\BUG\FIX\DONE注释格式支持
Set todo=euphoria.CreateItem(COLOR_COMMENT1, "^\-\-(todo|bug|fix|done)\s*(.+)$", False)
todo.Capture 1, COLOR_WORD2
todo.Capture 2, COLOR_WORD3

'括号匹配
Call euphoria.SetPairs("[](){}""""''")

'快捷键行注释
Call euphoria.CommentLine("--")

'代码折叠
Call euphoria.FoldText( "^\s*(global\s*)?(if|for|switch|while|loop|ifdef|function|procedure|type)\s", False )
Call euphoria.UnfoldText( "^\s*end\s(?!=)", False )

'代码自动缩进
Call euphoria.IndentText( "(\s(do|then)|^\s*((else|entry)|(function|procedure|type)\s.+))$", False )
Call euphoria.UnindentText( "^\s*(end\s|else)", False )

'
'创建的匹配加入主区域
euphoria.AddRegion(LineComment)
euphoria.AddRegion(BlockComment)
euphoria.AddRegion(regionString1)
euphoria.AddRegion(regionString2)
euphoria.AddWord(eu_words2)
euphoria.AddWord(eu_words3)
euphoria.AddWord(eu_words4)
LineComment.AddItem(todo)
