blob: 1886e2b3e34b7b4fa6249dd534083063a75c8658 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" 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
8if version < 600
9 syntax clear
10elseif exists("b:current_syntax")
11 finish
12endif
13
14" Reserved Expect variable prefixes.
15syn match expectVariables "\$exp[a-zA-Z0-9_]*\|\$inter[a-zA-Z0-9_]*"
16syn match expectVariables "\$spawn[a-zA-Z0-9_]*\|\$timeout[a-zA-Z0-9_]*"
17
18" Normal Expect variables.
19syn match expectVariables "\$env([^)]*)"
20syn match expectVariables "\$any_spawn_id\|\$argc\|\$argv\d*"
21syn match expectVariables "\$user_spawn_id\|\$spawn_id\|\$timeout"
22
23" Expect variable arrays.
24syn match expectVariables "\$\(expect\|interact\)_out([^)]*)" contains=expectOutVar
25
26" User defined variables.
27syn match expectVariables "\$[a-zA-Z_][a-zA-Z0-9_]*"
28
29" Reserved Expect command prefixes.
30syn match expectCommand "exp_[a-zA-Z0-9_]*"
31
32" Normal Expect commands.
33syn keyword expectStatement close debug disconnect
34syn keyword expectStatement exit exp_continue exp_internal exp_open
35syn keyword expectStatement exp_pid exp_version
36syn keyword expectStatement fork inter_return interpreter
37syn keyword expectStatement log_file log_user match_max overlay
38syn keyword expectStatement parity remove_nulls return
39syn keyword expectStatement send send_error send_log send_user
40syn keyword expectStatement sleep spawn strace stty system
41syn keyword expectStatement timestamp trace trap wait
42
43" Tcl commands recognized and used by Expect.
44syn keyword expectCommand proc
45syn keyword expectConditional if else
46syn keyword expectRepeat while for foreach
47
48" Expect commands with special arguments.
49syn keyword expectStatement expect expect_after expect_background nextgroup=expectExpectOpts
50syn keyword expectStatement expect_before expect_user interact nextgroup=expectExpectOpts
51
52syn match expectSpecial contained "\\."
53
54" Options for "expect", "expect_after", "expect_background",
55" "expect_before", "expect_user", and "interact".
56syn keyword expectExpectOpts default eof full_buffer null return timeout
57
58syn keyword expectOutVar contained spawn_id seconds seconds_total
59syn keyword expectOutVar contained string start end buffer
60
61" Numbers (Tcl style).
62syn 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_]*\>"
73syn case match
74
75syn region expectString start=+"+ end=+"+ contains=expectVariables,expectSpecial
76
77" Are these really comments in Expect? (I never use it, so I'm just guessing).
78syn keyword expectTodo contained TODO
79syn 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
84if 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
109endif
110
111let b:current_syntax = "expect"
112
113" vim: ts=8