codekingpro/portable-devtools
114k
1" Vim syntax file2" Language: Kuka Robot Language3" Maintainer: Patrick Meiser-Knosowski <knosowski@graeffrobotics.de>4" Version: 3.1.05" Last Change: 13. Jan 20266" Credits: Thanks for contributions to this to Michael Jagusch7" Thanks for beta testing to Thomas Baginski8"9" Note to self:10" for testing perfomance11" open a 1000 lines file.12" :syntime on13" G14" hold down CTRL-U until reaching top15" :syntime report16 17" Init {{{18if exists("b:current_syntax")19 finish20endif21 22let s:keepcpo = &cpo23set cpo&vim24 25" if colorscheme is tortus(less)? krlGroupName defaults to 126if get(g:, 'colors_name', " ") =~ '\<tortus'27 \&& !exists("g:krlGroupName")28 let g:krlGroupName=1 29endif30" krlGroupName defaults to 0 if it's not initialized yet or 031if !get(g:, "krlGroupName", 0)32 let g:krlGroupName = 0 33endif34 35" krl does ignore case36syn case ignore37" take #, $ and & into keyword (syntax only)38syn iskeyword @,48-57,_,192-255,#,$,&39" spell checking40syn spell notoplevel41" }}} init42 43" Comment and Folding {{{ 44 45" Special Comment46 47" TODO Comment48syn keyword krlTodo contained TODO FIXME XXX49highlight default link krlTodo Todo50 51" Debug Comment52syn keyword krlDebug contained DEBUG53highlight default link krlDebug Debug54 55" Comment56" none move fold comment until second ;57syn match krlFoldComment /\c\v^\s*;\s*%(end)?fold>[^;]*/ containedin=krlFold contains=krlSingleQuoteString,krlInteger,krlFloat,krlMovement,krlDelimiter,krlBoolean58highlight default link krlFoldComment Comment59 60" move fold comment until second ;61syn match krlMoveFoldComment /\c\v^\s*;\s*fold>[^;]*<s?%(ptp|lin|circ?|spl)%(_rel)?>[^;]*/ containedin=krlFold contains=krlInteger,krlFloat,krlMovement,krlDelimiter62highlight default link krlMoveFoldComment Comment63 64" things to highlight in a fold line65syn keyword krlFoldHighlights CONT IN SYN OUT contained containedin=krlFoldComment66syn match krlFoldHighlights /\c\v<(M|F|E|A|t|i|bin|binin|UP|SPSMAKRO)\d+>/ contained containedin=krlFoldComment67if g:krlGroupName68 highlight default link krlFoldHighlights Sysvars69else70 " default color for Fold Highlights71endif72syn keyword krlVkrcFoldConstants EIN AUS containedin=krlFoldComment73highlight default link krlVkrcFoldConstants Boolean74 75" Comment without Fold, also includes endfold lines and fold line part after second ;76syn match krlComment /\c\v;\s*%(<%(end)?fold>)@!.*$/ containedin=krlFold contains=krlTodo,krlDebug,@Spell77" Commented out Fold line: "; ;FOLD PTP..."78syn match krlComment /\c\v^\s*;\s*;.*$/ contains=krlTodo,krlDebug79highlight default link krlComment Comment80 81if has("conceal") && get(g:, 'krlConcealFoldTail', 1)82 syn match krlConcealFoldTail /\c\v(^\s*;\s*fold[^;]*)@250<=;%(--|\s*<fold>|\s*<endfold>)@!.*$/ transparent containedin=krlComment conceal cchar=*83endif84" }}} Comment and Folding 85 86" Header {{{87syn match krlHeader /&\a\w*/88highlight default link krlHeader PreProc89" }}} Header90 91" Operator {{{92" Boolean operator93syn keyword krlBoolOperator and or exor not b_and b_or b_exor b_not94highlight default link krlBoolOperator Operator95" Arithmetic operator96syn match krlArithOperator /[+-]/ containedin=krlFloat97syn match krlArithOperator /[*/]/98highlight default link krlArithOperator Operator99" Compare operator100syn match krlCompOperator /[<>=]/101highlight default link krlCompOperator Operator102" Geometric operator103" Do not move the : operator104" Must be present befor krlParamdef105syn match krlGeomOperator /[:]/ 106" syn match krlGeomOperator /[:]/ containedin=krlLabel,krlParamdef107highlight default link krlGeomOperator Operator108" }}} Operator109 110" Type, StorageClass and Typedef {{{111" Simple data types112syn keyword krlType bool char real int113" External program and function114syn keyword krlType ext extfct extfctp extp115" Communication116syn keyword krlType signal channel117highlight default link krlType Type118" StorageClass119syn keyword krlStorageClass const struc enum120syn match krlStorageClass /\<decl\>/121syn match krlStorageClass /\<global\>/122highlight default link krlStorageClass StorageClass123" .dat file public124syn keyword krlDatStorageClass public125highlight default link krlDatStorageClass StorageClass126" Parameter StorageClass127" Do not move the :in/:out128" Must be present after krlGeomOperator129syn match krlParamdef /[:]\s*in\>/130syn match krlParamdef /[:]\s*out\>/131highlight default link krlParamdef StorageClass132" Not a typedef but I like to have those highlighted133" different then types, structures or strorage classes134syn keyword krlTypedef DEF DEFFCT ENDFCT DEFDAT ENDDAT135syn match krlTypedef /^\s*END\>/136highlight default link krlTypedef Typedef137" }}} Type, StorageClass and Typedef138 139" Delimiter {{{140syn match krlDelimiter /[\[\](),\\]/141highlight default link krlDelimiter Delimiter142" }}} Delimiter143 144" Constant values {{{145" Boolean146syn keyword krlBoolean true false containedin=krlStructVal147highlight default link krlBoolean Boolean148" Binary integer149syn match krlBinaryInt /'b[01]\+'/ containedin=krlStructVal150highlight default link krlBinaryInt Number151" Hexadecimal integer152syn match krlHexInt /'h[0-9a-fA-F]\+'/ containedin=krlStructVal153highlight default link krlHexInt Number154" Integer155syn match krlInteger /\W\@1<=[+-]\?\d\+/ containedin=krlStructVal,krlFloat contains=krlArithOperator156highlight default link krlInteger Number157" Float158syn match krlFloat /\v\W@1<=[+-]?\d+\.?\d*%(\s*[eE][+-]?\d+)?/ containedin=krlStructVal159highlight default link krlFloat Float160" String161syn region krlString start=/"/ end=/"/ oneline containedin=krlStructVal contains=@Spell162highlight default link krlString String163syn match krlSpecialChar /[|]/ containedin=krlString164highlight default link krlSpecialChar SpecialChar165" String within a fold line166syn region krlSingleQuoteString start=/'/ end=/'/ oneline contained contains=@Spell167highlight default link krlSingleQuoteString String168" Enum169syn match krlEnumVal /#\s*\a\w*/ containedin=krlStructVal170highlight default link krlEnumVal Constant171" }}} Constant values172 173" Predefined Structure and Enum {{{174" Predefined structures and enums found in175" /r1/mada/$*.dat, /r1/steu/$*.dat and176" /r1/system/$config.dat as well as177" basisTech, gripperTech and spotTech178"179syn keyword krlStructure call_stack180" Predefined data types found in $operate*.dat181syn keyword krlStructure aux_pt_mode correction_struc delta_workspace deri_exax deri_struc deri_vector emd_struc energy_data_struc energy_measuring_struc energy_module_struc extended_ret force_val_struc iobus_info_t krl_bp_t loop_axis_inc mbw_para_offset mbw_para_target mbw_result memory_info opc_par_bool_t opc_par_int_t opc_par_real_t opc_par_string_t pathtime_struc pos_axis prog_info p_last_info slave_axis_inc spl_fctctrl spl_fctdef spl_tech spl_techfct spl_techsys spl_tech_map spl_vel_restr_struc ssb_active_t strike_out_components strike_out_struc target_pt_mode tension_struc torqlimitparam t_cs vector vmdirection vmparam vmparam_pull vmparam_push vmstate vmstrategy ws_state182syn keyword krlEnum abs_accur_state accu_state aux_pt_values axesmask_info ax_slave_type bin_parity_t braketest_time_info brake_state buff_mode_t eco_level ediagwritemode energy_config_state_t ext_ipo_mode integration_mode int_typ_e kcp_type laser_mode ldc_ereaction ldc_eresult mbw_error msgbufmsgtype_t prog_int_e prog_status recovery_pose remote_ctrl_mode req_status rob_stop_t seek_mode_t sigdtyp sigtyp spl_techfct_mode spl_tech_bound spl_vel_mode spo_reaction target_pt_values trigger_up_type vmcontrol_s vmerror vmoffoption vmpull vmredundancy_s vmselection_s waittype wait_cmd_e ws_reference183"184" Predefined data types found in krc1185syn keyword krlStructure servopara keymove powermodul trace techangle tech techfct techcps techfctctrl axis_inc axis_cal date display_var pro_ip con bus 186syn keyword krlEnum ident_state sig_state move_state async_state emt_mode boxmode msg_prm_typ msg_typ cmd_stat asys trace_state trace_mode direction techsys techgeoref techclass techmode hpu_key_val pro_state eax transsys mode_move cosys device rotsys emstop cause_t 187"188" Predefined data types found in kss functions189syn keyword krlEnum ediagstate rdc_fs_state ret_c_psync_e var_type cancel_psync_e sys_vars 190syn keyword krlStructure siginf rw_rdc_file rw_mam_file diagpar_t error_t stopmess case_sense_t msgbuf_t e3pos e3axis diagopt_t 191"192" Predefined structures for movement193syn keyword krlStructure frame e6pos pos e6axis axis194syn keyword krlStructure fdat ldat pdat195syn keyword krlStructure load inertia196"197" Predefined structures for shapes198syn keyword krlStructure axbox cylinder box199"200" Predefined structures and enums found in /r1/mada/$machine.dat201syn keyword krlStructure cp fra acc_car jerk_struc dhart spin trpspin ex_kin et_ax maxtool202syn keyword krlEnum individual_mames supply_voltage kinclass main_axis wrist_axis sw_onoff203"204" Predefined structures and enums found in /r1/mada/$robcor.dat205" syn keyword krlStructure206syn keyword krlEnum adap_acc model_type control_parameter eko_mode207"208" Predefined structures and enums found in /steu/mada/$custom.dat209syn keyword krlStructure pro_io_t ser ext_mod_t coop_krc ws_config bin_type coop_update_t ldc_reaction210syn keyword krlEnum axis_of_coordinates motion_mode spline_para_variant spreadstartpolicy target_status cp_vel_type cp_statmon211"212" Predefined structures and enums found in /steu/mada/$machine.dat213syn keyword krlStructure emstop_path boxstatesafein boxstatesafeout214syn keyword krlEnum digincode215"216" Predefined structures and enums found in /steu/mada/$option.dat217syn keyword krlStructure installed_motion_modes msg_t 218syn keyword krlEnum step_enum219" syn keyword krlEnum220"221" Predefined structures and enums found in /r1/system/$config.dat222" BasisTech223syn keyword krlStructure dig_out_type ctrl_in_t ctrl_out_t fct_out_t fct_in_t odat hdat basis_sugg_t out_sugg_t md_state machine_def_t machine_tool_t machine_frame_t trigger_para constvel_para condstop_para adat tm_sugg_t tqm_tqdat_t sps_prog_type224syn keyword krlEnum bas_command out_modetype ipo_m_t apo_mode_t funct_type p00_command timer_actiontype225"226" Types found in System Variable demo227syn keyword krlStructure int_info228"229" GripperTech230syn keyword krlStructure grp_typ grp_types grp_sugg_t231syn keyword krlEnum on_off_typ apo_typ232"233" SpotTech234syn keyword krlStructure spot_type spot_sugg_t235syn keyword krlEnum s_command s_pair_slct command_retr236"237" VW238syn keyword krlStructure vw_mpara_typ zangentyp zangenbedingung ibszangentyp last_ibs_typ verr_typ verrcheck_t t_fb_state kollisionsdaten state_t modus_t239syn keyword krlEnum synctype dir_typ subtype ari_typ bool_typ vw_command ibgn_command vw_user_cmd move_types adv_t_type bas_type ibs_mode_typ vw_user_cmd pro_mode mode_op240"241" ProgCoop242syn keyword krlStructure ydat243" syn keyword krlEnum244"245" bas.src246syn keyword krlStructure cont247syn keyword krlEnum esys ipo_mode circ_mode circ_type ori_type var_state248"249" MsgLib.src250syn keyword krlStructure KrlMsg_T KrlMsgParType_T KrlMsgPar_T KrlMsgOpt_T KrlMsgDlgSK_T251syn keyword krlEnum EKrlMsgType252"253highlight default link krlStructure Structure254highlight default link krlEnum Structure255" }}} Predefined Structure and Enum256 257" System variable {{{258syn match krlSysvars /\<\$\a[a-zA-Z0-9_.]*/259if g:krlGroupName260 highlight default link krlSysvars Sysvars261else262 " default color for Sysvars263endif264" }}} System variable265 266" Statements, keywords et al {{{267" continue268syn keyword krlContinue continue269if g:krlGroupName270 highlight default link krlContinue Continue271else272 highlight default link krlContinue Statement273endif274" interrupt 275syn match krlStatement /\v\c%(<global>\s+)?<interrupt>%(\s+<decl>)?/ contains=krlStorageClass276" keywords277syn keyword krlStatement wait on off enable disable stop trigger with when distance onstart delay prio import is minimum maximum confirm on_error_proceed278syn match krlStatement /\<do\>/279syn match krlStatement /\v\c%(<wait\s+)@7<=<sec>/280syn match krlStatement /\v\c%(<when\s+)@7<=<path>/281highlight default link krlStatement Statement282" Conditional283syn keyword krlConditional if then else endif switch case default endswitch skip endskip284highlight default link krlConditional Conditional285" Repeat286syn keyword krlRepeat to endfor endwhile repeat loop endloop exit287syn match krlRepeat /\<for\>/288syn match krlRepeat /\<while\>/289syn match krlRepeat /\<until\>/290" STEP is used as variable in VKRC, this pattern should match STEP -, 5(constant number) or VAR291syn match krlRepeat /\v\cstep\s+%(-|\w)/me=e-1292highlight default link krlRepeat Repeat293" Label294syn keyword krlLabel goto295syn match krlLabel /^\s*\w\+:\ze\s*\%(;.*\)\?$/296highlight default link krlLabel Label297" Keyword298syn keyword krlKeyword anin anout digin299highlight default link krlKeyword Keyword300" Exception301syn keyword krlException return resume halt302highlight default link krlException Exception303" }}} Statements, keywords et al304 305" special keywords for movement commands {{{306syn keyword krlMovement PTP PTP_REL LIN LIN_REL CIRC CIRC_REL SPL SPL_REL SPTP SPTP_REL SLIN SLIN_REL SCIRC SCIRC_REL307" VKRC movement308syn keyword krlMovement CIR KCIR KLIN309" Async movement310syn keyword krlMovement ASYPTP ASYCONT ASYSTOP ASYCANCEL MOVE_EMI311syn match krlMovement /\v\c^\s*<BRAKE(\s+F)?>/312if g:krlGroupName313 highlight default link krlMovement Movement314else315 highlight default link krlMovement Special316endif317" movement modifiers318syn match krlMoveBlockInst /\c\v^\s*TIME_BLOCK\s+(START|PART|END)/319syn match krlMoveBlockInst /\c\v^\s*CONST_VEL\s+(START|END)/320syn keyword krlMoveBlockInst ptp_spline spline endspline321highlight default link krlMoveBlockInst Statement322syn keyword krlMoveMod ca c_ptp c_dis c_vel c_ori c_spl323if g:krlGroupName324 highlight default link krlMoveMod Movement325else326 highlight default link krlMoveMod Special327endif328" }}} special keywords for movement commands329 330" Structure value {{{331" avoid coloring structure component names332syn match krlNames /\.[a-zA-Z_][.a-zA-Z0-9_$]*/333syn match krlNames contained /[a-zA-Z_][.a-zA-Z0-9_$]*/334" highlight default link krlNames None335" Structure value336syn region krlStructVal start=/{/ end=/}/ oneline containedin=krlStructVal contains=krlNames337highlight default link krlStructVal Delimiter338" }}} Structure value339 340" BuildInFunction {{{341syn keyword krlBuildInFunction contained Pulse342syn keyword krlBuildInFunction contained m_comment343syn keyword krlBuildInFunction contained is_key_pressed 344syn keyword krlBuildInFunction contained set_opt_filter 345syn keyword krlBuildInFunction contained timer_limit 346syn keyword krlBuildInFunction contained tool_adj 347syn keyword krlBuildInFunction contained FRand 348syn keyword krlBuildInFunction contained ExecFunc eb_abs eb_test_abs eb_test EB EK EO LK mbx_rec 349" $operate*.dat350" brake point351syn keyword krlBuildInFunction contained chg_krl_bp clr_all_krl_bp clr_krl_bp disable_krl_bp enable_krl_bp set_krl_bp352" other353syn keyword krlBuildInFunction contained InterimEnergy activate_force_mode DynBrakeTest test_brake354" coll monitor355syn keyword krlBuildInFunction contained get_collmon_set reset_collmon_set 356" safe robot357syn keyword krlbuildinfunction contained get_AxesMask get_BrakeTest_Time358" math359syn keyword krlBuildInFunction contained Abs Acos Atan2 Cos Sin Sqrt Tan360syn keyword krlBuildInFunction contained Forward Inverse inv_pos361" cFoo sFoo362syn keyword krlBuildInFunction contained cClose cOpen cRead cWrite sRead sWrite 363" string364syn keyword krlBuildInFunction contained StrToBool StrToInt StrToReal StrToString StrToFrame StrToPos StrToE3Pos StrToE6Pos StrToAxis StrToE3Axis StrToE6Axis 365syn keyword krlBuildInFunction contained StrAdd StrClear StrCopy StrComp StrFind StrLen StrDeclLen StrToBool StrToInt StrToReal StrToString366" diag367syn keyword krlBuildInFunction contained diag_start diag_stop get_DiagState 368" rdc mam pid369syn keyword krlBuildInFunction contained CheckPidOnRdc check_mam_on_rdc get_rdc_fs_state 370syn keyword krlBuildInFunction contained set_mam_on_hd copy_mam_hd_to_rdc copy_mam_rdc_to_hd 371syn keyword krlBuildInFunction contained PidToHd PidToRdc 372syn keyword krlBuildInFunction contained cal_to_rdc rdc_file_to_hd 373syn keyword krlBuildInFunction contained delete_pid_on_rdc delete_rdc_content 374syn keyword krlBuildInFunction contained create_rdc_archive restore_rdc_archive 375" ioctl376syn keyword krlBuildInFunction contained IOCtl cIOCtl 377syn keyword krlBuildInFunction contained WSpaceGive WSpaceTake 378" sync379syn keyword krlBuildInFunction contained Sync SyncCmd CancelProgSync 380" remote381syn keyword krlBuildInFunction contained RemoteCmd RemoteRead 382" msg/dlg383syn keyword krlBuildInFunction contained IsMessageSet clear_KrlMsg get_MsgBuffer exists_KrlDlg exists_KrlMsg set_KrlDlg set_KrlDlgAnswer set_KrlMsg 384" robvers385syn keyword krlBuildInFunction contained maximize_UsedxRobvers set_UsedxRobvers 386" md_foo387syn keyword krlBuildInFunction contained md_Cmd md_GetState md_SetState md_Asgn 388" emi389syn keyword krlBuildInFunction contained emi_ActPos emi_EndPos emi_StartPos emi_RecState emi_RecName 390" var391syn keyword krlBuildInFunction contained cast_from cast_to392syn keyword krlBuildInFunction contained GetVarsize GetCycDef get_sig_inf get_decl_place VarType VarState 393" sys394syn keyword krlBuildInFunction contained GetSysState get_system_data set_system_data set_system_data_delayed 395" err396syn keyword krlBuildInFunction contained err_clear err_raise397" motion398syn keyword krlBuildInFunction contained AdvancedVectorMoveOn delete_backward_buffer move_backward rob_stop rob_stop_release set_brake_delay suppress_repositioning VectorMoveOn VectorMoveOff399" torque400syn keyword krlBuildInFunction contained set_torque_limits reset_torque_limits401" krc1402syn keyword krlBuildInFunction contained clCopy cCurPos cNew cClear cRelease cKey403if g:krlGroupName404 highlight default link krlBuildInFunction BuildInFunction405else406 highlight default link krlBuildInFunction Function407endif408" }}} BuildInFunction409 410" Function {{{411syn match krlFunction /[$a-zA-Z_]\w* *(/me=e-1 contains=krlBuildInFunction412highlight default link krlFunction Function413" }}} Function414 415" Error {{{416if get(g:, 'krlShowError', 1)417 " some more or less common typos418 "419 " vars or funcs >24 chars are not possible in krl. a234567890123456789012345420 syn match krlError0 /\w\{25,}/ containedin=krlFunction,krlNames,krlLabel,krlEnumVal,krlSysvars421 "422 " should be interrupt (on|off) \w+423 syn match krlError1 /\vinterrupt[ \t(]+[_$a-zA-Z0-9]+[_$a-zA-Z0-9.\[\]()+\-*/]*[ \t)]+o%(n|ff)>/424 "425 " for bla==5 to 7...426 " ||427 syn match krlError3 /\v%(^\s*for%(\(|\s)+[_$a-zA-Z]+[_$a-zA-Z0-9.\[\]()+\-*/ ]*\s*)@<=[:=]\=/428 "429 " wait for a=b430 " |431 syn match krlError4 /\v%(^\s*%(return|wait\s+for|if|while|until|%(global\s+)?interrupt\s+decl)>[^;]+[^;<>=])@<=:?\=[^=]/me=e-1432 "433 " wait for a><b434 " ||435 syn match krlError5 /\v%(^\s*%(return|wait\s+for|if|while|until|%(global\s+)?interrupt\s+decl)>[^;]+)@<=\>\s*\</436 "437 " if (a==5) (b==6) ...438 " |||439 syn match krlError6 /\v%(^\s*%(return|wait\s+for|if|while|until|%(global\s+)?interrupt\s+decl)>[^;]+[^;])@<=\)\s*\(/440 "441 " a == b + 1442 " a := b + 1443 " ||444 syn match krlError7 /\v%(^\s*%(return|wait\s+for|if|while|until|%(global\s+)?interrupt\s+decl)>[^;]+[^;])@1<!%(^\s*[_$a-zA-Z]+[_$a-zA-Z0-9.\[\],+\-*/]*\s*)@<=[:=]\=/445 syn match krlError7 /\v%(^\s*%(decl\s+)%(global\s+)?%(const\s+)?\w+\s+\w+\s*)@<=[:=]\=/446 syn match krlError7 /\v%(^\s*%(decl\s+)?%(global\s+)?%(const\s+)?%(bool\s+|int\s+|real\s+|char\s+)\w+\s*)@<=[:=]\=/447 "448 " this one is tricky. Make sure this does not match trigger instructions; OK, next try, now search for false positives449 " a = b and c or (int1=int2)450 " |451 syn match krlError8 /\v%(^\s*[_$a-zA-Z]+[_$a-zA-Z0-9.\[\]()+\-*/]*\s*\=[^;]*[^;<>=])@<=\=\ze[^=]/452 "453 " <(distance|delay|prio|minimum|maximum)> :=454 " <(distance|delay|prio|minimum|maximum)> ==455 " ||456 syn match krlError9 /\v%(^[^;]*<(distance|delay|prio|minimum|maximum)\s*)@<=[:=]\=/457 "458 " DO is not used at KRL repeat loops (for, while, until)459 syn match krlError10 /\v%(^\s*%(for|while|until)[^;]+)@<=<do>/460 "461 " global decl must be decl global462 syn match krlError11 /\v%(^\s*)@<=global\s+decl>/463 "464 highlight default link krlError0 Error465 highlight default link krlError1 Error466 highlight default link krlError2 Error467 highlight default link krlError3 Error468 highlight default link krlError4 Error469 highlight default link krlError5 Error470 highlight default link krlError6 Error471 highlight default link krlError7 Error472 highlight default link krlError8 Error473 highlight default link krlError9 Error474 highlight default link krlError10 Error475 highlight default link krlError11 Error476endif477" }}} Error478 479" Finish {{{480let &cpo = s:keepcpo481unlet s:keepcpo482 483let b:current_syntax = "krl"484" }}} Finish485 486" vim:sw=2 sts=2 et fdm=marker487 