Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Expect |
| 3 | " Maintainer: Ralph Jennings <knowbudy@oro.net> |
| 4 | " Last Change: 2001 May 09 |
| 5 | |
| 6 | " For version 5.x: Clear all syntax items |
| 7 | " For version 6.x: Quit when a syntax file was already loaded |
| 8 | if version < 600 |
| 9 | syntax clear |
| 10 | elseif exists("b:current_syntax") |
| 11 | finish |
| 12 | endif |
| 13 | |
| 14 | " Reserved Expect variable prefixes. |
| 15 | syn match expectVariables "\$exp[a-zA-Z0-9_]*\|\$inter[a-zA-Z0-9_]*" |
| 16 | syn match expectVariables "\$spawn[a-zA-Z0-9_]*\|\$timeout[a-zA-Z0-9_]*" |
| 17 | |
| 18 | " Normal Expect variables. |
| 19 | syn match expectVariables "\$env([^)]*)" |
| 20 | syn match expectVariables "\$any_spawn_id\|\$argc\|\$argv\d*" |
| 21 | syn match expectVariables "\$user_spawn_id\|\$spawn_id\|\$timeout" |
| 22 | |
| 23 | " Expect variable arrays. |
| 24 | syn match expectVariables "\$\(expect\|interact\)_out([^)]*)" contains=expectOutVar |
| 25 | |
| 26 | " User defined variables. |
| 27 | syn match expectVariables "\$[a-zA-Z_][a-zA-Z0-9_]*" |
| 28 | |
| 29 | " Reserved Expect command prefixes. |
| 30 | syn match expectCommand "exp_[a-zA-Z0-9_]*" |
| 31 | |
| 32 | " Normal Expect commands. |
| 33 | syn keyword expectStatement close debug disconnect |
| 34 | syn keyword expectStatement exit exp_continue exp_internal exp_open |
| 35 | syn keyword expectStatement exp_pid exp_version |
| 36 | syn keyword expectStatement fork inter_return interpreter |
| 37 | syn keyword expectStatement log_file log_user match_max overlay |
| 38 | syn keyword expectStatement parity remove_nulls return |
| 39 | syn keyword expectStatement send send_error send_log send_user |
| 40 | syn keyword expectStatement sleep spawn strace stty system |
| 41 | syn keyword expectStatement timestamp trace trap wait |
| 42 | |
| 43 | " Tcl commands recognized and used by Expect. |
| 44 | syn keyword expectCommand proc |
| 45 | syn keyword expectConditional if else |
| 46 | syn keyword expectRepeat while for foreach |
| 47 | |
| 48 | " Expect commands with special arguments. |
| 49 | syn keyword expectStatement expect expect_after expect_background nextgroup=expectExpectOpts |
| 50 | syn keyword expectStatement expect_before expect_user interact nextgroup=expectExpectOpts |
| 51 | |
| 52 | syn match expectSpecial contained "\\." |
| 53 | |
| 54 | " Options for "expect", "expect_after", "expect_background", |
| 55 | " "expect_before", "expect_user", and "interact". |
| 56 | syn keyword expectExpectOpts default eof full_buffer null return timeout |
| 57 | |
| 58 | syn keyword expectOutVar contained spawn_id seconds seconds_total |
| 59 | syn keyword expectOutVar contained string start end buffer |
| 60 | |
| 61 | " Numbers (Tcl style). |
| 62 | syn case ignore |
| 63 | syn match expectNumber "\<\d\+\(u\=l\=\|lu\|f\)\>" |
| 64 | "floating point number, with dot, optional exponent |
| 65 | syn match expectNumber "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>" |
| 66 | "floating point number, starting with a dot, optional exponent |
| 67 | syn match expectNumber "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" |
| 68 | "floating point number, without dot, with exponent |
| 69 | syn match expectNumber "\<\d\+e[-+]\=\d\+[fl]\=\>" |
| 70 | "hex number |
| 71 | syn match expectNumber "0x[0-9a-f]\+\(u\=l\=\|lu\)\>" |
| 72 | "syn match expectIdentifier "\<[a-z_][a-z0-9_]*\>" |
| 73 | syn case match |
| 74 | |
| 75 | syn region expectString start=+"+ end=+"+ contains=expectVariables,expectSpecial |
| 76 | |
| 77 | " Are these really comments in Expect? (I never use it, so I'm just guessing). |
| 78 | syn keyword expectTodo contained TODO |
| 79 | syn match expectComment "#.*$" contains=expectTodo |
| 80 | |
| 81 | " Define the default highlighting. |
| 82 | " For version 5.7 and earlier: only when not done already |
| 83 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 84 | if version >= 508 || !exists("did_expect_syntax_inits") |
| 85 | if version < 508 |
| 86 | let did_expect_syntax_inits = 1 |
| 87 | command -nargs=+ HiLink hi link <args> |
| 88 | else |
| 89 | command -nargs=+ HiLink hi def link <args> |
| 90 | endif |
| 91 | |
| 92 | HiLink expectVariables Special |
| 93 | HiLink expectCommand Function |
| 94 | HiLink expectStatement Statement |
| 95 | HiLink expectConditional Conditional |
| 96 | HiLink expectRepeat Repeat |
| 97 | HiLink expectExpectOpts Keyword |
| 98 | HiLink expectOutVar Special |
| 99 | HiLink expectSpecial Special |
| 100 | HiLink expectNumber Number |
| 101 | |
| 102 | HiLink expectString String |
| 103 | |
| 104 | HiLink expectComment Comment |
| 105 | HiLink expectTodo Todo |
| 106 | "HiLink expectIdentifier Identifier |
| 107 | |
| 108 | delcommand HiLink |
| 109 | endif |
| 110 | |
| 111 | let b:current_syntax = "expect" |
| 112 | |
| 113 | " vim: ts=8 |