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