summaryrefslogtreecommitdiff
path: root/external/aspnetwebstack/src/System.Web.Razor/Parser/VBLanguageCharacteristics.cs
blob: a774f29b7b4a18bfa9f3e7556483631ad7d2feb7 (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Web.Razor.Parser.SyntaxTree;
using System.Web.Razor.Text;
using System.Web.Razor.Tokenizer;
using System.Web.Razor.Tokenizer.Symbols;

namespace System.Web.Razor.Parser
{
    public class VBLanguageCharacteristics : LanguageCharacteristics<VBTokenizer, VBSymbol, VBSymbolType>
    {
        private static readonly VBLanguageCharacteristics _instance = new VBLanguageCharacteristics();

        private VBLanguageCharacteristics()
        {
        }

        public static VBLanguageCharacteristics Instance
        {
            get { return _instance; }
        }

        public override VBTokenizer CreateTokenizer(ITextDocument source)
        {
            return new VBTokenizer(source);
        }

        public override string GetSample(VBSymbolType type)
        {
            return VBSymbol.GetSample(type);
        }

        public override VBSymbolType FlipBracket(VBSymbolType bracket)
        {
            switch (bracket)
            {
                case VBSymbolType.LeftBrace:
                    return VBSymbolType.RightBrace;
                case VBSymbolType.LeftBracket:
                    return VBSymbolType.RightBracket;
                case VBSymbolType.LeftParenthesis:
                    return VBSymbolType.RightParenthesis;
                case VBSymbolType.RightBrace:
                    return VBSymbolType.LeftBrace;
                case VBSymbolType.RightBracket:
                    return VBSymbolType.LeftBracket;
                case VBSymbolType.RightParenthesis:
                    return VBSymbolType.LeftParenthesis;
                default:
                    return VBSymbolType.Unknown;
            }
        }

        public override VBSymbol CreateMarkerSymbol(SourceLocation location)
        {
            return new VBSymbol(location, String.Empty, VBSymbolType.Unknown);
        }

        public override VBSymbolType GetKnownSymbolType(KnownSymbolType type)
        {
            switch (type)
            {
                case KnownSymbolType.CommentStart:
                    return VBSymbolType.RazorCommentTransition;
                case KnownSymbolType.CommentStar:
                    return VBSymbolType.RazorCommentStar;
                case KnownSymbolType.CommentBody:
                    return VBSymbolType.RazorComment;
                case KnownSymbolType.Identifier:
                    return VBSymbolType.Identifier;
                case KnownSymbolType.Keyword:
                    return VBSymbolType.Keyword;
                case KnownSymbolType.NewLine:
                    return VBSymbolType.NewLine;
                case KnownSymbolType.Transition:
                    return VBSymbolType.Transition;
                case KnownSymbolType.WhiteSpace:
                    return VBSymbolType.WhiteSpace;
                default:
                    return VBSymbolType.Unknown;
            }
        }

        protected override VBSymbol CreateSymbol(SourceLocation location, string content, VBSymbolType type, IEnumerable<RazorError> errors)
        {
            return new VBSymbol(location, content, type, errors);
        }
    }
}