annotate runtime/syntax/cweb.vim @ 8996:d25ba6b80388

Added tag v7.4.1783 for changeset 3cf6704d6efc8d1c2b3b6a1e145037fefa0f1f4f
author Christian Brabandt <cb@256bit.org>
date Sun, 24 Apr 2016 14:45:05 +0200
parents 91e53bcb7946
children 43efa4f5a8ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: CWEB
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Andreas Scherer <andreas.scherer@pobox.com>
3237
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
4 " Last Change: 2011 Dec 25 by Thilo Six
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Details of the CWEB language can be found in the article by Donald E. Knuth
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " and Silvio Levy, "The CWEB System of Structured Documentation", included as
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " file "cwebman.tex" in the standard CWEB distribution, available for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " anonymous ftp at ftp://labrea.stanford.edu/pub/cweb/.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 " TODO: Section names and C/C++ comments should be treated as TeX material.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " TODO: The current version switches syntax highlighting off for section
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " TODO: names, and leaves C/C++ comments as such. (On the other hand,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 " TODO: switching to TeX mode in C/C++ comments might be colour overkill.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 " For version 5.x: Clear all syntax items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 " For version 6.x: Quit when a syntax file was already loaded
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 syntax clear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 elseif exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " For starters, read the TeX syntax; TeX syntax items are allowed at the top
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 " level in the CWEB syntax, e.g., in the preamble. In general, a CWEB source
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 " code can be seen as a normal TeX document with some C/C++ material
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 " interspersed in certain defined regions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 source <sfile>:p:h/tex.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 runtime! syntax/tex.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 unlet b:current_syntax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 " Read the C/C++ syntax too; C/C++ syntax items are treated as such in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 " C/C++ section of a CWEB chunk or in inner C/C++ context in "|...|" groups.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 syntax include @webIncludedC <sfile>:p:h/cpp.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3237
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
39 let s:cpo_save = &cpo
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
40 set cpo&vim
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
41
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 " Inner C/C++ context (ICC) should be quite simple as it's comprised of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 " material in "|...|"; however the naive definition for this region would
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 " hickup at the innocious "\|" TeX macro. Note: For the time being we expect
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 " that an ICC begins either at the start of a line or after some white space.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 syntax region webInnerCcontext start="\(^\|[ \t\~`(]\)|" end="|" contains=@webIncludedC,webSectionName,webRestrictedTeX,webIgnoredStuff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 " Genuine C/C++ material. This syntactic region covers both the definition
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 " part and the C/C++ part of a CWEB section; it is ended by the TeX part of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 " the next section.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 syntax region webCpart start="@[dfscp<(]" end="@[ \*]" contains=@webIncludedC,webSectionName,webRestrictedTeX,webIgnoredStuff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 " Section names contain C/C++ material only in inner context.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 syntax region webSectionName start="@[<(]" end="@>" contains=webInnerCcontext contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " The contents of "control texts" is not treated as TeX material, because in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 " non-trivial cases this completely clobbers the syntax recognition. Instead,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " we highlight these elements as "strings".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 syntax region webRestrictedTeX start="@[\^\.:t=q]" end="@>" oneline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 " Double-@ means single-@, anywhere in the CWEB source. (This allows e-mail
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 " address <someone@@fsf.org> without going into C/C++ mode.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 syntax match webIgnoredStuff "@@"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 " Define the default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 " For version 5.7 and earlier: only when not done already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 " For version 5.8 and later: only when an item doesn't have highlighting yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 if version >= 508 || !exists("did_cweb_syntax_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 if version < 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 let did_cweb_syntax_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 HiLink webRestrictedTeX String
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 let b:current_syntax = "cweb"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82
3237
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
83 let &cpo = s:cpo_save
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
84 unlet s:cpo_save
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 " vim: ts=8