Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ParadoxShaderTokenProvider.cs
Go to the documentation of this file.
1 #region Header Licence
2 // ---------------------------------------------------------------------
3 //
4 // Copyright (c) 2009 Alexandre Mutel and Microsoft Corporation.
5 // All rights reserved.
6 //
7 // This code module is part of NShader, a plugin for visual studio
8 // to provide syntax highlighting for shader languages (hlsl, glsl, cg)
9 //
10 // ------------------------------------------------------------------
11 //
12 // This code is licensed under the Microsoft Public License.
13 // See the file License.txt for the license details.
14 // More info on: http://nshader.codeplex.com
15 //
16 // ------------------------------------------------------------------
17 #endregion
18 using NShader.Lexer;
19 
20 namespace NShader
21 {
23  {
24  private static EnumMap<ShaderToken> map;
25 
27  {
28  map = new EnumMap<ShaderToken>();
29  map.Load("ParadoxShaderKeywords.map");
30  }
31 
32  public ShaderToken GetTokenFromSemantics(string text)
33  {
34  text = text.Replace(" ", "");
35  ShaderToken token;
36  if (!map.TryGetValue(text.ToUpper(), out token))
37  {
38  token = ShaderToken.IDENTIFIER;
39  }
40  return token;
41  }
42 
43  public ShaderToken GetTokenFromIdentifier(string text)
44  {
45  ShaderToken token;
46  if ( ! map.TryGetValue(text, out token ) )
47  {
48  token = ShaderToken.IDENTIFIER;
49  }
50  return token;
51  }
52  }
53 }