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