Example #1
0
        public static TextStyle From(Token token, CompilerBrowser compiler)
        {
            try
            {
                if(token.IsError)
                    return Error;
                if(token.IsBraceLike && compiler.FindAllBelongings(token).Skip(1).Any())
                    return token.IsBrace ? Brace : BraceLikeKeyWord;
                if(token.IsKeyword)
                    return KeyWord;
                if(token.IsComment || token.IsLineComment)
                    return Comment;
                if(token.IsNumber)
                    return Number;
                if(token.IsText)
                    return Text;

                return Default;
            }
            catch(Exception)
            {
                return Error;
            }
        }
Example #2
0
 internal Trimmed(Token token, SourcePart sourcePart)
 {
     Token = token;
     SourcePart = sourcePart.Intersect(Token.SourcePart)
         ?? Token.SourcePart.Start.Span(0);
 }
Example #3
0
 internal IEnumerable<SourcePart> BracesLike(Token current)
     => Compiler.FindAllBelongings(current);
Example #4
0
 bool Equals(Token other) => SourcePart == other.SourcePart;