Syntax Color: Utilities
The "syntax-color" collection provides the underlying data structures and some helpful utilities for the color:text% class of the Framework: PLT GUI Application Framework.
1 Parenthesis Matching
superclass: object%  | 
Parenthesis matching code built on top of token-tree%.
2 Scheme Lexer
  | ||||||||||
in : input-port?  | 
A lexer for Scheme, including reader extensions (Reader Extension), built specifically for color:text%.
The scheme-lexer function returns 5 values:
Either a string containing the matching text or the eof object. Block comments and specials currently return an empty string. This may change in the future to other string or non-string data.
A symbol in '(error comment sexp-comment white-space constant string no-color parenthesis other symbol eof).
A symbol in '(|(| |)| |[| |]| |{| |}|) or #f.
A number representing the starting position of the match (or #f if eof).
A number representing the ending position of the match (or #f if eof).
3 Default lexer
  | ||||||||||
in : input-port?  | 
A lexer that only identifies (, ), [, ], {, and } built specifically for color:text%.
default-lexer returns 5 values:
Either a string containing the matching text or the eof object. Block specials currently return an empty string. This may change in the future to other string or non-string data.
A symbol in '(comment white-space no-color eof).
A symbol in '(|(| |)| |[| |]| |{| |}|) or #f.
A number representing the starting position of the match (or #f if eof).
A number representing the ending position of the match (or #f if eof).
4 Splay Tree for Tokenization
superclass: object%  | 
A splay-tree class specifically geared for the task of on-the-fly tokenization. Instead of keying nodes on values, each node has a length, and they are found by finding a node that follows a certain total length of preceding nodes.
FIXME: many methods are not yet documented.
(new token-tree% [len len] [data data])
→ (is-a?/c token-tree%)
len : (or/c exact-nonnegative-integer? fasle/c)
data : any/c
Creates a token tree with a single element.
Returns the root node in the tree.
key-position : natural-number/c
Splays, setting the root node to be the closest node to offset key-position (i.e., making the total length of the left tree at least key-position, if possible).
  | ||
  | ||
  | ||
  | ||
  | ||
  | 
Functions for working with nodes in a token-tree%.
(insert-first! tree1 tree2) → void?  | 
tree1 : (is-a?/c token-tree%)  | 
tree2 : (is-a?/c token-tree%)  | 
Inserts tree1 into tree2 as the first thing, setting tree2’s root to #f.
(insert-last! tree1 tree2) → void?  | 
tree1 : (is-a?/c token-tree%)  | 
tree2 : (is-a?/c token-tree%)  | 
Inserts tree1 into tree2 as the last thing, setting tree2’s root to #f.
(insert-last-spec! tree n v) → void?  | 
tree : (is-a?/c token-tree%)  | 
n : natural-number/c  | 
v : any/c  | 
Same as (insert-last! tree (new token-tree% [length n] [data v])). This optimization is important for the colorer.