.lang files — languages for the code editor

Category: IGI (in-game GUI) — Code editor

The IGI code editor colours text by following a .lang file: a small text file that says what the language's comments, strings, numbers and words look like, and what colour each is. Load one with igiLoadLanguage, or pass the same text to igiDefineLanguage. If something in it is wrong, the rest still works, and igiLanguageErrors tells you what and on which line.

Ready-made files are in userlibs\languages: bamboobasic.lang, cpp.lang, lua.lang, wgsl.lang and hlsl.lang. Copying one is the easiest way to start a new language.


An example
; mylang.lang - lines starting with ; are comments
name          = MyScript
caseSensitive = no
lineComment   = ;  //                 ; one or more
blockComment  = /*  */                ; a start and an end; can run over lines
string        = "  \                  ; the quote, then the escape character (if any)
numbers       = decimal hex:$ hex:0x binary:%
identifier    = A-Za-z_ : A-Za-z0-9_  ; first character : the rest
pattern       = #\w+ : preprocessor   ; a regular expression : the group it colours as

[keywords]
If Then Else EndIf While Wend
Function EndFunction Return

[types]
Int String Double

[colours]
keywords     = 86 156 214
types        = 78 201 176
preprocessor = 197 134 192
comment      = 106 153 85
background   = 30 30 30

Settings

Settings go at the top, before any [section], as name = value. Anything after a ; with a space before it is a comment (except on pattern lines).

SettingWhat it does
nameThe language's name (shown in error messages).
caseSensitiveyes or no. With no, IF, If and if are all the same keyword. Starts as yes.
lineCommentWhat starts a comment that runs to the end of the line. Give several separated by spaces, or repeat the setting.
blockCommentThe start and end of a comment that can run over several lines, such as /* */ or Lua's --[[ ]]. Repeat it for more than one kind.
stringA quote character (or text), then optionally the escape character that lets the quote appear inside the string. string = " \ is C's; string = " has no escape. Repeat it for more kinds of quote. Strings end at the end of the line if they aren't closed.
numbersWhich numbers to colour: decimal (42, 3.14, .5, 1e-3), hex:prefix and binary:prefix. numbers = decimal hex:$ binary:% is BambooBasic's. Starts as decimal only.
identifierThe characters a word can start with, then :, then the characters it can go on with. Ranges like A-Z work. Starts as A-Za-z_ : A-Za-z0-9_.
patternA regular expression (ECMAScript, as in JavaScript), then space : space and the group to colour the match as. For things words and numbers can't describe, such as #include, @group or SV_Target. Patterns are tried in the order they're written, and only match where a token starts.

Word groups

Any [section] other than [colours] is a group of words: write the words after it, separated by spaces, on as many lines as you like. The section's name is the group's name; use any names and as many groups as you want ([keywords], [types], [functions], [constants]…). A pattern can colour as a group too.


Colours

In [colours] each line is a name and a colour as three numbers 0-255 (red, green, blue). The names are your groups, plus:

NameColoursStarts as
texteverything else (names that aren't in a group)220 220 220
commentcomments106 153 85
stringstrings206 145 120
numbernumbers181 206 168
operatorpunctuation: + - ( ) , : and so on200 200 200
backgroundthe editor's background30 30 30
gutterbehind the line numbers26 26 26
linenumberthe line numbers133 133 133
currentlinethe caret's line42 42 42
selectionselected text38 79 120
caretthe caret255 255 255

A group with no colour of its own gets one in turn, in the order the groups are written: blue, teal, yellow, purple, light blue, gold, red, green.


How a line is read

At each point in a line the editor tries, in this order: the end of a block comment it's inside; the start of a block comment; a line comment; a string; the patterns; a number; a word (looked up in the groups); and anything else is an operator. Knowing the order helps when two rules could both match.


bamboobasic.lang

bamboobasic.lang is made from the IDE's keyword list and the runtime's function list, with the IDE's colours, so it colours code the way the IDE does.


BambooBasic © 2026 Michael Denathorn