public IncrementalHighlighter(Highlighter highlighter)
 {
     highlightingParser = new HighlightingParser(highlighter);
     var context = new CompilationContext();
     tokenizer = context.CreateTokenizer(
         token => highlightingParser.OnToken(token),
         () => highlightingParser.OnDone(),
         () => {}
     );
 }
Exemplo n.º 2
0
 public virtual Tokenizer HandleTokenError(Tokenizer tokenizer, CompilationError<TokenizationError> error)
 {
     return tokenizer;
 }
 public override Tokenizer HandleTokenError(Tokenizer tokenizer, CompilationError<TokenizationError> error)
 {
     if(error.Error == TokenizationError.UnexpectedRightCurlyBracket) {
         interpolationTokenizer.endColumn = error.Location.Column;
         interpolationTokenizer.justUninterpolated = true;
         tokenizer.OnDone();
         return interpolationTokenizer;
     } else {
         return ParentContext.HandleTokenError(tokenizer, error);
     }
 }
Exemplo n.º 4
0
 public Tokenizer OnError(Tokenizer tokenizer, Location location, TokenizationError error)
 {
     return OnError(tokenizer, new CompilationError<TokenizationError>(location, error));
 }
Exemplo n.º 5
0
 public Tokenizer OnError(Tokenizer tokenizer, CompilationError<TokenizationError> error)
 {
     return compilationContext.HandleTokenError(tokenizer, error);
 }
 public void Tokenize(Character character)
 {
     tokenizer = tokenizer.Tokenize(character);
     highlightingParser.OnLocation(character.Location);
 }
Exemplo n.º 7
0
 public void Tokenize(Character character)
 {
     if(tokenizer != null) {
         tokenizer = tokenizer.Tokenize(character);
     } else if(character.Char == '\t') {
         indentation = indentation + 1;
     } else {
         parser = compilationContext.CreateParser(source => source(syntaxifier));
         tokenizer = compilationContext.CreateTokenizer(
             token => this.token = token,
             () => parser = token(parser),
             OnLine,
             compilationContext);
         tokenizer = tokenizer.Tokenize(character);
     }
 }
Exemplo n.º 8
0
 void OnLine()
 {
     tokenizer = null;
     indentation = 0;
     parser.OnDone();
 }