compiler

package
v0.0.0-...-559a642 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GrammarAliases = map[string]string{
	"source.erb":         "text.html.erb",
	"source.cpp":         "source.c++",
	"source.less":        "source.css.less",
	"text.html.markdown": "text.md",
	"source.gfm":         "text.md",
	"source.php":         "text.html.php",
	"text.plain":         "",
	"source.asciidoc":    "text.html.asciidoc",
	"source.perl6":       "source.raku",
	"source.scss":        "source.css.scss",
	"source.git-config":  "source.gitconfig",
	"source.smarty":      "text.html.smarty",
	"text.slm":           "text.slim",
	"text.pug":           "text.jade",
}
View Source
var GrammarsInNonStdPath = map[string]bool{
	"conllu-linguist-grammar": true,
	"hy.tmLanguage":           true,
	"abl-tmlanguage":          true,
	"avro.tmLanguage":         true,
}

GrammarsInNonStdPath is a list of grammars known to have their syntax .cson or .json files in non-standard directories.

View Source
var IgnoredFiles = map[string]bool{
	"ballerina-grammar/syntaxes/ballerina.monarch.json":           true,
	"oz-tmbundle/Originals/Oz.tmLanguage":                         true,
	"abl-tmlanguage/package-lock.json":                            true,
	"abl-tmlanguage/package.json":                                 true,
	"avro.tmLanguage/package-lock.json":                           true,
	"avro.tmLanguage/package.json":                                true,
	"avro.tmLanguage/avro-avsc-json-schema.json":                  true,
	"liquid-tm-grammar/tests/syntaxes/css.tmLanguage.json":        true,
	"liquid-tm-grammar/tests/syntaxes/html.tmLanguage.json":       true,
	"liquid-tm-grammar/tests/syntaxes/javascript.tmLanguage.json": true,
	"liquid-tm-grammar/tests/syntaxes/json.tmLanguage.json":       true,
	"godot-vscode-plugin/syntaxes/.prettierrc.json":               true,
}

IgnoredFiles is a list of files that look like syntax files but aren't, or are known to be broken and never likely to be fixed.

View Source
var KnownFields = map[string]bool{
	"$schema":               true,
	"comment":               true,
	"uuid":                  true,
	"author":                true,
	"comments":              true,
	"macros":                true,
	"fileTypes":             true,
	"firstLineMatch":        true,
	"keyEquivalent":         true,
	"foldingStopMarker":     true,
	"foldingStartMarker":    true,
	"foldingEndMarker":      true,
	"maxTokensPerLine":      true,
	"limitLineLength":       true,
	"hideFromUser":          true,
	"injectionSelector":     true,
	"swallow":               true,
	"foregroundColor":       true,
	"backgroundColor":       true,
	"increaseIndentPattern": true,
	"beginComment":          true,
	"endComment":            true,
}

Functions

func CheckPCRE

func CheckPCRE(re string) (string, error)

func ConvertCSON

func ConvertCSON(data []byte) ([]byte, error)

func ConvertProto

func ConvertProto(path, ext string, data []byte) (*grammar.Rule, []string, error)

Types

type ConversionError

type ConversionError struct {
	Path string
	Err  error
}

func (*ConversionError) Error

func (err *ConversionError) Error() string

type Converter

type Converter struct {
	Loaded map[string]*Repository
	// contains filtered or unexported fields
}

func NewConverter

func NewConverter(root string) (*Converter, error)

func (*Converter) AddGrammar

func (conv *Converter) AddGrammar(source string) error

func (*Converter) AllScopes

func (conv *Converter) AllScopes() map[string]bool

func (*Converter) ConvertGrammars

func (conv *Converter) ConvertGrammars(update bool) error

func (*Converter) Load

func (conv *Converter) Load(src string) *Repository

func (*Converter) Report

func (conv *Converter) Report(verbose bool) error

func (*Converter) WriteGrammarList

func (conv *Converter) WriteGrammarList() error

func (*Converter) WriteJSON

func (conv *Converter) WriteJSON(rulePath string) error

func (*Converter) WriteProto

func (conv *Converter) WriteProto(path string) error

type DuplicateScopeError

type DuplicateScopeError struct {
	Original  *Repository
	Duplicate string
}

func (*DuplicateScopeError) Error

func (err *DuplicateScopeError) Error() string

type InvalidRegexError

type InvalidRegexError struct {
	File *LoadedFile
	Err  error
}

func (*InvalidRegexError) Error

func (err *InvalidRegexError) Error() string

type LoadedFile

type LoadedFile struct {
	Path string
	Rule *grammar.Rule
}

func (*LoadedFile) String

func (f *LoadedFile) String() string

type MissingIncludeError

type MissingIncludeError struct {
	File    *LoadedFile
	Include string
}

func (*MissingIncludeError) Error

func (err *MissingIncludeError) Error() string

type MissingScopeError

type MissingScopeError struct {
	Scope string
}

func (*MissingScopeError) Error

func (err *MissingScopeError) Error() string

type Repository

type Repository struct {
	Source   string
	Upstream string
	Files    map[string]*LoadedFile
	Errors   []error
}

func LoadFromFilesystem

func LoadFromFilesystem(root, src string) *Repository

func LoadFromURL

func LoadFromURL(src string) *Repository

func (*Repository) AddFile

func (repo *Repository) AddFile(path string, rule *grammar.Rule, uk []string)

func (*Repository) CompareScopes

func (repo *Repository) CompareScopes(scopes []string)

func (*Repository) Fail

func (repo *Repository) Fail(err error)

func (*Repository) FixRules

func (repo *Repository) FixRules(knownScopes map[string]bool)

func (*Repository) Scopes

func (repo *Repository) Scopes() (scopes []string)

func (*Repository) String

func (repo *Repository) String() string

type UndeclaredScopeError

type UndeclaredScopeError struct {
	Path string
}

func (*UndeclaredScopeError) Error

func (err *UndeclaredScopeError) Error() string

type UnexpectedScopeError

type UnexpectedScopeError struct {
	File  *LoadedFile
	Scope string
}

func (*UnexpectedScopeError) Error

func (err *UnexpectedScopeError) Error() string

type UnknownKeysError

type UnknownKeysError struct {
	File *LoadedFile
	Keys []string
}

func (*UnknownKeysError) Error

func (err *UnknownKeysError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL