jagregory / boolangstudio forked from olsonjeffery/boolangstudio

Boo language integration for Visual Studio 2008

This URL has Read+Write access

boolangstudio / Source / BooLangService / BooScanner.cs
100644 78 lines (66 sloc) 1.756 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.Package;
using Microsoft.VisualStudio.TextManager.Interop;
using BooPegLexer;
 
namespace Boo.BooLangService
{
    public partial class BooScanner : IScanner
    {
        #region properties and members
        private ILexer __lexer = null;
public ILexer Lexer
{
get
{
return __lexer;
}
set
{
__lexer = value;
__lexer.Initialize(new string[] { }, new string[] { });
}
}
        #endregion
 
        /// <summary>
        /// empty ctor
        /// </summary>
        public BooScanner()
        {
         //
        }
 
        /// <summary>
        /// ctor that takes a lexer as an argument.. assume the lexer has
        /// already had it's PEGs bound...
        /// </summary>
        /// <param name="buffer"></param>
        public BooScanner(ILexer lexer)
        {
         Lexer = lexer;
        }
        
        public BooScanner(Microsoft.VisualStudio.TextManager.Interop.IVsTextLines buffer)
            : this()
        {
            //
        }
 
        #region lexer/colorizing-related
        
        PegToken pegToken = new PegToken();
        public bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state)
        {
         Lexer.NextToken(pegToken,ref state);
         TranslatePegToken(pegToken, tokenInfo);
            if (pegToken.Type == PegTokenType.EOL)
                return false;
        
         return true;
        }
 
        public void SetSource(string source, int offset)
        {
         Lexer.SetSource(source.Substring(offset));
        }
        
        #endregion
 
    }
 
}