xref: /vim-8.2.3635/runtime/syntax/spup.vim (revision cb03397a)
1" Vim syntax file
2" Language:     Speedup, plant simulator from AspenTech
3" Maintainer:   Stefan.Schwarzer <[email protected]>
4" URL:		http://www.ndh.net/home/sschwarzer/download/spup.vim
5" Last Change:  2012 Feb 03 by Thilo Six
6" Filename:     spup.vim
7
8" Bugs
9" - in the appropriate sections keywords are always highlighted
10"   even if they are not used with the appropriate meaning;
11"   example: in
12"       MODEL demonstration
13"       TYPE
14"      *area AS area
15"   both "area" are highlighted as spupType.
16"
17" If you encounter problems or have questions or suggestions, mail me
18
19" Remove old syntax stuff
20" For version 5.x: Clear all syntax items
21" For version 6.x: Quit when a syntax file was already loaded
22if version < 600
23    syntax clear
24elseif exists("b:current_syntax")
25    finish
26endif
27
28let s:cpo_save = &cpo
29set cpo&vim
30
31" don't hightlight several keywords like subsections
32"let strict_subsections = 1
33
34" highlight types usually found in DECLARE section
35if !exists("hightlight_types")
36    let highlight_types = 1
37endif
38
39" one line comment syntax (# comments)
40" 1. allow appended code after comment, do not complain
41" 2. show code beginnig with the second # as an error
42" 3. show whole lines with more than one # as an error
43if !exists("oneline_comments")
44    let oneline_comments = 2
45endif
46
47" Speedup SECTION regions
48syn case ignore
49syn region spupCdi	  matchgroup=spupSection start="^CDI"	     end="^\*\*\*\*" contains=spupCdiSubs,@spupOrdinary
50syn region spupConditions matchgroup=spupSection start="^CONDITIONS" end="^\*\*\*\*" contains=spupConditionsSubs,@spupOrdinary,spupConditional,spupOperator,spupCode
51syn region spupDeclare    matchgroup=spupSection start="^DECLARE"    end="^\*\*\*\*" contains=spupDeclareSubs,@spupOrdinary,spupTypes,spupCode
52syn region spupEstimation matchgroup=spupSection start="^ESTIMATION" end="^\*\*\*\*" contains=spupEstimationSubs,@spupOrdinary
53syn region spupExternal   matchgroup=spupSection start="^EXTERNAL"   end="^\*\*\*\*" contains=spupExternalSubs,@spupOrdinary
54syn region spupFlowsheet  matchgroup=spupSection start="^FLOWSHEET"  end="^\*\*\*\*" contains=spupFlowsheetSubs,@spupOrdinary,spupStreams,@spupTextproc
55syn region spupFunction   matchgroup=spupSection start="^FUNCTION"   end="^\*\*\*\*" contains=spupFunctionSubs,@spupOrdinary,spupHelp,spupCode,spupTypes
56syn region spupGlobal     matchgroup=spupSection start="^GLOBAL"     end="^\*\*\*\*" contains=spupGlobalSubs,@spupOrdinary
57syn region spupHomotopy   matchgroup=spupSection start="^HOMOTOPY"   end="^\*\*\*\*" contains=spupHomotopySubs,@spupOrdinary
58syn region spupMacro      matchgroup=spupSection start="^MACRO"      end="^\*\*\*\*" contains=spupMacroSubs,@spupOrdinary,@spupTextproc,spupTypes,spupStreams,spupOperator
59syn region spupModel      matchgroup=spupSection start="^MODEL"      end="^\*\*\*\*" contains=spupModelSubs,@spupOrdinary,spupConditional,spupOperator,spupTypes,spupStreams,@spupTextproc,spupHelp
60syn region spupOperation  matchgroup=spupSection start="^OPERATION"  end="^\*\*\*\*" contains=spupOperationSubs,@spupOrdinary,@spupTextproc
61syn region spupOptions    matchgroup=spupSection start="^OPTIONS"    end="^\*\*\*\*" contains=spupOptionsSubs,@spupOrdinary
62syn region spupProcedure  matchgroup=spupSection start="^PROCEDURE"  end="^\*\*\*\*" contains=spupProcedureSubs,@spupOrdinary,spupHelp,spupCode,spupTypes
63syn region spupProfiles   matchgroup=spupSection start="^PROFILES"   end="^\*\*\*\*" contains=@spupOrdinary,@spupTextproc
64syn region spupReport     matchgroup=spupSection start="^REPORT"     end="^\*\*\*\*" contains=spupReportSubs,@spupOrdinary,spupHelp,@spupTextproc
65syn region spupTitle      matchgroup=spupSection start="^TITLE"      end="^\*\*\*\*" contains=spupTitleSubs,spupComment,spupConstant,spupError
66syn region spupUnit       matchgroup=spupSection start="^UNIT"       end="^\*\*\*\*" contains=spupUnitSubs,@spupOrdinary
67
68" Subsections
69syn keyword spupCdiSubs	       INPUT FREE OUTPUT LINEARTIME MINNONZERO CALCULATE FILES SCALING contained
70syn keyword spupDeclareSubs    TYPE STREAM contained
71syn keyword spupEstimationSubs ESTIMATE SSEXP DYNEXP RESULT contained
72syn keyword spupExternalSubs   TRANSMIT RECEIVE contained
73syn keyword spupFlowsheetSubs  STREAM contained
74syn keyword spupFunctionSubs   INPUT OUTPUT contained
75syn keyword spupGlobalSubs     VARIABLES MAXIMIZE MINIMIZE CONSTRAINT contained
76syn keyword spupHomotopySubs   VARY OPTIONS contained
77syn keyword spupMacroSubs      MODEL FLOWSHEET contained
78syn keyword spupModelSubs      CATEGORY SET TYPE STREAM EQUATION PROCEDURE contained
79syn keyword spupOperationSubs  SET PRESET INITIAL SSTATE FREE contained
80syn keyword spupOptionsSubs    ROUTINES TRANSLATE EXECUTION contained
81syn keyword spupProcedureSubs  INPUT OUTPUT SPACE PRECALL POSTCALL DERIVATIVE STREAM contained
82" no subsections for Profiles
83syn keyword spupReportSubs     SET INITIAL FIELDS FIELDMARK DISPLAY WITHIN contained
84syn keyword spupUnitSubs       ROUTINES SET contained
85
86" additional keywords for subsections
87if !exists( "strict_subsections" )
88    syn keyword spupConditionsSubs STOP PRINT contained
89    syn keyword spupDeclareSubs    UNIT SET COMPONENTS THERMO OPTIONS contained
90    syn keyword spupEstimationSubs VARY MEASURE INITIAL contained
91    syn keyword spupFlowsheetSubs  TYPE FEED PRODUCT INPUT OUTPUT CONNECTION OF IS contained
92    syn keyword spupMacroSubs      CONNECTION STREAM SET INPUT OUTPUT OF IS FEED PRODUCT TYPE contained
93    syn keyword spupModelSubs      AS ARRAY OF INPUT OUTPUT CONNECTION contained
94    syn keyword spupOperationSubs  WITHIN contained
95    syn keyword spupReportSubs     LEFT RIGHT CENTER CENTRE UOM TIME DATE VERSION RELDATE contained
96    syn keyword spupUnitSubs       IS A contained
97endif
98
99" Speedup data types
100if exists( "highlight_types" )
101    syn keyword spupTypes act_coeff_liq area coefficient concentration contained
102    syn keyword spupTypes control_signal cond_liq cond_vap cp_mass_liq contained
103    syn keyword spupTypes cp_mol_liq cp_mol_vap cv_mol_liq cv_mol_vap contained
104    syn keyword spupTypes diffus_liq diffus_vap delta_p dens_mass contained
105    syn keyword spupTypes dens_mass_sol dens_mass_liq dens_mass_vap dens_mol contained
106    syn keyword spupTypes dens_mol_sol dens_mol_liq dens_mol_vap enthflow contained
107    syn keyword spupTypes enth_mass enth_mass_liq enth_mass_vap enth_mol contained
108    syn keyword spupTypes enth_mol_sol enth_mol_liq enth_mol_vap entr_mol contained
109    syn keyword spupTypes entr_mol_sol entr_mol_liq entr_mol_vap fraction contained
110    syn keyword spupTypes flow_mass flow_mass_liq flow_mass_vap flow_mol contained
111    syn keyword spupTypes flow_mol_vap flow_mol_liq flow_vol flow_vol_vap contained
112    syn keyword spupTypes flow_vol_liq fuga_vap fuga_liq fuga_sol contained
113    syn keyword spupTypes gibb_mol_sol heat_react heat_trans_coeff contained
114    syn keyword spupTypes holdup_heat holdup_heat_liq holdup_heat_vap contained
115    syn keyword spupTypes holdup_mass holdup_mass_liq holdup_mass_vap contained
116    syn keyword spupTypes holdup_mol holdup_mol_liq holdup_mol_vap k_value contained
117    syn keyword spupTypes length length_delta length_short liqfraction contained
118    syn keyword spupTypes liqmassfraction mass massfraction molefraction contained
119    syn keyword spupTypes molweight moment_inertia negative notype percent contained
120    syn keyword spupTypes positive pressure press_diff press_drop press_rise contained
121    syn keyword spupTypes ratio reaction reaction_mass rotation surf_tens contained
122    syn keyword spupTypes temperature temperature_abs temp_diff temp_drop contained
123    syn keyword spupTypes temp_rise time vapfraction vapmassfraction contained
124    syn keyword spupTypes velocity visc_liq visc_vap volume zmom_rate contained
125    syn keyword spupTypes seg_rate smom_rate tmom_rate zmom_mass seg_mass contained
126    syn keyword spupTypes smom_mass tmom_mass zmom_holdup seg_holdup contained
127    syn keyword spupTypes smom_holdup tmom_holdup contained
128endif
129
130" stream types
131syn keyword spupStreams  mainstream vapour liquid contained
132
133" "conditional" keywords
134syn keyword spupConditional  IF THEN ELSE ENDIF contained
135" Operators, symbols etc.
136syn keyword spupOperator  AND OR NOT contained
137syn match spupSymbol  "[,\-+=:;*/\"<>@%()]" contained
138syn match spupSpecial  "[&\$?]" contained
139" Surprisingly, Speedup allows no unary + instead of the -
140syn match spupError  "[(=+\-*/]\s*+\d\+\([ed][+-]\=\d\+\)\=\>"lc=1 contained
141syn match spupError  "[(=+\-*/]\s*+\d\+\.\([ed][+-]\=\d\+\)\=\>"lc=1 contained
142syn match spupError  "[(=+\-*/]\s*+\d*\.\d\+\([ed][+-]\=\d\+\)\=\>"lc=1 contained
143" String
144syn region spupString  start=+"+  end=+"+  oneline contained
145syn region spupString  start=+'+  end=+'+  oneline contained
146" Identifier
147syn match spupIdentifier  "\<[a-z][a-z0-9_]*\>" contained
148" Textprocessor directives
149syn match spupTextprocGeneric  "?[a-z][a-z0-9_]*\>" contained
150syn region spupTextprocError matchgroup=spupTextprocGeneric start="?ERROR"  end="?END"he=s-1 contained
151" Number, without decimal point
152syn match spupNumber  "-\=\d\+\([ed][+-]\=\d\+\)\=" contained
153" Number, allows 1. before exponent
154syn match spupNumber  "-\=\d\+\.\([ed][+-]\=\d\+\)\=" contained
155" Number allows .1 before exponent
156syn match spupNumber  "-\=\d*\.\d\+\([ed][+-]\=\d\+\)\=" contained
157" Help subsections
158syn region spupHelp  start="^HELP"hs=e+1  end="^\$ENDHELP"he=s-1 contained
159" Fortran code
160syn region spupCode  start="^CODE"hs=e+1  end="^\$ENDCODE"he=s-1 contained
161" oneline comments
162if oneline_comments > 3
163    oneline_comments = 2   " default
164endif
165if oneline_comments == 1
166    syn match spupComment  "#[^#]*#\="
167elseif oneline_comments == 2
168    syn match spupError  "#.*$"
169    syn match spupComment  "#[^#]*"  nextgroup=spupError
170elseif oneline_comments == 3
171    syn match spupComment  "#[^#]*"
172    syn match spupError  "#[^#]*#.*"
173endif
174" multiline comments
175syn match spupOpenBrace "{" contained
176syn match spupError  "}"
177syn region spupComment  matchgroup=spupComment2  start="{"  end="}"  keepend  contains=spupOpenBrace
178
179syn cluster spupOrdinary  contains=spupNumber,spupIdentifier,spupSymbol
180syn cluster spupOrdinary  add=spupError,spupString,spupComment
181syn cluster spupTextproc  contains=spupTextprocGeneric,spupTextprocError
182
183" define syncronizing; especially OPERATION sections can become very large
184syn sync clear
185syn sync minlines=100
186syn sync maxlines=500
187
188syn sync match spupSyncOperation  grouphere spupOperation  "^OPERATION"
189syn sync match spupSyncCdi	  grouphere spupCdi	   "^CDI"
190syn sync match spupSyncConditions grouphere spupConditions "^CONDITIONS"
191syn sync match spupSyncDeclare    grouphere spupDeclare    "^DECLARE"
192syn sync match spupSyncEstimation grouphere spupEstimation "^ESTIMATION"
193syn sync match spupSyncExternal   grouphere spupExternal   "^EXTERNAL"
194syn sync match spupSyncFlowsheet  grouphere spupFlowsheet  "^FLOWSHEET"
195syn sync match spupSyncFunction   grouphere spupFunction   "^FUNCTION"
196syn sync match spupSyncGlobal     grouphere spupGlobal     "^GLOBAL"
197syn sync match spupSyncHomotopy   grouphere spupHomotopy   "^HOMOTOPY"
198syn sync match spupSyncMacro      grouphere spupMacro      "^MACRO"
199syn sync match spupSyncModel      grouphere spupModel      "^MODEL"
200syn sync match spupSyncOperation  grouphere spupOperation  "^OPERATION"
201syn sync match spupSyncOptions    grouphere spupOptions    "^OPTIONS"
202syn sync match spupSyncProcedure  grouphere spupProcedure  "^PROCEDURE"
203syn sync match spupSyncProfiles   grouphere spupProfiles   "^PROFILES"
204syn sync match spupSyncReport     grouphere spupReport     "^REPORT"
205syn sync match spupSyncTitle      grouphere spupTitle      "^TITLE"
206syn sync match spupSyncUnit       grouphere spupUnit       "^UNIT"
207
208" Define the default highlighting.
209" For version 5.7 and earlier: only when not done already
210" For version 5.8 and later: only when an item doesn't have highlighting yet
211if version >= 508 || !exists("did_spup_syn_inits")
212    if version < 508
213	let did_spup_syn_inits = 1
214	command -nargs=+ HiLink hi link <args>
215    else
216	command -nargs=+ HiLink hi def link <args>
217    endif
218
219    HiLink spupCdi	    spupSection
220    HiLink spupConditions   spupSection
221    HiLink spupDeclare	    spupSection
222    HiLink spupEstimation   spupSection
223    HiLink spupExternal	    spupSection
224    HiLink spupFlowsheet    spupSection
225    HiLink spupFunction	    spupSection
226    HiLink spupGlobal	    spupSection
227    HiLink spupHomotopy	    spupSection
228    HiLink spupMacro	    spupSection
229    HiLink spupModel	    spupSection
230    HiLink spupOperation    spupSection
231    HiLink spupOptions	    spupSection
232    HiLink spupProcedure    spupSection
233    HiLink spupProfiles	    spupSection
234    HiLink spupReport	    spupSection
235    HiLink spupTitle	    spupConstant  " this is correct, truly ;)
236    HiLink spupUnit	    spupSection
237
238    HiLink spupCdiSubs	      spupSubs
239    HiLink spupConditionsSubs spupSubs
240    HiLink spupDeclareSubs    spupSubs
241    HiLink spupEstimationSubs spupSubs
242    HiLink spupExternalSubs   spupSubs
243    HiLink spupFlowsheetSubs  spupSubs
244    HiLink spupFunctionSubs   spupSubs
245    HiLink spupHomotopySubs   spupSubs
246    HiLink spupMacroSubs      spupSubs
247    HiLink spupModelSubs      spupSubs
248    HiLink spupOperationSubs  spupSubs
249    HiLink spupOptionsSubs    spupSubs
250    HiLink spupProcedureSubs  spupSubs
251    HiLink spupReportSubs     spupSubs
252    HiLink spupUnitSubs	      spupSubs
253
254    HiLink spupCode	       Normal
255    HiLink spupComment	       Comment
256    HiLink spupComment2	       spupComment
257    HiLink spupConditional     Statement
258    HiLink spupConstant	       Constant
259    HiLink spupError	       Error
260    HiLink spupHelp	       Normal
261    HiLink spupIdentifier      Identifier
262    HiLink spupNumber	       Constant
263    HiLink spupOperator	       Special
264    HiLink spupOpenBrace       spupError
265    HiLink spupSection	       Statement
266    HiLink spupSpecial	       spupTextprocGeneric
267    HiLink spupStreams	       Type
268    HiLink spupString	       Constant
269    HiLink spupSubs	       Statement
270    HiLink spupSymbol	       Special
271    HiLink spupTextprocError   Normal
272    HiLink spupTextprocGeneric PreProc
273    HiLink spupTypes	       Type
274
275    delcommand HiLink
276endif
277
278let b:current_syntax = "spup"
279
280let &cpo = s:cpo_save
281unlet s:cpo_save
282" vim:ts=8
283