advanced library
Grammar authoring and engine access for val_highlight.
Import this to write or extend a grammar; validate one eagerly with
Grammar.validate. The built-in grammars use exactly this API.
Classes
- Annotation
-
Annotations, attributes and decorators, such as
@overrideor@app.route. - BlockComment
-
A comment between open and close, such as
/*and*/. - BlockRule
- A reusable rule that expands into basic rules when the grammar is compiled.
- CommonRules
- Common heuristics for identifiers that are not keywords, for use in KeywordRule.otherwise.
- Detection
- A detected language and how confident the detector is.
- Grammar
- A language grammar: an ordered list of Rules plus a named repository of reusable rule lists.
- Highlighter
- Highlights source code.
- HighlightResult
- The output of highlighting: code split into contiguous tokens.
- HighlightToken
- A lightweight view of one token in a HighlightResult.
- HtmlRenderer
- Renders a HighlightResult as HTML.
- IncludeRule
- Inserts the rules of a Grammar.repository entry in place.
- IncrementalHighlighter
- Keeps a document highlighted as it is edited, re-scanning only what an edit can affect.
- Interpolation
-
An interpolated expression inside a string, such as
${…}or#{…}. - KeywordRule
- Matches words with word and scopes them by table lookup.
- LanguageDetector
- Guesses the language of a piece of code.
- LanguageRegistry
- Languages addressable by name, alias or file extension.
- LineComment
-
A comment from start to the end of the line, such as
//or#. - Numbers
- Numeric literals: decimals, floats with exponents, and hexadecimal, binary and octal forms.
- Operators
-
Runs of operator characters, such as
+,==or>>=. - Preprocessor
-
Preprocessor lines such as
#include <x>or#define X 1, including lines continued with a trailing backslash. - QuotedString
- A string between quote and end (default: quote).
- RegionRule
- A region that starts at begin and ends at end, with its own rules active in between.
- Rule
- A single grammar rule.
- Scopes
- Standard scope names used by the built-in grammars and themes.
- ScopeTable
- Interned scope names and scope stacks for one highlight result.
- Style
- Visual style for one scope. Unset fields inherit from the enclosing scope.
- TokenRule
- Matches pattern and marks the match with scope.
- ValTheme
- A color theme: a root style plus a style per scope.
Functions
Exceptions / Errors
- GrammarException
- Thrown when a grammar is invalid: a bad pattern, an unknown include or an include cycle.
- UnknownLanguageException
- Thrown when a language name is not registered.