Library
Module
Module type
Parameter
Class
Class type
type plist = [
| `Bool of bool
| `Data of string
| `Date of float * float option
| `Float of float
| `Int of int
| `String of string
| `Array of plist list
| `Dict of (string * plist) list
]
A plist document. This is the same plist type that is defined in the plist-xml
package (as of version 0.3.0), but is reproduced here as not to depend on plist-xml
.
val create : unit -> t
Create an empty collection of grammars.
Finds a grammar by its name
attribute. Case-insensitive.
Finds for a grammar by its scopeName
attribute. Case-sensitive.
Reads a TextMate grammar from a plist file. Raises Error
if the plist does not represent a valid TextMate grammar.
val empty : stack
The initial state of the code highlighter.
val ending : token -> int
One past the index of the last character of the token.
If tok
is the first token of the line, tok
spans the substring within interval [0
, ending tok
). If tok
succeeds a token prev
, tok
spans the substring within interval [ending prev
, ending tok
).
val scopes : token -> string list
The token's stack of TextMate grammar scopes.
Usage: let tokens, stack = tokenize_exn t grammar stack line
Tokenizes a line of code. Returns the list of tokens tokens
and the updated tokenization state stack
.
Precondition:
line
must be a single line, including the newline character at the end.Postconditions:
tokens
is nonempty.ending
of the last token in tokens
is always String.length line
.Raises Error
if it tries to match a malformed end
or while
regex.
Raises Error
if it tries to access a local repository that doesn't exist in the file. Currently, it silently ignores include
s of other grammars that don't exist in t
.