'*******************************************************************************
' EverEdit Syntax File
' Language:    grub
' Maintainer:  mdyblog.blog.163.com 
' History:
'   2014/01/20 Created
'*******************************************************************************
Include( ".\const.mac" )

Set grub=CreateParser()
grub.WordChars="_"

'comment
Set rLineComment=grub.CreateRegion( COLOR_COMMENT1, "+#+", "$", True )
'Set rBlockComment=grub.CreateRegion( COLOR_COMMENT2, "+/*+", "+*/+", True )
grub.AddRegion( rLineComment )
'grub.AddRegion( rBlockComment )

'add todo to comment
'Set iTodo=grub.CreateItem( COLOR_HIGHLIGHT2, "\b(TODO|FIX)\b", False )
'rLineComment.AddItem( iTodo )
'rBlockComment.AddItem( iTodo )

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

Set rString2=grub.CreateStringRegion( COLOR_STRING1, """", "\", False )
grub.AddRegion( rString2 )

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

'命令词
grub.AddWord( grub.CreateWord(COLOR_WORD1, "_bsd _chain _linux _multiboot acorn acpi adler32 affs afs ahci all_video amiga aout apple ata at_keyboard background background_image backtrace bfs biosdisk bitmap bitmap_scale blocklist boot bsd btrfs bufio calc call cat cdrom chain chainloader checkrange checktime clear cmp cmostest color command commandline configfile cpio cpio_be cpuid crc64 crypto cryptodisk cs5536 date datehook datetime dd debug default delmod diskfilter displaymem dm_nv drivemap echo efiemu efi_gop efi_uga ehci elf errnum errorcheck exfat exfctest ext2 extcmd fat find font fontfile foreground freedos fshelp fstest functional_test gcry_arcfour gcry_blowfish gcry_camellia gcry_cast5 gcry_crc gcry_des gcry_md4 gcry_md5 gcry_rfc2268 gcry_rijndael gcry_rmd160 gcry_seed gcry_serpent gcry_sha1 gcry_sha256 gcry_sha512 gcry_tiger gcry_twofish gcry_whirlpool gdb geli gettext geometry gfxmenu gfxmode gfxterm gpt gptsync graphicsmode gzio halt hashsum hdparm hello help hexdump hfs hfsplus hide hiddenflag hiddenmenu http initrd initrd16 insmod iorw is64bit iso9660 jfs jpeg kernel keylayouts keystatus ldm legacycfg linux linux16 loadfont loadenv lock loopback ls lsacpi lsapm lsmmap lsmod lspci lsusb luks lvm lzopio makeactive map md5crypt mdraid09 mdraid09_be mdraid1x memdisk memrw module modulenounzip minicmd minix minix2 minix2_be minix3 minix3_be minix_be mmap msdospart multiboot multiboot2 net newc nilfs2 normal ntfs ntfscomp ntldr odc ohci outline pager parttool part_acorn part_amiga part_apple part_bsd part_dvh part_gpt part_msdos part_plan part_sun part_sunpc password_pbkdf2 pata partnew parttype password pause pbkdf2 plan9 priority_queue probe pxe pxechain pc pci play png quit raid raid5rec raid6rec read regexp reboot reiserfs relocator romfs root rootnoverify savedefault scsi search search_fs_file search_fs_uuid search_label sendkey serial setjmp setkey setpci setvbe sfs shift sleep source splashimage squash4 submenu tar terminal terminal_output terminfo test test_blockarg testload testvbe tftp tga time timeout tpm trig true udf ufs ufs1 ufs2 uhci unhide usb usbms usbserial_common usbserial_ftdi usbserial_pl2303 usbtest usb_keyboard uuid vbe vbeinfo vbeprobe vbetest vga vga_text video videoinfo videotest video_bochs video_cirrus video_fb write xfs xnu xnu_uuid xzio zfs zfscrypt zfsinfo", True ) )

'语法结构词
grub.AddWord( grub.CreateWord(COLOR_WORD2, "$ &&  break case  continue elif else endlocal esac exist exit export fallback fi for goto if iftitle in menuentry return set setlocal then title unalias unset while { || }", True ) )

'系统变量
grub.AddWord( grub.CreateWord(COLOR_WORD3, "auto bootmgr border black blue brown color_normal color_highlight cyan dark-gray green hd0 hd1 hd2 hd3 hd4 highlight lang light-blue light-cyan light-gray light-green light-magenta light-red locale_dir magenta menu_color_normal menu_color_highlight off on red prefix white yellow zh_cn zh_CN", True ) )


'常用特别开关
grub.AddWord( grub.CreateWord(COLOR_WORD4, "harddisk iso raw --a20-keep-on --active --add-io-ports --all --bypass --boot-cs --boot-ip --chkpass --clear --config-file --device --devices --disable-a20 --disable-chs-mode --disable-lba-mode --dumb --ebx --edx --fake-write --file --floppies --force --force-sci --harddrives --heads --hex --hook --hotkey --hot-key --ignore-floppies --ignore-cd --init --int13-scheme --keep-pxe --length --lines --load-offset --load-length --load-segment --locate --locatei --locate-align --md5 --mem --memdisk-raw --no-apm --no-acpi --no-echo --no-edit --no-mem-option --number --offset --parity --port --ram-drive --rd-base --rd-size --read-only --rehook --replace --safe-mbr-hook --sdi --set --sectors-per-track --set-path --set-root --silent --sikp --skip-length --speed --status --stop --test-key --timeout --time-out --top --tune --type --unhook --unit --unmap --unsafe-boot --wait --word", True ) )

'operators
grub.AddItem( grub.CreateItem(COLOR_OPERATOR, "[\{\}\(\)\+\*\\=%&\^!~\|<>?\.,:;\/\[\]\$]",False ) )
Set rError=grub.CreateRegion( COLOR_COMMENT1, "#\s*error\b", "$", True )
grub.AddRegion( rError )

'include
'Set iInclude1=grub.CreateItem( COLOR_MACRO, "#\s*include\s*(<.*?>)", False )
'iInclude1.Capture 1, COLOR_STRING2
'Set iInclude2=grub.CreateItem( COLOR_MACRO, "#\s*include\s*(?="")", False )
'iInclude2.Capture 1, COLOR_STRING2

grub.AddItem( iInclude1 )
grub.AddItem( iInclude2 )

'macro
'grub.AddItem( grub.CreateItem(COLOR_MACRO, "#\s*if\s+!?defined",False ) )

'grub.AddItem( grub.CreateItem(COLOR_MACRO, "#\s*(if|pragma|else|elif|error|ifndef|define|endif|undef|ifdef)\b", False ) )
'number
grub.AddItem( grub.CreateItem(COLOR_NUMBER, "\b([0-9]+\.?[0-9]*|0x[0-9a-fA-F]+)\b", False) )


'grub.AddSnippet "c.snippet"
grub.FoldText "\{", False, "\}", False
grub.IndentText "(\[|{|\w+:)$", False, "^\s*}|\]$", False

grub.CommentLine("#)

grub.SetPairs( "[]{}()""""''" )
