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