[svn] r6754: nemerle/trunk/ncc/parsing/Lexer.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Uti...
IT
svnadmin at nemerle.org
Thu Oct 12 06:23:04 CEST 2006
Log:
Start working on ScanLexer (colorizer).
Author: IT
Date: Thu Oct 12 06:22:53 2006
New Revision: 6754
Added:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenColor.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenTriggers.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenType.n
Modified:
nemerle/trunk/ncc/parsing/Lexer.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs
Modified: nemerle/trunk/ncc/parsing/Lexer.n
==============================================================================
--- nemerle/trunk/ncc/parsing/Lexer.n (original)
+++ nemerle/trunk/ncc/parsing/Lexer.n Thu Oct 12 06:22:53 2006
@@ -64,6 +64,7 @@
| EndQuote // ]>
| Indent { value : string; }
+ | WhiteSpace { value : string; }
| RoundGroup { Child : Token; } // ( ... )
| BracesGroup { Child : Token; } // { ... }
@@ -302,14 +303,15 @@
/** if there was only white chars from beginnig of line */
protected mutable white_beginning : bool;
- mutable eating_stack : Stack[int]; // stack of nested #if
+ protected mutable eating_stack : Stack[int]; // stack of nested #if
/** -1 = now inside true preprocessing section
0 = no preprocessing currently in action
1 = there were no true preprocessing sections in this set
2 = there already was true preprocessing section in this set
3 = we are now inside #else section, but it is not analyzed */
- mutable eating_now : int;
+ protected mutable eating_now : int;
+
mutable line_stack : int; // real line number at moment of `#line 3' occurence
mutable line_start : int; // how to compute real line after `#line default' occurence
protected file_real : string; // real filename to revert after `#line 4 "bla"'
@@ -877,6 +879,8 @@
def ch =
try { peek () }
catch { _ is LexerBase.Error => eof = true; '_' };
+ when (ch == '\0')
+ eof = true;
if (eof) {
if (eating_now > 0) {
Message.Error (this.Location, "unexpected end of file"
@@ -1594,7 +1598,7 @@
public class LexerString : LexerBase
{
- reader : string;
+ protected mutable reader : string;
protected mutable pos : int;
public this (man : ManagerClass, fn : string, loc : Location)
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj Thu Oct 12 06:22:53 2006
@@ -128,6 +128,24 @@
<ItemGroup>
<Compile Include="Nemerle.Completion2\CodeModel\ExprWalkInfo.n" />
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\CodeModel\ScanLexer.n" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\CodeModel\ScanState.n" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\CodeModel\ScanTokenInfo.n" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\CodeModel\ScanTokenColor.n" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\CodeModel\ScanTokenTriggers.n" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\CodeModel\ScanTokenType.n" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n Thu Oct 12 06:22:53 2006
@@ -76,6 +76,8 @@
def token = findIdentifier(prev);
+ when (token != null)
+ {
_startName = token.Location;
_startParameters = group.Location;
@@ -85,10 +87,12 @@
group.Location.FileIndex,
group.Location.EndLine,
if (group.Location.EndColumn > 1) group.Location.EndColumn - 1 else group.Location.EndColumn);
-
+ }
| _ => ()
}
+ when (HasTip)
+ {
// TODO: This works incorrectly and should be redone.
//
_defaultMethod = _methods.FindIndex(m => m.GetParameters().Length == _nextParameters.Count + 1);
@@ -96,6 +100,12 @@
when (_defaultMethod < 0)
_defaultMethod = 0;
}
+ }
+
+ public HasTip : bool
+ {
+ get { _startName.EndLine > 0 }
+ }
public GetCount() : int
{
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n Thu Oct 12 06:22:53 2006
@@ -243,7 +243,13 @@
| _ => ()
}
- if (members.Count > 0) MethodTipInfo(members, tokens) else (null)
+ if (members.Count > 0)
+ {
+ def tip = MethodTipInfo(members, tokens);
+ if (tip.HasTip) (tip) else (null)
+ }
+ else
+ (null)
}
else (null)
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n Thu Oct 12 06:22:53 2006
@@ -0,0 +1,151 @@
+using System;
+using System.Collections.Generic;
+
+using Nemerle.Collections;
+using Nemerle.Compiler;
+
+using TP = Nemerle.Completion2.ScanTokenType;
+using C = Nemerle.Completion2.ScanTokenColor;
+using TR = Nemerle.Completion2.ScanTokenTriggers;
+
+namespace Nemerle.Completion2
+{
+ public class ScanLexer : LexerString
+ {
+ public this(manager : ManagerClass)
+ {
+ base(manager, "", Location());
+
+ Keywords = manager.CoreEnv.Keywords;
+ }
+
+ public SetLine(line : string, offset : int) : void
+ {
+ base.reader = line;
+ base.pos = offset;
+ base.line = 1;
+ base.col = 1;
+ base.isPendingChar = false;
+ base.white_beginning = true;
+ base.eating_stack = Stack();
+ base.eating_now = 0;
+
+ _tokenInfo.Token = null;
+ }
+
+ _tokenInfo : ScanTokenInfo = ScanTokenInfo();
+
+ static _types : Dictionary[string,string] = Dictionary();
+
+ static this()
+ {
+ foreach (name in
+ ["object", "bool", "byte", "float", "uint", "char", "ulong", "ushort",
+ "decimal", "int", "sbyte", "short", "double", "long", "string", "void"])
+ {
+ _types.Add(name, name);
+ }
+ }
+
+ private GetWhiteSpaceToken() : Token
+ {
+ mutable str = "";
+
+ def wsloop(c)
+ {
+ when (pos < reader.Length)
+ {
+ match (c)
+ {
+ | ' ' | '\t' | '\r' | '\n' => str += c.ToString(); wsloop(read());
+ | _ => pos--; col--;
+ }
+ }
+ }
+
+ def last_line = line;
+ def last_col = col;
+
+ wsloop(read());
+
+ def tok = Token.WhiteSpace(str);
+
+ tok.Location = Location (file_idx, last_line, last_col, line, col);
+
+ tok
+ }
+
+ public GetToken(prevState : ScanState) : ScanTokenInfo
+ {
+ _tokenInfo.ScanState = prevState;
+
+ def prevToken = _tokenInfo.Token;
+
+ (_tokenInfo.Type, _tokenInfo.Color, _tokenInfo.Triggers) =
+ match (peek())
+ {
+ | ' ' | '\t' | '\n' | '\r' =>
+
+ _tokenInfo.Token = GetWhiteSpaceToken();
+
+ (
+ TP.WhiteSpace,
+ C.Text,
+ if (pos+1 >= reader.Length && (_tokenInfo.Token :> Token.WhiteSpace).value == "")
+ match (prevToken)
+ {
+ | Keyword (name) when name == "using"
+ | Operator(name) when name == "|" => TR.MemberSelect
+ | _ => TR.None
+ }
+ else
+ TR.None
+ )
+
+ | _ =>
+
+ _tokenInfo.Token = base.GetToken();
+
+ match (_tokenInfo.Token)
+ {
+ | Identifier(nm) when _types.ContainsKey(nm)
+ | Keyword => (TP.Keyword, C.Keyword, TR.None)
+ | Identifier
+ | IdentifierToComplete => (TP.Identifier, C.Identifier, TR.None)
+ | Comma => (TP.Operator, C.Operator, TR.ParameterNext)
+ | Operator(n) when n == "." => (TP.Delimiter, C.Operator, TR.MemberSelect)
+ | Semicolon
+ | Operator => (TP.Operator, C.Operator, TR.None)
+ | StringLiteral => (TP.String, C.String, TR.None)
+ | CharLiteral => (TP.Literal, C.String, TR.None)
+ | IntegerLiteral
+ | FloatLiteral
+ | DoubleLiteral
+ | DecimalLiteral => (TP.Literal, C.Number, TR.None)
+ | Comment => (TP.Comment, C.Comment, TR.None)
+ | Indent
+ | WhiteSpace => (TP.WhiteSpace, C.Text, TR.None)
+ | BeginRound /* ( */ => (TP.Operator, C.Operator, TR.MatchBraces | TR.ParameterStart)
+ | EndRound /* ) */ => (TP.Operator, C.Operator, TR.MatchBraces | TR.ParameterEnd)
+ | BeginBrace /* { */
+ | EndBrace /* } */
+ | BeginSquare /* [ */
+ | EndSquare /* ] */ => (TP.Operator, C.Operator, TR.MatchBraces)
+ | BeginQuote /* <[ */
+ | EndQuote /* ]> */
+ | RoundGroup // { Child : Token; } // ( ... )
+ | BracesGroup // { Child : Token; } // { ... }
+ | SquareGroup // { mutable Child : Token; } // [ ... ]
+ | QuoteGroup // { Child : Token; } // <[ ... ]>
+ | LooseGroup // { mutable Child : Token; } // ; ... ;
+ | Namespace // { Env : GlobalEnv; Body : Token; }
+ | Using // { Env : GlobalEnv; }
+ | EndOfFile
+ | EndOfGroup => (TP.Unknown, C.Text, TR.None)
+ }
+ }
+
+ _tokenInfo
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n Thu Oct 12 06:22:53 2006
@@ -0,0 +1,11 @@
+using System;
+
+namespace Nemerle.Completion2
+{
+ [Flags]
+ public enum ScanState
+ {
+ | None = 0x0000
+ | Comment = 0x0001
+ }
+}
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenColor.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenColor.n Thu Oct 12 06:22:53 2006
@@ -0,0 +1,17 @@
+using System;
+
+namespace Nemerle.Completion2
+{
+ public enum ScanTokenColor
+ {
+ // The first 6 items in this list MUST be these default items.
+ | Text = 0
+ | Keyword = 1
+ | Comment = 2
+ | Identifier = 3
+ | String = 4
+ | Number = 5
+
+ | Operator
+ }
+}
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n Thu Oct 12 06:22:53 2006
@@ -0,0 +1,21 @@
+using System;
+
+using Nemerle.Compiler;
+using Nemerle.Utility;
+
+namespace Nemerle.Completion2
+{
+ public class ScanTokenInfo
+ {
+ [Accessor(flags=WantSetter)] mutable _token : Token;
+ [Accessor(flags=WantSetter)] mutable _scanState : ScanState;
+ [Accessor(flags=WantSetter)] mutable _color : ScanTokenColor;
+ [Accessor(flags=WantSetter)] mutable _triggers : ScanTokenTriggers;
+ [Accessor(flags=WantSetter)] mutable _type : ScanTokenType;
+
+ public IsEndOfLine : bool
+ {
+ get { match (_token) { | EndOfFile => true | _ => false } }
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenTriggers.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenTriggers.n Thu Oct 12 06:22:53 2006
@@ -0,0 +1,17 @@
+using System;
+
+namespace Nemerle.Completion2
+{
+ [Flags]
+ public enum ScanTokenTriggers
+ {
+ | None = 0x00
+ | MemberSelect = 0x01
+ | MatchBraces = 0x02
+ | MethodTip = 0xF0
+ | ParameterStart = 0x10
+ | ParameterNext = 0x20
+ | ParameterEnd = 0x40
+ | Parameter = 0x80
+ }
+}
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenType.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenType.n Thu Oct 12 06:22:53 2006
@@ -0,0 +1,19 @@
+using System;
+
+namespace Nemerle.Completion2
+{
+ public enum ScanTokenType
+ {
+ | Unknown = 0
+ | Text = 1
+ | Keyword = 2
+ | Identifier = 3
+ | String = 4
+ | Literal = 5
+ | Operator = 6
+ | Delimiter = 7
+ | WhiteSpace = 8
+ | LineComment = 9
+ | Comment = 10
+ }
+}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs Thu Oct 12 06:22:53 2006
@@ -100,7 +100,7 @@
return info.FilePath;
}
- if (null != info.Member && !string.IsNullOrEmpty(info.FilePath))
+ if (info.Member != null && !string.IsNullOrEmpty(info.FilePath))
{
Guid mdiGuid = new Guid("7DAC8207-D3AE-4c75-9B67-92801A497D44");
IntPtr mdiPtr = IntPtr.Zero;
@@ -121,17 +121,16 @@
{
ISymbolDocument[] documents = new ISymbolDocument[1];
int[] lines = new int[1];
- int[] offsets = new int[1];
int[] columns = new int[1];
int[] endLines = new int[1];
int[] endColumns = new int[1];
- method.GetSequencePoints(offsets, documents, lines, columns, endLines, endColumns);
+ method.GetSequencePoints(new int[1], documents, lines, columns, endLines, endColumns);
span.iStartLine = lines[0] - 1;
span.iEndLine = endLines[0] - 1;
span.iStartIndex = columns[0] - 1;
- span.iEndIndex = endColumns[0] - 1;
+ span.iEndIndex = columns[0] - 1;
return documents[0].URL;
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs Thu Oct 12 06:22:53 2006
@@ -66,7 +66,6 @@
}
LanguagePreferences _preferences;
- NemerleScanner _scanner;
Dictionary<IVsTextView, NemerleSource> _specialSources = new Dictionary<IVsTextView, NemerleSource>();
// This array contains the definition of the colorable items provided by
@@ -146,9 +145,7 @@
public override IScanner GetScanner(IVsTextLines buffer)
{
- if (_scanner == null)
- _scanner = new NemerleScanner();
- return _scanner;
+ return new NemerleScanner(this, buffer);
}
#region ParseSource
@@ -292,8 +289,17 @@
if (projectInfo == null)
return null;
+ int col = request.Col;
+
+ if (request.TokenInfo != null &&
+ (request.TokenInfo.Trigger & TokenTriggers.ParameterStart) == TokenTriggers.ParameterStart &&
+ request.Col == request.TokenInfo.StartIndex)
+ {
+ col++;
+ }
+
NemerleMethods methods = projectInfo.GetMethodTip(
- request.FileName, request.Line, request.Col, new SourceTextManager(this, request.View));
+ request.FileName, request.Line, col, new SourceTextManager(this, request.View));
if (methods != null)
{
Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs Thu Oct 12 06:22:53 2006
@@ -1,155 +1,75 @@
using System;
using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.TextManager.Interop;
using Nemerle.Compiler;
+using Nemerle.Completion2;
+
+using Nemerle.VisualStudio.Project;
namespace Nemerle.VisualStudio.LanguageService
{
class NemerleScanner : IScanner
{
- static LexerHack _Root = new LexerHack();
-
- public NemerleScanner()
+ public NemerleScanner(NemerleLanguageService languageService, IVsTextLines buffer)
{
- _lexer = _Root.lexer;
+ _languageService = languageService;
+ _buffer = buffer;
}
- private LexerColorizer _lexer;
- private string _source;
- private LexerColorizer.SyntaxToken _prevToken;
+ private NemerleLanguageService _languageService;
+ private IVsTextLines _buffer;
- enum TC
+ private ScanLexer _lexer;
+ private ScanLexer GetLexer()
{
- Text = TokenColor.Text,
- Keyword = TokenColor.Keyword,
- Comment = TokenColor.Comment,
- Identifier = TokenColor.Identifier,
- String = TokenColor.String,
- Number = TokenColor.Number,
- Operator = 7,
- }
-
- // Its calling depends on IVsColorizer.GetStateMaintenanceFlag, which defaults to true.
- //
- public bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state)
+ if (_lexer == null)
{
- LexerColorizer.SyntaxToken token = _lexer.GetSyntaxToken(ref state);
+ Source source = _languageService.GetSource(_buffer);
- // TokenInfo is only read in *.LanguageService.dll
- //
- tokenInfo.Trigger = TokenTriggers.None;
- tokenInfo.StartIndex = token.StartPos;
- tokenInfo.EndIndex = token.EndPos;
+ if (source == null)
+ return null;
- //TODO: it has to handle # (pragma, region, etc)
+ ProjectInfo projectInfo = ProjectInfo.FindProject(source.GetFilePath());
- switch (token.Token)
- {
- case SyntaxType.WhiteSpace:
- tokenInfo.Color = TokenColor.Text;
- tokenInfo.Type = TokenType. WhiteSpace;
+ if (projectInfo == null)
+ return null;
- if (_prevToken != null) switch (_prevToken.Token)
- {
- case SyntaxType.Keyword:
- if (_source == "using ")
- tokenInfo.Trigger = TokenTriggers.MemberSelect;
-
- break;
-
- case SyntaxType.Operator:
- switch (_source[_prevToken.StartPos])
- {
- case '|': tokenInfo.Trigger = TokenTriggers.MemberSelect; break;
+ _lexer = new ScanLexer(projectInfo.Engine);
}
- break;
+ return _lexer;
}
- break;
-
- case SyntaxType.OperatorBrace:
- tokenInfo.Color = (TokenColor)TC.Operator;
- tokenInfo.Type = TokenType.Operator;
- tokenInfo.Trigger = TokenTriggers.MatchBraces;
-
- switch (_source[token.StartPos])
+ // Its calling depends on IVsColorizer.GetStateMaintenanceFlag, which defaults to true.
+ //
+ public bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state)
{
- case '(': tokenInfo.Trigger |= TokenTriggers.ParameterStart; break;
- //case ')': tokenInfo.Trigger |= TokenTriggers.ParameterEnd; break;
- }
-
- break;
-
- case SyntaxType.Operator:
- tokenInfo.Color = (TokenColor)TC.Operator;
- tokenInfo.Type = TokenType.Operator;
-
- //switch (_source[token.StartPos])
- //{
- // case ',': tokenInfo.Trigger |= TokenTriggers.ParameterNext; break;
- //}
-
- break;
-
- case SyntaxType.OperatorDot:
- tokenInfo.Color = (TokenColor)TC.Operator;
- tokenInfo.Type = TokenType.Operator;
- tokenInfo.Trigger = TokenTriggers.MemberSelect;
- break;
-
- case SyntaxType.Keyword:
- tokenInfo.Color = TokenColor.Keyword;
- tokenInfo.Type = TokenType .Keyword;
- break;
-
- case SyntaxType.Identifier:
- tokenInfo.Color = TokenColor.Identifier;
- tokenInfo.Type = TokenType. Identifier;
- break;
+ ScanLexer lexer = GetLexer();
- case SyntaxType.Comment:
- tokenInfo.Color = TokenColor.Comment;
- tokenInfo.Type = state == 0? TokenType.LineComment : TokenType.Comment;
- break;
-
- case SyntaxType.CharLiteral:
- tokenInfo.Color = TokenColor.String;
- tokenInfo.Type = TokenType. Literal;
- break;
-
- case SyntaxType.IntLiteral:
- case SyntaxType.FloatLiteral:
- tokenInfo.Color = TokenColor.Number;
- tokenInfo.Type = TokenType. Literal;
- break;
-
- case SyntaxType.StringLiteral:
- tokenInfo.Color = TokenColor.String;
- tokenInfo.Type = TokenType. String;
- break;
+ if (lexer == null)
+ return false;
- default:
- tokenInfo.Color = TokenColor.Text;
- tokenInfo.Type = TokenType. Text;
- break;
+ ScanTokenInfo info = lexer.GetToken((ScanState)state);
- case SyntaxType.EndOfFile:
- return false;
- }
+ state = (int)info.ScanState;
- _prevToken = token;
+ tokenInfo.Type = (TokenType) info.Type;
+ tokenInfo.Color = (TokenColor) info.Color;
+ tokenInfo.Trigger = (TokenTriggers)info.Triggers;
+ tokenInfo.StartIndex = info.Token.Location.Column - 1;
+ tokenInfo.EndIndex = info.Token.Location.EndColumn - 2;
- return true;
+ return !info.IsEndOfLine;;
}
- // The current implementation in *.LanguageService.dll always uses offset 0.
- //
public void SetSource(string source, int offset)
{
- _prevToken = null;
- _lexer.SetString(_source = source.Replace("#", ""), offset);
+ ScanLexer lexer = GetLexer();
+
+ if (lexer != null)
+ lexer.SetLine(source, offset);
}
}
}
More information about the svn
mailing list