Sublime Forum

Add support for a slightly modified Python language syntax

#1

Hi,

I use a tool which generates source code from a UML model and for some strange reason they have a slightly different syntax to Python, even though it’s actually Python that is being used. The key differences are as follows.

Files are named .inc and .tpl, so they do not directly clash with .py files.

  def mapModelElement(self, element):
    if getUtil().isIgnore(element):
      return ]
    return  element ]

Changes to…

  def mapModelElement(self, element) :{
    if getUtil().isIgnore(element) :{
      return ]
    :}
    return  element ]
  :}

The other quirk is that when encountering an @ symbol, this changes to template output. For example:

  def writeHtmlHeader() :{
@
<html>
  <head>
@writeHtmlStyles()@
@writeHtmlScripts()@
  </head>
@
  :}

To output an @ symbol the programmer would write @@.

I’m now wondering how easy it would be to modify the Python ‘TM’ files to achieve this. Is there a good guide somewhere that I can look at to try and work out what changes I need to get these little quirks understood by Sublime Text? Color schemes would also be a big bonus!

Thanks,
Stuart

0 Likes

#2

Should I have posted this somewhere else?

0 Likes

#3

https://www.sublimetext.com/docs/3/syntax.html

But it requires the last dev build.
Else the unofficial doc has something on the subject.

0 Likes