cheat/vendor/github.com/alecthomas/chroma/lexers/b/blitz.go
Chris Lane 55b18b4897 Squashed commit of the following:
commit 95479c8ad744db48386a5c78e54ef8da80e9120b
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 12:26:32 2021 -0400

    chore(version): bump version to 4.2.1

commit 6956f51cae
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 12:24:21 2021 -0400

    fix(Makefile): `vendor-update`

    Update the `vendor-update` build target to run `go mod vendor` after
    updating dependencies.

commit 0aca411279
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 12:23:24 2021 -0400

    chore(deps): update dependencies

commit e847956b02
Author: Chris Lane <chris@chris-allen-lane.com>
Date:   Wed Apr 28 08:26:51 2021 -0400

    chore(deps): build updates

    - Upgrade `go` to `1.16.3`

    - Attempt to fix build errors regarding dependencies
2021-04-28 12:35:32 -04:00

52 lines
2.6 KiB
Go

package b
import (
. "github.com/alecthomas/chroma" // nolint
"github.com/alecthomas/chroma/lexers/internal"
)
// Blitzbasic lexer.
var Blitzbasic = internal.Register(MustNewLazyLexer(
&Config{
Name: "BlitzBasic",
Aliases: []string{"blitzbasic", "b3d", "bplus"},
Filenames: []string{"*.bb", "*.decls"},
MimeTypes: []string{"text/x-bb"},
CaseInsensitive: true,
},
blitzbasicRules,
))
func blitzbasicRules() Rules {
return Rules{
"root": {
{`[ \t]+`, Text, nil},
{`;.*?\n`, CommentSingle, nil},
{`"`, LiteralStringDouble, Push("string")},
{`[0-9]+\.[0-9]*(?!\.)`, LiteralNumberFloat, nil},
{`\.[0-9]+(?!\.)`, LiteralNumberFloat, nil},
{`[0-9]+`, LiteralNumberInteger, nil},
{`\$[0-9a-f]+`, LiteralNumberHex, nil},
{`\%[10]+`, LiteralNumberBin, nil},
{Words(`\b`, `\b`, `Shl`, `Shr`, `Sar`, `Mod`, `Or`, `And`, `Not`, `Abs`, `Sgn`, `Handle`, `Int`, `Float`, `Str`, `First`, `Last`, `Before`, `After`), Operator, nil},
{`([+\-*/~=<>^])`, Operator, nil},
{`[(),:\[\]\\]`, Punctuation, nil},
{`\.([ \t]*)([a-z]\w*)`, NameLabel, nil},
{`\b(New)\b([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
{`\b(Gosub|Goto)\b([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameLabel), nil},
{`\b(Object)\b([ \t]*)([.])([ \t]*)([a-z]\w*)\b`, ByGroups(Operator, Text, Punctuation, Text, NameClass), nil},
{`\b([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?\b([ \t]*)(\()`, ByGroups(NameFunction, Text, KeywordType, Text, Punctuation, Text, NameClass, Text, Punctuation), nil},
{`\b(Function)\b([ \t]+)([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?`, ByGroups(KeywordReserved, Text, NameFunction, Text, KeywordType, Text, Punctuation, Text, NameClass), nil},
{`\b(Type)([ \t]+)([a-z]\w*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
{`\b(Pi|True|False|Null)\b`, KeywordConstant, nil},
{`\b(Local|Global|Const|Field|Dim)\b`, KeywordDeclaration, nil},
{Words(`\b`, `\b`, `End`, `Return`, `Exit`, `Chr`, `Len`, `Asc`, `New`, `Delete`, `Insert`, `Include`, `Function`, `Type`, `If`, `Then`, `Else`, `ElseIf`, `EndIf`, `For`, `To`, `Next`, `Step`, `Each`, `While`, `Wend`, `Repeat`, `Until`, `Forever`, `Select`, `Case`, `Default`, `Goto`, `Gosub`, `Data`, `Read`, `Restore`), KeywordReserved, nil},
{`([a-z]\w*)(?:([ \t]*)(@{1,2}|[#$%])|([ \t]*)([.])([ \t]*)(?:([a-z]\w*)))?`, ByGroups(NameVariable, Text, KeywordType, Text, Punctuation, Text, NameClass), nil},
},
"string": {
{`""`, LiteralStringDouble, nil},
{`"C?`, LiteralStringDouble, Pop(1)},
{`[^"]+`, LiteralStringDouble, nil},
},
}
}