package q

import "github.com/alecthomas/chroma/lexers/q"

Index

Variables

var Qbasic = internal.Register(MustNewLexer(
	&Config{
		Name:      "QBasic",
		Aliases:   []string{"qbasic", "basic"},
		Filenames: []string{"*.BAS", "*.bas"},
		MimeTypes: []string{"text/basic"},
	},
	Rules{
		"root": {
			{`\n+`, Text, nil},
			{`\s+`, TextWhitespace, nil},
			{`^(\s*)(\d*)(\s*)(REM .*)$`, ByGroups(TextWhitespace, NameLabel, TextWhitespace, CommentSingle), nil},
			{`^(\s*)(\d+)(\s*)`, ByGroups(TextWhitespace, NameLabel, TextWhitespace), nil},
			{`(?=[\s]*)(\w+)(?=[\s]*=)`, NameVariableGlobal, nil},
			{`(?=[^"]*)\'.*$`, CommentSingle, nil},
			{`"[^\n"]*"`, LiteralStringDouble, nil},
			{`(END)(\s+)(FUNCTION|IF|SELECT|SUB)`, ByGroups(KeywordReserved, TextWhitespace, KeywordReserved), nil},
			{`(DECLARE)(\s+)([A-Z]+)(\s+)(\S+)`, ByGroups(KeywordDeclaration, TextWhitespace, NameVariable, TextWhitespace, Name), nil},
			{`(DIM)(\s+)(SHARED)(\s+)([^\s(]+)`, ByGroups(KeywordDeclaration, TextWhitespace, NameVariable, TextWhitespace, NameVariableGlobal), nil},
			{`(DIM)(\s+)([^\s(]+)`, ByGroups(KeywordDeclaration, TextWhitespace, NameVariableGlobal), nil},
			{`^(\s*)([a-zA-Z_]+)(\s*)(\=)`, ByGroups(TextWhitespace, NameVariableGlobal, TextWhitespace, Operator), nil},
			{`(GOTO|GOSUB)(\s+)(\w+\:?)`, ByGroups(KeywordReserved, TextWhitespace, NameLabel), nil},
			{`(SUB)(\s+)(\w+\:?)`, ByGroups(KeywordReserved, TextWhitespace, NameLabel), nil},
			Include("declarations"),
			Include("functions"),
			Include("metacommands"),
			Include("operators"),
			Include("statements"),
			Include("keywords"),
			{`[a-zA-Z_]\w*[$@#&!]`, NameVariableGlobal, nil},
			{`[a-zA-Z_]\w*\:`, NameLabel, nil},
			{`\-?\d*\.\d+[@|#]?`, LiteralNumberFloat, nil},
			{`\-?\d+[@|#]`, LiteralNumberFloat, nil},
			{`\-?\d+#?`, LiteralNumberIntegerLong, nil},
			{`\-?\d+#?`, LiteralNumberInteger, nil},
			{`!=|==|:=|\.=|<<|>>|[-~+/\\*%=<>&^|?:!.]`, Operator, nil},
			{`[\[\]{}(),;]`, Punctuation, nil},
			{`[\w]+`, NameVariableGlobal, nil},
		},
		"declarations": {
			{`\b(DATA|LET)(?=\(|\b)`, KeywordDeclaration, nil},
		},
		"functions": {
			{"" /* 512 byte string literal not displayed */, KeywordReserved, nil},
		},
		"metacommands": {
			{`\b(\$DYNAMIC|\$INCLUDE|\$STATIC)(?=\(|\b)`, KeywordConstant, nil},
		},
		"operators": {
			{`\b(AND|EQV|IMP|NOT|OR|XOR)(?=\(|\b)`, OperatorWord, nil},
		},
		"statements": {
			{"" /* 846 byte string literal not displayed */, KeywordReserved, nil},
		},
		"keywords": {
			{"" /* 201 byte string literal not displayed */, Keyword, nil},
		},
	},
))

Qbasic lexer.

Source Files

qbasic.go

Version
v0.7.1
Published
Jan 2, 2020
Platform
js/wasm
Imports
2 packages
Last checked
12 minutes ago

Tools for package owners.