#28 Syntax-Highlighting for z80 source


could you add z80-source syntax-highlighting ?
on search there are severall package available for common syntax-highlighting


  • Derrick Moser

    Derrick Moser - 2013-03-14

    Example of Z80 syntax highlighting

  • Derrick Moser

    Derrick Moser - 2013-03-14

    Diffuse lets users add their own custom syntax highlighting rules. It is a simple (ie. not very sophisticated) finite state machine that uses Python regular expressions for matching text. There is brief documentation of the syntax highlighting system in the manual. If the language is similar to one currently supported, consider using its *.syntax file as reference for your own. You can install your syntax highlighting file by placing it in the ~/.config/diffuse folder and append an import statement to ~/.config/diffuse/diffuserc like this:

    $ mv z80.syntax ~/.config/diffuse/
    $ echo "import z80.syntax" >> ~/.config/diffuse/diffuserc

    I'm not familiar with z80 but have attempted to quickly throw together a syntax file for you. There appears to be multiple z80 assembler formats. I probably have the preprocessor stuff wrong. Let me know if you need any help customising the syntax file further.

  • crisis13

    crisis13 - 2013-03-19

    in debian 6 diffuserc is placed in /etc and contains the line:
    import ../usr/share/diffuse/syntax/*.syntax

    changing your lines gave errors so I placed z80.syntax directly in /usr/share/diffuse/syntax and just looked at the syntax list and there it is now !!

    first remark about z80.syntax itself is:
    the ' sign is used for a colour change , maybe a remark?
    but in z80 the ' is used for alternative registers

    ex af, af''
    ld d, (exo_mapbasebits/256)+1
    ld a, (de)
    inc d
    add a,c
    ld c, a
    ld a, (de)
    adc a,b
    ld b, a
    ld (token_length+1), bc
    jr nz, exo_dontgo
    ld de, 512+48 ;1?
    dec c
    jr z, exo_goforit
    dec c ;2?
    ld de, 1024+16
    jr nz, exo_goforit
    ld e, 32
    ex af, af''
    ld bc, 0

    the ' after AF will result in a permanent colour change (red) until the next ' apears

    Now by using this webformular i have another remark:
    the within the txt copied ' sign was REMOVED by the parser giving AF instead of AF'
    i supose its the COPIE parser of your form that cuts out any ' sign.
    maybe that's a SourgeForge routine ?

  • crisis13

    crisis13 - 2013-03-19

    the ' is maybe just in "open" state since now the comment has a confusion double ' as in af''
    the copie parser works ok, it was just not visible that the ' was realy copied

  • Derrick Moser

    Derrick Moser - 2013-03-19

    There is a system wide initialisation file, /etc/diffuserc, that requires root privileges to modify and affects all users. There is also a per user initialisation file, ~/.config/diffuse/diffuserc, for adding your own customisations. I forgot to mention you likely need to manually create the directory structure (can be created with "mkdir -p ~/.config/diffuse") and the file itself (created with the "echo 'import z80.syntax' >> ~/.config/diffuse/diffuserc" command). Sorry for the confusion. Paths used with the "import" command are relative to the file containing the import command. Ideally, all of your personal customisations will be placed in a single directory (~/.config/diffuse). The commands for installing the syntax file should have been:

    $ mkdir -p ~/.config/diffuse
    $ mv z80.syntax ~/.config/diffuse
    $ echo "import z80.syntax" >> ~/.config/diffuse/diffuserc

    The highlighting behaviour of the single quote character is due to my poor understanding of the z80 syntax. I assumed the single quote was used to specify character literals similar to the language C. Are single quotes only used to specify alternative registers? If that is the case, you could simply remove the special handling of single quotes by removing the lines containing "single_string" from the z80.syntax file (or commenting out the lines with by placing a "#" character at the beginning).

  • crisis13

    crisis13 - 2013-03-20

    the single quote character is used in the syntax at one place only, which is the command
    ex AF, AF'
    In books like http://www.worldofspectrum.org/infoseekid.cgi?id=2000687
    on page 106 the single quote mark is used in the formula to explain like in
    LD r,r'
    but thats a replacement and the real command WONT have the single quote character
    This means you just can remove the line from your original z80.syntax file
    thanks for making this possible, i will read the file it self and try to enlarge it with eg PASMO directives


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks