Shop OBEX P1 Docs P2 Docs Learn Events
Spin ctags — Parallax Forums

Spin ctags

jazzedjazzed Posts: 11,803
edited 2012-06-30 23:28 in Propeller 1
Hi.

An off-shoot of some work i'm doing for SimpleIDE is a spin ctags program. The ctags program searches files for language symbols and creates a lookup method for different editors. If you are a VI or EMACS user, it is a great benefit. I've only tested it with VIM.

The editor must understand UTF16 fonts like the Parallax font to be useful with such files. Linux VIM automatically translates the files. For other editors, one can use the iconv program to convert Parallax files to ASCII.

The ctags program will create a tags file (or TAGS with -e) that will make tags for spin files specified on the command line as:

$ ctags *.spin c:/spinlib/*.spin

Some current limits/issues:
  • Using tags with an editor that does not support the parallax font will be disappointing. While the ctags program itself doesn't seem to have trouble with the font.
  • The ctags program will not automatically look up the correct object for symbols. The user must know to do this manually. This could be enhanced for spin.
  • There is at least one bug where a symbol like "dat0 long $55" will be tagged as "0".
If you need a source pointer for some reason it's in the propside.googlecode.com repository. There are two ctags folders. I'm only using ctags-5.8 long term so that's where you'll find the source. Also, I'm not actually using the ctags program for generating spin tags in SimpleIDE because I need a better database than ctags can provide.

Comments

  • Heater.Heater. Posts: 21,230
    edited 2012-06-28 08:21
    Jazzed,

    Linux VIM automatically translates the files

    Not vim on my Debian box here. What am I missing?
  • jazzedjazzed Posts: 11,803
    edited 2012-06-28 08:27
    Hmm. Got dos2unix ?
  • Heater.Heater. Posts: 21,230
    edited 2012-06-28 08:45
    dos2unix? For sure, cannot live without it. However that does not help. For example I have a UTF-16 copy of Servo32_Ramp_v2.spin

    $ file Servo32_Ramp_v2.spin Servo32_Ramp_v2.spin: Little-endian UTF-16 Unicode English text, with CRLF line terminators

    Opening in vim gives a screen full of garbage and dos2unix barfs:

    $ dos2unix Servo32_Ramp_v2.spin
    dos2unix: Skipping binary file Servo32_Ramp_v2.spin

    Only way out is with iconv:

    $iconv -f UTF-16 -t ASCII Servo32_Ramp_v2.spin

    Which always throws up when it hits graphics chars in the file:

    iconv: illegal input sequence at position 29288

    Which happens to be the box around the license text. So try again with the -c option

    BINGO it works!

    God I hate all the internationalization nonsense. And who thought graphics chars in source files was a good idea?
  • jazzedjazzed Posts: 11,803
    edited 2012-06-28 09:03
    Heater I don't know really what the difference is, but i'm running debian 6.02 i686.
    I have a simplified chinese font installed for testing - maybe that affects it. No idea.

    Your help for early testing of the SpinSIDE would be very useful at this point.
    The QPlainTextEdit is supposed to do all this for us. Need some verification though.

    Hope my spin ctags effort is useful otherwise.
    The source browser parser in SimpleIDE certainly benefited from it.

    Thanks.
    --Steve
  • Heater.Heater. Posts: 21,230
    edited 2012-06-28 09:14
    Jazzed,
    Your help for early testing of the SpinSIDE would be very useful at this point.

    I'll see what I can do.
  • jazzedjazzed Posts: 11,803
    edited 2012-06-28 12:49
    Heater. wrote: »
    And who thought graphics chars in source files was a good idea?


    Propably someone we know.
  • Heater.Heater. Posts: 21,230
    edited 2012-06-28 13:13
    Yeah I know. Perhaps I should not shout so loud.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-06-28 13:31
    You could always add it to the 'What Frustrates Me" thread!! :lol:
  • pedwardpedward Posts: 1,642
    edited 2012-06-28 13:49
    UTF-16 uses a sentinel sequence to indicate that it's UTF-16, whereas UTF-8 parses inline. Perhaps the files are missing the sentinel value and conventional parsing is choking when it hits a 16 bit character.
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-06-28 14:58
    Steve, I ran ctags on a spin file, and it produced a tags file. Now how do I use the tags file with vi?
  • jazzedjazzed Posts: 11,803
    edited 2012-06-28 15:31
    Dave Hein wrote: »
    Steve, I ran ctags on a spin file, and it produced a tags file. Now how do I use the tags file with vi?
    Assuming one cares to find a unique "symbol" in a file ...
    At startup one of these:
    [LIST=|INDENT=2]
    [*]vi -t symbol
    [*]vim -t symbol
    [/LIST]
    After startup:
    [LIST=|INDENT=2]
    [*]Put cursor over a symbol then Ctrl+] (Ctrl and Right Bracket)
    [*]ESC, :ta symbol
    [*]ESC, :pop
    [/LIST]
    Two files in the same project should not have the same symbols such as found in TvText.spin and VgaText.spin.

    It is possible modify the ctag program to find a symbol based on scope, but I haven't added that.

    The tags database should be built with the spin files.
    Say the project has all spin files in the current directory, then:
    [LIST=|INDENT=2]
    [*]ctags *.spin
    [/LIST]
    Say you have many spin files but only care about main.spin and FullDuplexSerial.spin, then:
    [LIST=|INDENT=2]
    [*]ctags main.spin FullDuplexSerial.spin
    [/LIST]
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-06-30 23:28
    Heater. wrote: »
    Jazzed,

    Not vim on my Debian box here. What am I missing?
    In vim, open the file, then type:
    :e ++enc=ucs-2
    
Sign In or Register to comment.