public Tk(int iline, int icol_start, int icol_end, TkType itype, int iindent, Tk iparent = null) { line = iline; col_start = icol_start; col_end = icol_end; type = itype; indent = iindent; parent = iparent; }
public bool TkTypeToTokenInfo(TokenInfo token_info, Tk tk) { //NSScanState flags = (NSScanState)state; //Debug.Print("ScanTokenAndProvideInfoAboutIt " + DateTime.Now.Second.ToString()); //Debug.Print("ScanTokenAndProvideInfoAboutIt " + DateTime.Now.Millisecond.ToString()); switch (tk.type) { case TkType.EOL: token_info.StartIndex = -1; return(false); // end of line case TkType.None: token_info.Type = TokenType.Unknown; token_info.Color = (VSTkColor)TokenColor.Text; break; case TkType.Space: token_info.Type = TokenType.WhiteSpace; token_info.Color = (VSTkColor)TokenColor.Text; break; case TkType.NumberInt: case TkType.NumberBin: case TkType.NumberHex: case TkType.NumberOct: case TkType.NumberFloat: token_info.Type = TokenType.Literal; token_info.Color = (VSTkColor)TokenColor.Number; break; case TkType.Identifier: token_info.Type = TokenType.Identifier; token_info.Color = (VSTkColor)TokenColor.Identifier; break; case TkType.Keyword: token_info.Type = TokenType.Keyword; token_info.Color = (VSTkColor)TokenColor.Keyword; break; case TkType.DataType: token_info.Type = TokenType.Unknown; token_info.Color = (VSTkColor)TokenColor.DataType; break; case TkType.Procedure: token_info.Type = TokenType.Unknown; token_info.Color = (VSTkColor)TokenColor.Procedure; break; case TkType.StringLit: token_info.Type = TokenType.String; token_info.Color = (VSTkColor)TokenColor.String; //if (!flags.HasFlag(NSScanState.StringLitRaw)) { // flags ^= NSScanState.StringLit; //} break; case TkType.StringLitLong: token_info.Type = TokenType.String; token_info.Color = (VSTkColor)TokenColor.String; //flags ^= NSScanState.StringLitRaw; break; case TkType.CharLit: token_info.Type = TokenType.String; token_info.Color = (VSTkColor)TokenColor.String; break; case TkType.Escape: token_info.Type = TokenType.Unknown; token_info.Color = (VSTkColor)TokenColor.Text; break; case TkType.Operator: token_info.Type = TokenType.Operator; token_info.Color = (VSTkColor)TokenColor.Punctuation; break; case TkType.Punctuation: case TkType.Star: token_info.Type = TokenType.Text; token_info.Color = (VSTkColor)TokenColor.Punctuation; break; case TkType.Comment: token_info.Type = TokenType.Comment; token_info.Color = (VSTkColor)TokenColor.Comment; break; case TkType.CommentLong: token_info.Type = TokenType.LineComment; token_info.Color = (VSTkColor)TokenColor.Comment; break; case TkType.RegEx: case TkType.TagStart: case TkType.TagEnd: case TkType.Key: case TkType.Value: case TkType.RawData: case TkType.Assembler: case TkType.Preprocessor: case TkType.Directive: case TkType.Command: case TkType.Rule: case TkType.Hyperlink: case TkType.Label: case TkType.Reference: case TkType.Other: token_info.Type = TokenType.Unknown; token_info.Color = (VSTkColor)TokenColor.Text; break; case TkType.CurlyDotLeft: case TkType.CurlyDotRight: case TkType.BracketLeft: case TkType.BracketRight: token_info.Type = TokenType.Delimiter; token_info.Color = (VSTkColor)TokenColor.Punctuation; break; case TkType.Dot: token_info.Type = TokenType.Operator; token_info.Color = (VSTkColor)TokenColor.Punctuation; token_info.Trigger = TokenTriggers.MemberSelect; break; case TkType.ParenLeft: token_info.Type = TokenType.Delimiter; token_info.Color = (VSTkColor)TokenColor.Punctuation; token_info.Trigger = TokenTriggers.ParameterStart; break; case TkType.ParenRight: token_info.Type = TokenType.Delimiter; token_info.Color = (VSTkColor)TokenColor.Punctuation; token_info.Trigger = TokenTriggers.ParameterEnd; break; case TkType.Comma: token_info.Type = TokenType.Text; token_info.Color = (VSTkColor)TokenColor.Punctuation; token_info.Trigger = TokenTriggers.ParameterNext; break; } //if (flags.HasFlag(NSScanState.StringLit) || flags.HasFlag(NSScanState.StringLitRaw)) { // token_info.Color = (VSTkColor)TokenColor.String; // token_info.Type = TokenType.String; //} //state = (int)flags; //token_info.StartIndex = m_tokenpos_start; //token_info.EndIndex = m_tokenpos_start_next-1; token_info.StartIndex = tk.col_start; token_info.EndIndex = tk.col_end; //Debug.WriteLine("$" + m_source.Substring( m_tokenpos_start,m_tokenpos_start_next - //m_tokenpos_start) + "$" + m_token_type); //TokenNextGet(flags); return(true); }
public void Add(int line, int col_start, int col_end, TkType type, int indent, Tk parent = null) { if (line >= m_arr.Count) { m_arr.Add(new List <Tk>()); } m_arr[line].Add(new Tk(line, col_start, col_end, type, indent, parent)); tk_tot++; }