prettify.parser
Class Prettify.CreateSimpleLexer

java.lang.Object
  extended by prettify.parser.Prettify.CreateSimpleLexer
Enclosing class:
Prettify

public class Prettify.CreateSimpleLexer
extends java.lang.Object


Field Summary
protected  java.util.List<java.util.List<java.lang.Object>> fallthroughStylePatterns
           
protected  int nPatterns
           
protected  java.util.Map<java.lang.Character,java.util.List<java.lang.Object>> shortcuts
           
protected  java.util.regex.Pattern tokenizer
           
 
Constructor Summary
protected Prettify.CreateSimpleLexer(java.util.List<java.util.List<java.lang.Object>> shortcutStylePatterns, java.util.List<java.util.List<java.lang.Object>> fallthroughStylePatterns)
          Given triples of [style, pattern, context] returns a lexing function, The lexing function interprets the patterns to find token boundaries and returns a decoration list of the form [index_0, style_0, index_1, style_1, ..., index_n, style_n] where index_n is an index into the sourceCode, and style_n is a style constant like PR_PLAIN.
 
Method Summary
 void decorate(Job job)
          Lexes job.sourceCode and produces an output array job.decorations of style classes preceded by the position at which they start in job.sourceCode in order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fallthroughStylePatterns

protected java.util.List<java.util.List<java.lang.Object>> fallthroughStylePatterns

shortcuts

protected java.util.Map<java.lang.Character,java.util.List<java.lang.Object>> shortcuts

tokenizer

protected java.util.regex.Pattern tokenizer

nPatterns

protected int nPatterns
Constructor Detail

Prettify.CreateSimpleLexer

protected Prettify.CreateSimpleLexer(java.util.List<java.util.List<java.lang.Object>> shortcutStylePatterns,
                                     java.util.List<java.util.List<java.lang.Object>> fallthroughStylePatterns)
                              throws java.lang.Exception
Given triples of [style, pattern, context] returns a lexing function, The lexing function interprets the patterns to find token boundaries and returns a decoration list of the form [index_0, style_0, index_1, style_1, ..., index_n, style_n] where index_n is an index into the sourceCode, and style_n is a style constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to all characters in sourceCode[index_n-1:index_n]. The stylePatterns is a list whose elements have the form [style : string, pattern : RegExp, DEPRECATED, shortcut : string]. Style is a style constant like PR_PLAIN, or can be a string of the form 'lang-FOO', where FOO is a language extension describing the language of the portion of the token in $1 after pattern executes. E.g., if style is 'lang-lisp', and group 1 contains the text '(hello (world))', then that portion of the token will be passed to the registered lisp handler for formatting. The text before and after group 1 will be restyled using this decorator so decorators should take care that this doesn't result in infinite recursion. For example, the HTML lexer rule for SCRIPT elements looks something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match ' SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD