Home Download Buy Blog Forum Support

Uniface syntax highlighting - what am I doing wrong?

Uniface syntax highlighting - what am I doing wrong?

Postby eviloverlord on Thu Mar 28, 2013 5:43 pm

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:
Code: Select all
{
   "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:

Code: Select all
; 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 http://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?
eviloverlord
 
Posts: 2
Joined: Thu Mar 28, 2013 5:27 pm

Re: Uniface syntax highlighting - what am I doing wrong?

Postby robertcollier4 on Thu Mar 28, 2013 6:24 pm

eviloverlord wrote:or do I need to define the colours somewhere as well as the matches?

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

eviloverlord wrote:or suggest some method of debugging syntax highlighting files please?

Use ScopeHunter. It is invaluable at debugging syntax highlighting files.
http://www.macdrifter.com/2013/02/scope ... -link.html
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm

Re: Uniface syntax highlighting - what am I doing wrong?

Postby eviloverlord on Fri Mar 29, 2013 3:04 am

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
Code: Select all
"patterns": [{"include": "#general"} ],

just prior to the uuid definition.
eviloverlord
 
Posts: 2
Joined: Thu Mar 28, 2013 5:27 pm


Return to General Discussion

Who is online

Users browsing this forum: estmatic and 27 guests