1 module ppsl.tokens; 2 enum Tokens { 3 Unrecognized, 4 EOF, 5 Whitespace, 6 7 StStartStatement, 8 StEndStatement, 9 StEnd, 10 11 KwTechnique, 12 KwGLSL, 13 KwPreAttrib, 14 15 KwSelect, 16 KwVertex, 17 KwFragment, 18 KwTotal, 19 20 KwHdShader, 21 KwHdVersion, 22 KwHdName, 23 KwHdAttribs, 24 KwHdVertex, 25 KwHdFragment, 26 27 Identifier, 28 ConstDecimal, 29 GlIn, 30 GlOut, 31 GlInOut, 32 GlUniform, 33 GlPrecision, 34 GlHighp, 35 GlReturn, 36 37 GlVoid, 38 GlFloat, 39 GlVec2, 40 GlVec3, 41 GlVec4, 42 GlMat, 43 GlMat2x2, 44 GlMat2x3, 45 GlMat2x4, 46 GlMat3x2, 47 GlMat3x3, 48 GlMat3x4, 49 GlMat4x2, 50 GlMat4x3, 51 GlMat4x4, 52 53 54 55 } 56 57 struct TokenWord { 58 string Word; 59 int Length; 60 Tokens Type; 61 } 62 63 class Token { 64 TokenWord Word; 65 string Content; 66 } 67 68 private static TokenWord defineToken(string name, Tokens type) { 69 return TokenWord(name, cast(int)name.length, type); 70 } 71 72 public static TokenWord[] WORDS = [ 73 defineToken(" \t\r\n", Tokens.Whitespace), 74 defineToken("{", Tokens.StStartStatement), 75 defineToken("}", Tokens.StEndStatement), 76 defineToken(";", Tokens.StEnd), 77 defineToken("technique", Tokens.KwTechnique), 78 defineToken("version", Tokens.KwTechnique), 79 defineToken("glsl", Tokens.KwGLSL), 80 defineToken("cg", Tokens.KwGLSL), 81 defineToken("name", Tokens.KwHdName), 82 defineToken("select", Tokens.KwSelect), 83 defineToken("vertex", Tokens.KwVertex), 84 defineToken("fragment", Tokens.KwFragment), 85 defineToken("total", Tokens.KwTotal), 86 defineToken("preattrib", Tokens.KwPreAttrib), 87 //Graphics Language 88 defineToken("in", Tokens.GlIn), 89 defineToken("out", Tokens.GlOut), 90 defineToken("inout", Tokens.GlInOut)//, 91 //defineToken() 92 ];