Sublime Forum

Uniface syntax highlighting - what am I doing wrong?

#1

I’m trying to get Sublime Text 2 to highlight Uniface proc code.

My initial version of the JSON is deliberately simplistic - I just want it to highlight the keywords, comments, etc even though I expect a lot of false matches at the moment e.g. where a comment contains code.

Nevertheless, all I get is plain black/white text with no colours at all. Have I messed up the JSON somehow or do I need to define the colours somewhere as well as the matches?

My current effort is:

{ 
	"name": "Uniface proc",
	"scopeName": "source.uniface_proc",
	"fileTypes": "uni","pro"],
	"repository": {
		"general": {
			"patterns": 
				{"include": "#comment"},
				{"include": "#control_block"},
				{"include": "#keywords"},
				{"include": "#data_types"},
				{"include": "#parameter_direction"},
				{"include": "#variable_dollar"}
			]
		},

		"comment": {
			"match": ";.*$",
			"name": "comment.line.uniface_proc"
		},

		"control_block":{
			"match": "(else|elsecase|elseif|end|endif|endparams|endscope|endselectcase|endvariables|endwhile|entry|if|operation|params|repeat|scope|selectcase|trigger|until|variables|while)",
  			"name": "keyword.control.uniface_proc"
		},

		"data_types":{
			"match": "(any|boolean|date|datetime|entity|float|handle|image|lineardate|lineardatetime|lineartime|numeric|occurrence|raw|string|time|xmlstream)",
	  		"name": "storage.type.uniface_proc"
		},

		"keywords":{
			"match": "(activate|addmonths|apexit|apstart|askmess|blockdata|break|call|callfieldtrigger|case|clear|clear/e|close|clrmess|commit|compare|creocc|curoccvideo|debug|delete|delitem|dircreate|dirdelete|dirrename|discard|display|displaylength|done|edit|eject||erase|exit|fieldsyntax|fieldvideo|filebox|filecopy|filedelete|filedump|fileload|filemove|filerename|findkey|flush|getitem|getlistitems|goto|help|ldircreate|ldirdelete|ldirrename|length|lfilecopy|lfiledelete|lfiledump|lfileload|lfilemove|lfilerename|lflush|lock|lookup|lowercase|macro|message|moveocc|nodebug|numgen|numset|open|perform|postmessage|pragma|print|printbreak|proccompile|pulldown|putitem|putlistitems|putmess|read|reconnect|refresh|release|reload|remocc|reset|retrieve|retrieve/a|retrieve/e|retrieve/o|retrieve/reconnect|retrieve/x|return|returns|rollback|run|scan|selectdb|setocc|set|show|skip|sleep|sort|sort/list|spawn|sql|store|stripattributes|trigger|u_condition|u_where|uppercase|validate|validatefield|validatekey|validateocc|web|webdefinitions|webgen|webget|weblayout|webload|webmessage|websave|websetocc|write|xmlload|xmlsave|xmlvalidate)",
	  		"name": "keyword.source.uniface_proc"
		},

		"parameter_direction":{
			"match": "(inout|in|out|partner|public)",
	  		"name": "variable.language.uniface_proc"
		},

		"variable_dollar":{
			"match": "\\$\\$?[A-Za-z0-9_]+\\$?",
	  		"name": "variable.source.uniface_proc"
		},

		"string":{
            "begin": "\"", 
            "beginCaptures": {
                "0": {
                    "name": "punctuation.definition.string.begin.shell"
                }
            }, 
            "end": "\"", 
            "endCaptures": {
                "0": {
                    "name": "punctuation.definition.string.end.shell"
                }
            }, 
            "name": "string.quoted.double.uniface_proc"
        }		
	},
	"uuid": "36fb77f3-e99f-4578-a68d-c7d72c4b1ffc"
}

This should highlight the following file but it shows all one colour as if plain text:

; Comment
entry ProcedureName
  params
    string parametername : in
  endparams
  variables
    numeric somevariable
  endvariables
  while ($status > 0 & $$GLOBALVARIABLE == 1 & $COMPONENTVARIABLE == 2)
    if (parametername == "BOO")
      SOMEFIELD.SOMEENTITY = "a string of text"
    endif
  endwhile ; another comment
end

I’ve been following the guide at sublimetext.info/docs/en/extensi … xdefs.html and also examining .JSON.tmLanguage files online but I just can’t see where my very simplified file is going wrong.

Can anyone point out the error of my ways or suggest some method of debugging syntax highlighting files please?

0 Likes

#2

The .tmLanguage file associates Regular Expression string matches with “scopes”. You also need a .tmTheme “Color Scheme” file to assign colors to scopes.

Use ScopeHunter. It is invaluable at debugging syntax highlighting files.
macdrifter.com/2013/02/scope … -link.html

0 Likes

#3

Thanks - that’s exactly what I needed to know. Scope Hunter is proving incredibly helpful in improving the matches.

It turns out most of my problem was caused by a missing

"patterns": {"include": "#general"} ],

just prior to the uuid definition.

0 Likes