Moonshine Syntax File Format

Moonshine version 1.1.2


Summary of Changes

1.1.2

  • added support for specifying background colors

1.1.0

  • Syntax's are now stored separately from modules, in a file ending with a .syntax extension
  • Moved discussion of syntax highlighting from module.html to this document
  • Updated example

Summary

Syntax files are used to store syntax highlighting rules for use in brew or in the captured commands window. A syntax file must begin with the line:

#Moonshine Syntax File

Object Types

Name Description
tag A tag is used to identify the placement and content of a list or block.
string a sequence of characters
list A list is a comma separated series of strings ended by a new line
block A block is a series one or more lists ended by a double-newline

Rules for Tags

  • Tags must start in column zero and end with a colon.
  • A tag must be followed by a list on the same line or by a block on the next line.
  • Tags are not case sensitive
  • Placement of any of the recognized tags within the syntax file is not important.

Recognized Tags

Tag Description
background color a color (e.g. green) or an RBG value proceded by a # (e.g. #00FFFF)
forground color a color (e.g. green) or an RBG value proceded by a # (e.g. #00FFFF)
syntax syntax definitions block
colors color definitions block

The Syntax Definitions Block

This is a list of syntax definitions.

Syntax Definitions Block Format

id , parent id , syntax element type , syntax element

Description of Fields

id used to identify the syntax element if used as a parent and to identify the default color to use. multiple syntax definitions may share an id
parent id refers to another syntax definition. this definition will only be valid within that parent syntax.
use <none> if their is no parent
syntax element type One of: keyword, regex, block, line
syntax element the text of the syntax element. the format of this depends on which sayntax element type is being used

Syntax Element Types

element type example definition description
keyword decl, <none>, keyword, int matches on literal text
regex directive, <none>, regex, #.* matches a Qt-style regular expression
line comment, <none>, line, // matches from the given literal text (inclusive) to the next newline
block comment, <none>, block, /* */ matches from starting text to ending text (inclusive)

Color Block Format

id , fg color , styles    
id , fg color , styles , bg color

Description of Fields

id maps this color to a syntax definition
fg color text foreground color. Either a named color or an RGB value (e.g. green or #00FFFF)
styles a space separated list of styles. Supported styles are: normal, italics, bold
bg color text background color. Either a named color or an RGB value (e.g. blue or #FF00FF)


A Complete Example of a Syntax


#Moonshine Syntax File
forground color: black
background color: #999999

// id, parent, type, definition

Syntax:
tag, <none>, regex, ^[^:,]+:[\s]
builtin, <none>, regex, $[^\s\;]*
variable, <none>, regex, %[^\s\;]*
default, <none>, regex, <.*>
url, <none>, regex, (.*)\s*$
comment, <none>, regex, ^//.*
id, <none>, regex, ^#Moonshine\sModule\sFile$

// id, color, (optional) styles (bold and/or italics)

Colors:
tag, darkblue, bold
default, darkblue, bold
builtin, darkgreen, bold
variable, darkolivegreen, bold
comment, gold, normal, gray70
id, black, bold
url, darkblue, normal