betacode1 / google-code-prettify

Automatically exported from code.google.com/p/google-code-prettify
Apache License 2.0
0 stars 0 forks source link

Highlighting Support for the Spin Language #232

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am part of team that is putting a library for Spin code onto Google Code. We 
would like syntax highlighting for the Spin language (a Python like language 
for the Propeller microcontroller from Parallax.com).

I have attached a .lang file to this issue. This is the syntax highlighting for 
the GTK Source View system. If a list of keywords would be more appropriate 
then I can provide that too.

Here is a link to some example code for Spin: 
http://www.parallaxsemiconductor.com/sites/default/files/parallax/Gold-Standard_
2.zip

More code can be found at obex.parallax.com (any of the files will do).

One note about the highlighting: the block comment of Spin is a bit odd. There 
are two versions:

{ block comment type 1 }
{{ block comment type 2 }}

A block comment has either one curly brace or two. A double {{ comment could be 
incorrectly parsed as a single { followed by (as part of the comment) another 
{. Then, the last } of the }} pair would be incorrectly highlighted as part of 
the code, rather than the closing part of the comment. The .lang file gets 
around this by defining the {{/}} comment first. It seems to work, but I don't 
know if this a defined feature of Source View or not.

Original issue reported on code.google.com by srlm@anzhelka.com on 9 Aug 2012 at 2:45

Attachments:

GoogleCodeExporter commented 8 years ago
> The .lang file gets around this by defining the {{/}} comment first

JS regexps are analytic so this should work.

Original comment by mikesamuel@gmail.com on 5 Feb 2013 at 12:09

GoogleCodeExporter commented 8 years ago
In what format is spin.lang written?

Original comment by mikesamuel@gmail.com on 5 Feb 2013 at 12:22

GoogleCodeExporter commented 8 years ago
The .lang format is from the GtkSourceView project.

http://projects.gnome.org/gtksourceview/

Original comment by s...@srlmproductions.com on 5 Feb 2013 at 5:40

GoogleCodeExporter commented 8 years ago
Ah.  I've put off writing adapters for things like that because of a lack of 
clarity on OSS licenses.

You don't happen to have a language grammar handy?  I can probably sort it out 
from 
http://code.google.com/p/anzhelka/source/browse/software/spin/src/main.spin and 
the keyword list in spin.lang.

Original comment by mikesamuel@gmail.com on 5 Feb 2013 at 2:19

GoogleCodeExporter commented 8 years ago
Unfortunately, there isn't a formal language grammar. Spin is defined by what 
the official Parallax compiler produces.

There is a good list of keywords and their breakdown in the Propeller manual 
v1.2, page 36:
http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/Web-PropellerManual-v
1.2.pdf

The anzhelka main is a good reference for most of the language features to test 
out on. The main thing that it's missing is an assembly DAT (or dat, spin is 
case-insensitive) block. An example block can be found in the following file, 
starting on line 368 and running the rest of the file: 
http://code.google.com/p/anzhelka/source/browse/software/spin/lib/Float32.spin

Original comment by s...@srlmproductions.com on 5 Feb 2013 at 5:27