blob: 75cbd3eddfe7bfda0375a94b06442276d7e5ee74 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Expect
3" Maintainer: Ralph Jennings <knowbudy@oro.net>
Bram Moolenaarc8734422012-06-01 22:38:45 +02004" Last Change: 2012 Jun 01
5" (Dominique Pelle added @Spell)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02007" quit when a syntax file was already loaded
8if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +00009 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
Bram Moolenaarc8734422012-06-01 22:38:45 +020073syn region expectString start=+"+ end=+"+ contains=@Spell,expectVariables,expectSpecial
Bram Moolenaar071d4272004-06-13 20:20:40 +000074
75" Are these really comments in Expect? (I never use it, so I'm just guessing).
76syn keyword expectTodo contained TODO
Bram Moolenaarc8734422012-06-01 22:38:45 +020077syn match expectComment "#.*$" contains=@Spell,expectTodo
78syn match expectSharpBang "\%^#!.*"
Bram Moolenaar071d4272004-06-13 20:20:40 +000079
80" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020081" Only when an item doesn't have highlighting yet
Bram Moolenaar071d4272004-06-13 20:20:40 +000082
Bram Moolenaarf37506f2016-08-31 22:22:10 +020083hi 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
Bram Moolenaar071d4272004-06-13 20:20:40 +000093
Bram Moolenaarf37506f2016-08-31 22:22:10 +020094hi def link expectString String
Bram Moolenaar071d4272004-06-13 20:20:40 +000095
Bram Moolenaarf37506f2016-08-31 22:22:10 +020096hi def link expectComment Comment
97hi def link expectTodo Todo
98"hi def link expectIdentifier Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +000099
Bram Moolenaar071d4272004-06-13 20:20:40 +0000100
101let b:current_syntax = "expect"
102
103" vim: ts=8