Exemplo n.º 1
0
        public static Node CreateVoidToken()
        {
            TokenPattern patternVoid = new TokenPattern((int)HlslConstants.VOID,
                                                        "VOID", TokenPattern.PatternType.STRING, "void");

            return(new Token(patternVoid, patternVoid.GetPattern(), 1, 1));
        }
Exemplo n.º 2
0
        public static Node CreateNewLineToken()
        {
            TokenPattern patternNEW_LINE = new TokenPattern((int)HlslConstants.NEWLINE,
                                                            "NEWLINE", TokenPattern.PatternType.STRING, "\n");

            return(new Token(patternNEW_LINE, patternNEW_LINE.GetPattern(), 1, 1));
        }
Exemplo n.º 3
0
        public static Node CreateVaryingToken()
        {
            TokenPattern patternVarying = new TokenPattern((int)HlslConstants.VARYING,
                                                           "VARYING", TokenPattern.PatternType.STRING, "varying");

            return(new Token(patternVarying, patternVarying.GetPattern(), 1, 1));
        }
Exemplo n.º 4
0
        public static Node CreateDotCommaToken()
        {
            TokenPattern patternDOT_COMMA = new TokenPattern((int)HlslConstants.DOT_COMMA,
                                                             "DOT_COMMA", TokenPattern.PatternType.STRING, ";");

            return(new Token(patternDOT_COMMA, patternDOT_COMMA.GetPattern(), 1, 1));
        }
Exemplo n.º 5
0
        /**
         * <summary>Initializes the tokenizer by creating all the token
         * patterns.</summary>
         *
         * <exception cref='ParserCreationException'>if the tokenizer
         * couldn't be initialized correctly</exception>
         */
        private void CreatePatterns()
        {
            TokenPattern pattern;

            pattern = new TokenPattern((int)MySqlModuleConstants.MULTI_LINE_COMMENT,
                                       "MULTI_LINE_COMMENT",
                                       TokenPattern.PatternType.REGEXP,
                                       "/\\*([^*]|\\*+[^*/])*\\*+/");
            AddPattern(pattern);

            pattern = new TokenPattern((int)MySqlModuleConstants.SINGLE_LINE_COMMENT,
                                       "SINGLE_LINE_COMMENT",
                                       TokenPattern.PatternType.REGEXP,
                                       "--.*");
            AddPattern(pattern);

            pattern = new TokenPattern((int)MySqlModuleConstants.WHITESPACE,
                                       "WHITESPACE",
                                       TokenPattern.PatternType.REGEXP,
                                       "[ \\t\\n\\r]+");
            AddPattern(pattern);

            pattern = new TokenPattern((int)MySqlModuleConstants.DEFINITION,
                                       "DEFINITION",
                                       TokenPattern.PatternType.REGEXP,
                                       "[Cc][Rr][Ee][Aa][Tt][Ee]([\\r\\n]|.)+");
            AddPattern(pattern);
        }
Exemplo n.º 6
0
    /**
     * Creates a new default tokenizer that recognizes a trivial
     * language.
     *
     * @param input          the input string
     * @param ignoreCase     the character case ignore flag
     *
     * @return a new tokenizer
     */
    private Tokenizer CreateDefaultTokenizer(string input, bool ignoreCase)
    {
        Tokenizer    tokenizer = CreateTokenizer(input, ignoreCase);
        TokenPattern pattern;

        pattern = new TokenPattern(KEYWORD,
                                   "KEYWORD",
                                   TokenPattern.PatternType.STRING,
                                   "keyword");
        AddPattern(tokenizer, pattern);
        pattern = new TokenPattern(IDENTIFIER,
                                   "IDENTIFIER",
                                   TokenPattern.PatternType.REGEXP,
                                   "[A-Z]+");
        AddPattern(tokenizer, pattern);
        pattern = new TokenPattern(NUMBER,
                                   "NUMBER",
                                   TokenPattern.PatternType.REGEXP,
                                   "[0-9]+");
        AddPattern(tokenizer, pattern);
        pattern = new TokenPattern(WHITESPACE,
                                   "WHITESPACE",
                                   TokenPattern.PatternType.REGEXP,
                                   "[ \t\n]+");
        pattern.Ignore = true;
        AddPattern(tokenizer, pattern);
        pattern = new TokenPattern(ERROR,
                                   "ERROR",
                                   TokenPattern.PatternType.STRING,
                                   "error");
        pattern.Error = true;
        AddPattern(tokenizer, pattern);

        return(tokenizer);
    }
Exemplo n.º 7
0
        public static Node CreateNumberToken(float value)
        {
            var pattern = new TokenPattern((int)HlslConstants.NUMBER,
                                           "NUMBER", TokenPattern.PatternType.STRING, value.ToString("0.0######", CultureInfo.InvariantCulture));

            return(new Token(pattern, pattern.GetPattern(), 1, 1));
        }
Exemplo n.º 8
0
        public static Node CreateEqualToken()
        {
            TokenPattern patternEqual = new TokenPattern((int)HlslConstants.EQUAL,
                                                         "EQUAL", TokenPattern.PatternType.STRING, "=");

            return(new Token(patternEqual, patternEqual.GetPattern(), 1, 1));
        }
Exemplo n.º 9
0
        protected ParseRule.ParseRuleDelegate GetDoWhileParseFunc(TokenPattern pattern)
        {
            return((tokens, matchResult) =>
            {
                if (matchResult.MatchesCount == 5)
                {
                    var blockMatch = matchResult.GetMatch(1);
                    var whileOperatorMatch = matchResult.GetMatch(2);
                    var argsMatch = matchResult.GetMatch(3);
                    var lineEndMatch = matchResult.GetMatch(4);
                    if (matchResult.IsFullMatch)
                    {
                        var blockTokens = TokenUtils.GetMatchResultBlockTokens(tokens, blockMatch);
                        var childNodes = ParseBlock(blockTokens);

                        var argsTokens = TokenUtils.GetMatchResultTokens(tokens, argsMatch);

                        var newNode = new Node(NodeType.DO_WHILE, argsTokens);
                        newNode.PrimaryChildNodes = childNodes;
                        return newNode;
                    }
                    else if (!blockMatch.IsFullMatch || !whileOperatorMatch.IsFullMatch || !argsMatch.IsFullMatch ||
                             !lineEndMatch.IsFullMatch)
                    {
                        throw new ParseRuleException(pattern, tokens, matchResult.Start, NodeType.WHILE);
                    }
                }

                throw new ParseException(tokens, matchResult.Start, NodeType.WHILE);
            });
        }
Exemplo n.º 10
0
        public static Node CreateSpaceToken()
        {
            TokenPattern patternWHITESPACE = new TokenPattern((int)HlslConstants.WHITESPACE,
                                                              "WHITESPACE", TokenPattern.PatternType.STRING, " ");

            return(new Token(patternWHITESPACE, patternWHITESPACE.GetPattern(), 1, 1));
        }
Exemplo n.º 11
0
        /// <summary>Initializes the tokenizer by creating all the token
        /// patterns.</summary>
        ///
        /// <exception cref='ParserCreationException'>if the tokenizer
        /// couldn't be initialized correctly</exception>
        private void CreatePatterns()
        {
            TokenPattern pattern;

            pattern = new TokenPattern((int)ArithmeticConstants.ADD,
                                       "ADD",
                                       TokenPattern.PatternType.STRING,
                                       "+");
            AddPattern(pattern);

            pattern = new TokenPattern((int)ArithmeticConstants.SUB,
                                       "SUB",
                                       TokenPattern.PatternType.STRING,
                                       "-");
            AddPattern(pattern);

            pattern = new TokenPattern((int)ArithmeticConstants.MUL,
                                       "MUL",
                                       TokenPattern.PatternType.STRING,
                                       "*");
            AddPattern(pattern);

            pattern = new TokenPattern((int)ArithmeticConstants.DIV,
                                       "DIV",
                                       TokenPattern.PatternType.STRING,
                                       "/");
            AddPattern(pattern);

            pattern = new TokenPattern((int)ArithmeticConstants.LEFT_PAREN,
                                       "LEFT_PAREN",
                                       TokenPattern.PatternType.STRING,
                                       "(");
            AddPattern(pattern);

            pattern = new TokenPattern((int)ArithmeticConstants.RIGHT_PAREN,
                                       "RIGHT_PAREN",
                                       TokenPattern.PatternType.STRING,
                                       ")");
            AddPattern(pattern);

            pattern = new TokenPattern((int)ArithmeticConstants.NUMBER,
                                       "NUMBER",
                                       TokenPattern.PatternType.REGEXP,
                                       "[0-9]+");
            AddPattern(pattern);

            pattern = new TokenPattern((int)ArithmeticConstants.IDENTIFIER,
                                       "IDENTIFIER",
                                       TokenPattern.PatternType.REGEXP,
                                       "[a-z]");
            AddPattern(pattern);

            pattern = new TokenPattern((int)ArithmeticConstants.WHITESPACE,
                                       "WHITESPACE",
                                       TokenPattern.PatternType.REGEXP,
                                       "[ \\t\\n\\r]+");
            pattern.Ignore = true;
            AddPattern(pattern);
        }
Exemplo n.º 12
0
 public void Update(int length, TokenPattern pattern)
 {
     if (this._length < length)
     {
         this._length  = length;
         this._pattern = pattern;
     }
 }
Exemplo n.º 13
0
 /**
  * Adds a pattern to the tokenizer and reports a test failure if
  * it failed.
  *
  * @param tokenizer      the tokenizer
  * @param pattern        the pattern to add
  */
 private void AddPattern(Tokenizer tokenizer, TokenPattern pattern)
 {
     try {
         tokenizer.AddPattern(pattern);
     } catch (ParserCreationException e) {
         Fail("couldn't add pattern " + pattern.Name + ": " +
              e.Message);
     }
 }
Exemplo n.º 14
0
 /**
  * Adds a pattern to the tokenizer and reports a test failure if
  * it failed.
  *
  * @param tokenizer      the tokenizer
  * @param pattern        the pattern to add
  */
 private void FailAddPattern(Tokenizer tokenizer, TokenPattern pattern)
 {
     try {
         tokenizer.AddPattern(pattern);
         Fail("could add pattern " + pattern.Name);
     } catch (ParserCreationException) {
         // Failure was expected
     }
 }
Exemplo n.º 15
0
 /**
  * Updates this match with new values. The new values will only
  * be considered if the length is longer than any previous match
  * found.
  *
  * @param length         the matched length
  * @param pattern        the matched pattern
  */
 public void Update(int length, TokenPattern pattern) {
     if (this.length < length) {
         this.length = length;
         this.pattern = pattern;
     } else if (this.length == length && this.pattern.Id > pattern.Id) {
         this.length = length;
         this.pattern = pattern;
     }
 }
Exemplo n.º 16
0
        private static int FindFirst(IReadOnlyList <MarkdownToken> tokens, TokenPattern pattern)
        {
            for (var i = 0; i < tokens.Count; ++i)
            {
                if (StartsWith(tokens.Slice(i), pattern))
                {
                    return(i);
                }
            }

            return(-1);
        }
Exemplo n.º 17
0
 /**
  * Updates this match with new values. The new values will only
  * be considered if the length is longer than any previous match
  * found.
  *
  * @param length         the matched length
  * @param pattern        the matched pattern
  */
 public void Update(int length, TokenPattern pattern)
 {
     if (length < length)
     {
         length  = length;
         pattern = pattern;
     }
     else if (length == length && pattern.Id > pattern.Id)
     {
         length  = length;
         pattern = pattern;
     }
 }
Exemplo n.º 18
0
 /**
  * Updates this match with new values. The new values will only
  * be considered if the length is longer than any previous match
  * found.
  *
  * @param length         the matched length
  * @param pattern        the matched pattern
  */
 public void Update(int length, TokenPattern pattern)
 {
     if (this.length < length)
     {
         this.length  = length;
         this.pattern = pattern;
     }
     else if (this.length == length && this.pattern.Id > pattern.Id)
     {
         this.length  = length;
         this.pattern = pattern;
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// Updates this match with new values. The new values will only
 /// be considered if the length is longer than any previous match
 /// found.
 /// </summary>
 /// <param name="matchLength">The matched length</param>
 /// <param name="matchPattern">The matched pattern</param>
 public void Update(int matchLength, TokenPattern matchPattern)
 {
     if (this.length < matchLength)
     {
         this.length  = matchLength;
         this.pattern = matchPattern;
     }
     else if (this.length == matchLength && this.pattern.Id > matchPattern.Id)
     {
         this.length  = matchLength;
         this.pattern = matchPattern;
     }
 }
Exemplo n.º 20
0
    /**
     * Test various invalid patterns.
     */
    public void TestInvalidPattern()
    {
        Tokenizer    tokenizer = CreateTokenizer("", false);
        TokenPattern pattern;

        pattern = new TokenPattern(NUMBER,
                                   "NUMBER",
                                   TokenPattern.PatternType.REGEXP + 13,
                                   "13");
        FailAddPattern(tokenizer, pattern);
        pattern = new TokenPattern(NUMBER,
                                   "NUMBER",
                                   TokenPattern.PatternType.REGEXP,
                                   "1(3");
        FailAddPattern(tokenizer, pattern);
    }
Exemplo n.º 21
0
        private static bool StartsWith(IReadOnlyList <MarkdownToken> tokens, TokenPattern pattern)
        {
            if (tokens.Count < pattern.Length)
            {
                return(false);
            }

            for (var i = 0; i < pattern.Length; ++i)
            {
                var token    = tokens[i];
                var expected = pattern.Types[i];
                if (token.Type != expected)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 22
0
 public CodeParser()
 {
     ArgsPattern = TokensBlockWithExcludePatternBuilder
                   .Reset()
                   .StartWith(TokenType.ARGS_OPEN)
                   .ExceptRange(
         Enum.GetValues(typeof(TokenType))
         .Cast <TokenType>()
         .Where(t => t.IsOperatorToken())
         .ToList())
                   .Except(TokenType.ACCESS_MODIFICATOR)
                   .EndWith(TokenType.ARGS_CLOSE)
                   .Build();
     MethodDefPattern = StrictPatternBuilder
                        .Reset()
                        .NextPattern(new SingleTokenPattern(TokenType.IDENTIFIER))
                        .NextPattern(ArgsPattern)
                        .NextPattern(TokensBlockPattern.BracketBlock)
                        .Build();
 }
        protected List <Token> FilterTryBlock(TokenPattern tryPattern, List <Token> tokens)
        {
            var tryMatch = tryPattern.GetMatch(tokens);

            while (tryMatch.IsPartMatch)
            {
                var tryOpMatch     = tryMatch.GetMatch(0);
                var codeBlockMatch = tryMatch.GetMatch(1);
                if (tryMatch.IsFullMatch)
                {
                    var tryBlockTokens = tokens.GetRange(codeBlockMatch.Start + 1, codeBlockMatch.Length - 2);
                    tokens.RemoveRange(tryMatch.Start, tryMatch.Length);
                    tokens.InsertRange(tryMatch.Start, tryBlockTokens);
                    tryMatch = tryPattern.GetMatch(tokens, tryMatch.Start + codeBlockMatch.Length);
                }
                else if (tryOpMatch.IsFullMatch && !codeBlockMatch.IsFullMatch)
                {
                    throw new ParseRuleException(tryPattern, tokens, tryMatch.Start);
                }
            }

            return(tokens);
        }
Exemplo n.º 24
0
        protected ParseRule.ParseRuleDelegate GetElseParseFunc(TokenPattern pattern)
        {
            return((tokens, matchResult) =>
            {
                if (matchResult.MatchesCount == 2)
                {
                    var blockMatch = matchResult.GetMatch(1);
                    if (matchResult.IsFullMatch)
                    {
                        var blockTokens = TokenUtils.GetMatchResultBlockTokens(tokens, blockMatch);
                        var childNodes = ParseBlock(blockTokens);

                        var newNode = new Node(NodeType.ELSE);
                        newNode.PrimaryChildNodes = childNodes;
                        return newNode;
                    }
                    else if (!blockMatch.IsFullMatch)
                    {
                        throw new ParseRuleException(pattern, tokens, matchResult.Start, NodeType.ELSE);
                    }
                }
                throw new ParseException(tokens, matchResult.Start, NodeType.ELSE);
            });
        }
        protected List <Token> ClassFilter(TokenPattern classDefPattern, List <Token> tokens)
        {
            var classDef = classDefPattern.GetMatch(tokens);

            while (classDef.IsPartMatch)
            {
                var classOperatorMatch = classDef.GetMatch(0);
                var classArgsMatch     = classDef.GetMatch(1);
                var codeBlockMatch     = classDef.GetMatch(2);
                if (codeBlockMatch.IsFullMatch)
                {
                    var classBlockLex = TokenUtils.GetMatchResultBlockTokens(tokens, codeBlockMatch);
                    tokens.RemoveRange(classDef.Start, classDef.Length);
                    tokens.InsertRange(classDef.Start, classBlockLex);
                    classDef = classDefPattern.GetMatch(tokens, classDef.End - 4);
                }
                else if (classOperatorMatch.IsFullMatch && (!classArgsMatch.IsFullMatch | classArgsMatch.IsFullMatch))
                {
                    throw new ParseRuleException(classDefPattern, tokens, classDef.Start);
                }
            }

            return(tokens);
        }
 public StrictEditTokensFilter(StrictTokenEditFunc editFunc, TokenPattern tokenPattern, int priority) : base(tokenPattern, priority)
 {
     EditFunc = editFunc;
 }
 public StrictEditTokensFilter(StrictTokenEditFunc editFunc, TokenPattern tokenPattern) : base(tokenPattern)
 {
     EditFunc = editFunc;
 }
Exemplo n.º 28
0
        private Inline MatchOne(IReadOnlyList <MarkdownToken> tokens, out int consumedCount)
        {
            int totalMatchCount;
            IReadOnlyList <MarkdownToken> match;

            if ((match = Match(tokens, out totalMatchCount,
                               TokenPattern.Required(MarkdownTokenType.Star, MarkdownTokenType.Star),
                               TokenPattern.Optional(MarkdownTokenType.Star, MarkdownTokenType.Star))) != null)
            {
                var children = MatchAll(match);
                var element  = new Bold();
                element.Inlines.AddRange(children);
                consumedCount = 4 + match.Count;
                return(element);
            }

            if ((match = Match(tokens, out totalMatchCount,
                               TokenPattern.Required(MarkdownTokenType.Underscore, MarkdownTokenType.Underscore),
                               TokenPattern.Optional(MarkdownTokenType.Underscore, MarkdownTokenType.Underscore))) != null)
            {
                var children = MatchAll(match);
                var element  = new Bold();
                element.Inlines.AddRange(children);
                consumedCount = 4 + match.Count;
                return(element);
            }

            if ((match = Match(tokens, out totalMatchCount,
                               TokenPattern.Required(MarkdownTokenType.Tilde, MarkdownTokenType.Tilde),
                               TokenPattern.Optional(MarkdownTokenType.Tilde, MarkdownTokenType.Tilde))) != null)
            {
                var children   = MatchAll(match);
                var element    = new Span();
                var decoration = new TextDecoration {
                    Location = TextDecorationLocation.Strikethrough
                };
                decoration.Freeze();
                element.TextDecorations.Add(decoration);
                element.Inlines.AddRange(children);
                consumedCount = 4 + match.Count;
                return(element);
            }

            if ((match = Match(tokens, out totalMatchCount,
                               TokenPattern.Required(MarkdownTokenType.Star),
                               TokenPattern.Optional(MarkdownTokenType.Star))) != null)
            {
                var children = MatchAll(match);
                var element  = new Italic();
                element.Inlines.AddRange(children);
                consumedCount = 2 + match.Count;
                return(element);
            }

            if ((match = Match(tokens, out totalMatchCount,
                               TokenPattern.Required(MarkdownTokenType.Underscore),
                               TokenPattern.Optional(MarkdownTokenType.Underscore))) != null)
            {
                var children = MatchAll(match);
                var element  = new Italic();
                element.Inlines.AddRange(children);
                consumedCount = 2 + match.Count;
                return(element);
            }

            if ((match = Match(tokens, out totalMatchCount,
                               start: TokenPattern.Required(MarkdownTokenType.LineBreak))) != null)
            {
                consumedCount = 1;
                return(new LineBreak());
            }

            if ((match = Match(tokens, out totalMatchCount,
                               start: TokenPattern.Required(MarkdownTokenType.Whitespace))) != null)
            {
                consumedCount = 1;
                return(new Run(" "));
            }

            var token = tokens[index : 0];

            consumedCount = 1;
            return(new Run(token.Text));
        }
Exemplo n.º 29
0
 public static Node CreateDotCommaToken()
 {
     TokenPattern patternDOT_COMMA = new TokenPattern((int) HlslConstants.DOT_COMMA,
                               "DOT_COMMA", TokenPattern.PatternType.STRING, ";");
     return new Token(patternDOT_COMMA, patternDOT_COMMA.GetPattern(), 1, 1);
 }
Exemplo n.º 30
0
 public static Node CreateNewLineToken()
 {
     TokenPattern patternNEW_LINE = new TokenPattern((int) HlslConstants.NEWLINE,
                                "NEWLINE", TokenPattern.PatternType.STRING, "\n");
     return new Token(patternNEW_LINE, patternNEW_LINE.GetPattern(), 1, 1);
 }
Exemplo n.º 31
0
 public static Node CreateEqualToken()
 {
     TokenPattern patternEqual = new TokenPattern((int)HlslConstants.EQUAL,
                                 "EQUAL", TokenPattern.PatternType.STRING, "=");
     return new Token(patternEqual, patternEqual.GetPattern(), 1, 1);
 }
Exemplo n.º 32
0
        /**
         * <summary>Initializes the tokenizer by creating all the token
         * patterns.</summary>
         *
         * <exception cref='ParserCreationException'>if the tokenizer
         * couldn't be initialized correctly</exception>
         */
        private void CreatePatterns()
        {
            TokenPattern pattern;

            pattern = new TokenPattern((int)Arch4Constants.LD,
                                       "LD",
                                       TokenPattern.PatternType.STRING,
                                       "LD");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.ST,
                                       "ST",
                                       TokenPattern.PatternType.STRING,
                                       "ST");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.ADD,
                                       "ADD",
                                       TokenPattern.PatternType.STRING,
                                       "ADD");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.HALT,
                                       "HALT",
                                       TokenPattern.PatternType.STRING,
                                       "HALT");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.JMP,
                                       "JMP",
                                       TokenPattern.PatternType.STRING,
                                       "JMP");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.OUT,
                                       "OUT",
                                       TokenPattern.PatternType.STRING,
                                       "OUT");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.ITR,
                                       "ITR",
                                       TokenPattern.PatternType.STRING,
                                       "ITR");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.RTI,
                                       "RTI",
                                       TokenPattern.PatternType.STRING,
                                       "RTI");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R0,
                                       "R0",
                                       TokenPattern.PatternType.STRING,
                                       "R0");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R1,
                                       "R1",
                                       TokenPattern.PatternType.STRING,
                                       "R1");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R2,
                                       "R2",
                                       TokenPattern.PatternType.STRING,
                                       "R2");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R3,
                                       "R3",
                                       TokenPattern.PatternType.STRING,
                                       "R3");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R4,
                                       "R4",
                                       TokenPattern.PatternType.STRING,
                                       "R4");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R5,
                                       "R5",
                                       TokenPattern.PatternType.STRING,
                                       "R5");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R6,
                                       "R6",
                                       TokenPattern.PatternType.STRING,
                                       "R6");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R7,
                                       "R7",
                                       TokenPattern.PatternType.STRING,
                                       "R7");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R8,
                                       "R8",
                                       TokenPattern.PatternType.STRING,
                                       "R8");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R9,
                                       "R9",
                                       TokenPattern.PatternType.STRING,
                                       "R9");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R10,
                                       "R10",
                                       TokenPattern.PatternType.STRING,
                                       "R10");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R11,
                                       "R11",
                                       TokenPattern.PatternType.STRING,
                                       "R11");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R12,
                                       "R12",
                                       TokenPattern.PatternType.STRING,
                                       "R12");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R13,
                                       "R13",
                                       TokenPattern.PatternType.STRING,
                                       "R13");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R14,
                                       "R14",
                                       TokenPattern.PatternType.STRING,
                                       "R14");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.R15,
                                       "R15",
                                       TokenPattern.PatternType.STRING,
                                       "R15");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.BL,
                                       "BL",
                                       TokenPattern.PatternType.STRING,
                                       "BL");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.BH,
                                       "BH",
                                       TokenPattern.PatternType.STRING,
                                       "BH");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.BX,
                                       "BX",
                                       TokenPattern.PatternType.STRING,
                                       "BX");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.PC,
                                       "PC",
                                       TokenPattern.PatternType.STRING,
                                       "PC");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.EQUALS,
                                       "EQUALS",
                                       TokenPattern.PatternType.STRING,
                                       "=");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.LEFT_PAREN,
                                       "LEFT_PAREN",
                                       TokenPattern.PatternType.STRING,
                                       "(");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.RIGHT_PAREN,
                                       "RIGHT_PAREN",
                                       TokenPattern.PatternType.STRING,
                                       ")");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.HASH,
                                       "HASH",
                                       TokenPattern.PatternType.STRING,
                                       "#");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.COLON,
                                       "COLON",
                                       TokenPattern.PatternType.STRING,
                                       ":");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.COMMA,
                                       "COMMA",
                                       TokenPattern.PatternType.STRING,
                                       ",");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.ORG,
                                       "ORG",
                                       TokenPattern.PatternType.STRING,
                                       "org");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.SIGN,
                                       "SIGN",
                                       TokenPattern.PatternType.REGEXP,
                                       "[+-]");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.DEC_NUMBER,
                                       "DEC_NUMBER",
                                       TokenPattern.PatternType.REGEXP,
                                       "[0-9]+");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.BIN_NUMBER,
                                       "BIN_NUMBER",
                                       TokenPattern.PatternType.REGEXP,
                                       "[01]+[bB]");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.OCT_NUMBER,
                                       "OCT_NUMBER",
                                       TokenPattern.PatternType.REGEXP,
                                       "[0-8]+[oO]");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.HEX_NUMBER,
                                       "HEX_NUMBER",
                                       TokenPattern.PatternType.REGEXP,
                                       "[0-9a-f]+[hH]");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.IDENTIFIER,
                                       "IDENTIFIER",
                                       TokenPattern.PatternType.REGEXP,
                                       "[a-z][a-z0-9_]*");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.ENTER,
                                       "ENTER",
                                       TokenPattern.PatternType.REGEXP,
                                       "[\\n\\r]+");
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.SINGLE_LINE_COMMENT,
                                       "SINGLE_LINE_COMMENT",
                                       TokenPattern.PatternType.REGEXP,
                                       ";.*");
            pattern.Ignore = true;
            AddPattern(pattern);

            pattern = new TokenPattern((int)Arch4Constants.WHITESPACE,
                                       "WHITESPACE",
                                       TokenPattern.PatternType.REGEXP,
                                       "[ \\t]+");
            pattern.Ignore = true;
            AddPattern(pattern);
        }
Exemplo n.º 33
0
        /**
         * <summary>Initializes the tokenizer by creating all the token
         * patterns.</summary>
         *
         * <exception cref='ParserCreationException'>if the tokenizer
         * couldn't be initialized correctly</exception>
         */
        private void CreatePatterns()
        {
            TokenPattern pattern;

            pattern = new TokenPattern((int)RegexpConstants.LEFT_PAREN,
                                       "LEFT_PAREN",
                                       TokenPattern.PatternType.STRING,
                                       "(");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.RIGHT_PAREN,
                                       "RIGHT_PAREN",
                                       TokenPattern.PatternType.STRING,
                                       ")");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.LEFT_BRACKET,
                                       "LEFT_BRACKET",
                                       TokenPattern.PatternType.STRING,
                                       "[");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.RIGHT_BRACKET,
                                       "RIGHT_BRACKET",
                                       TokenPattern.PatternType.STRING,
                                       "]");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.LEFT_BRACE,
                                       "LEFT_BRACE",
                                       TokenPattern.PatternType.STRING,
                                       "{");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.RIGHT_BRACE,
                                       "RIGHT_BRACE",
                                       TokenPattern.PatternType.STRING,
                                       "}");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.QUESTION,
                                       "QUESTION",
                                       TokenPattern.PatternType.STRING,
                                       "?");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.ASTERISK,
                                       "ASTERISK",
                                       TokenPattern.PatternType.STRING,
                                       "*");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.PLUS,
                                       "PLUS",
                                       TokenPattern.PatternType.STRING,
                                       "+");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.VERTICAL_BAR,
                                       "VERTICAL_BAR",
                                       TokenPattern.PatternType.STRING,
                                       "|");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.DOT,
                                       "DOT",
                                       TokenPattern.PatternType.STRING,
                                       ".");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.COMMA,
                                       "COMMA",
                                       TokenPattern.PatternType.STRING,
                                       ",");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.NUMBER,
                                       "NUMBER",
                                       TokenPattern.PatternType.REGEXP,
                                       "[0-9]+");
            AddPattern(pattern);

            pattern = new TokenPattern((int)RegexpConstants.CHAR,
                                       "CHAR",
                                       TokenPattern.PatternType.REGEXP,
                                       "(\\\\.)|.");
            AddPattern(pattern);
        }
Exemplo n.º 34
0
 public static Node CreateNumberToken(float value)
 {
     var pattern = new TokenPattern((int)HlslConstants.NUMBER,
                                 "NUMBER", TokenPattern.PatternType.STRING, value.ToString("0.0######",CultureInfo.InvariantCulture));
     return new Token(pattern, pattern.GetPattern(), 1, 1);
 }
Exemplo n.º 35
0
 public void Clear()
 {
     _length  = 0;
     _pattern = null;
 }
Exemplo n.º 36
0
 public static Node CreateSpaceToken()
 {
     TokenPattern patternWHITESPACE = new TokenPattern((int) HlslConstants.WHITESPACE,
                               "WHITESPACE", TokenPattern.PatternType.STRING, " ");
     return new Token(patternWHITESPACE, patternWHITESPACE.GetPattern(), 1, 1);
 }
Exemplo n.º 37
0
 public static Node CreateVaryingToken()
 {
     TokenPattern patternVarying = new TokenPattern((int) HlslConstants.VARYING,
                                "VARYING", TokenPattern.PatternType.STRING, "varying");
     return new Token(patternVarying, patternVarying.GetPattern(), 1, 1);
 }
Exemplo n.º 38
0
 public static Node CreateVoidToken()
 {
     TokenPattern patternVoid = new TokenPattern((int)HlslConstants.VOID,
                                "VOID", TokenPattern.PatternType.STRING, "void");
     return new Token(patternVoid, patternVoid.GetPattern(), 1, 1);
 }
Exemplo n.º 39
0
    /**
     * <summary>Initializes the tokenizer by creating all the token
     * patterns.</summary>
     *
     * <exception cref='ParserCreationException'>if the tokenizer
     * couldn't be initialized correctly</exception>
     */
    private void CreatePatterns()
    {
        TokenPattern  pattern;

        pattern = new TokenPattern((int) HlslConstants.ADD,
                                   "ADD",
                                   TokenPattern.PatternType.STRING,
                                   "+");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SUB,
                                   "SUB",
                                   TokenPattern.PatternType.STRING,
                                   "-");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MULT,
                                   "MULT",
                                   TokenPattern.PatternType.STRING,
                                   "*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DIV,
                                   "DIV",
                                   TokenPattern.PatternType.STRING,
                                   "/");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MOD,
                                   "MOD",
                                   TokenPattern.PatternType.STRING,
                                   "%");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.ADD_ADD,
                                   "ADD_ADD",
                                   TokenPattern.PatternType.STRING,
                                   "++");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SUB_SUB,
                                   "SUB_SUB",
                                   TokenPattern.PatternType.STRING,
                                   "--");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.EQUAL,
                                   "EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.ADD_EQUAL,
                                   "ADD_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "+=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SUB_EQUAL,
                                   "SUB_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "-=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MULT_EQUAL,
                                   "MULT_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "*=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DIV_EQUAL,
                                   "DIV_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "/=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MOD_EQUAL,
                                   "MOD_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "%=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MINOR_MINOR_EQUAL,
                                   "MINOR_MINOR_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "<<=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MAJOR_MAJOR_EQUAL,
                                   "MAJOR_MAJOR_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   ">>=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.AND_EQUAL,
                                   "AND_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "&=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.OR_EQUAL,
                                   "OR_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "|=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.POT_EQUAL,
                                   "POT_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "^=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.EQUAL_EQUAL,
                                   "EQUAL_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "==");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DIFF,
                                   "DIFF",
                                   TokenPattern.PatternType.STRING,
                                   "!=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.LESS_EQUAL,
                                   "LESS_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   "<=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MORE_EQUAL,
                                   "MORE_EQUAL",
                                   TokenPattern.PatternType.STRING,
                                   ">=");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TIL,
                                   "TIL",
                                   TokenPattern.PatternType.STRING,
                                   "~");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MINOR_MINOR,
                                   "MINOR_MINOR",
                                   TokenPattern.PatternType.STRING,
                                   "<<");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MAJOR_MAJOR,
                                   "MAJOR_MAJOR",
                                   TokenPattern.PatternType.STRING,
                                   ">>");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.AND,
                                   "AND",
                                   TokenPattern.PatternType.STRING,
                                   "&");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.OR,
                                   "OR",
                                   TokenPattern.PatternType.STRING,
                                   "|");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.POT,
                                   "POT",
                                   TokenPattern.PatternType.STRING,
                                   "^");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.AND_AND,
                                   "AND_AND",
                                   TokenPattern.PatternType.STRING,
                                   "&&");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.OR_OR,
                                   "OR_OR",
                                   TokenPattern.PatternType.STRING,
                                   "||");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NOT,
                                   "NOT",
                                   TokenPattern.PatternType.STRING,
                                   "!");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MAJOR,
                                   "MAJOR",
                                   TokenPattern.PatternType.STRING,
                                   ">");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MINOR,
                                   "MINOR",
                                   TokenPattern.PatternType.STRING,
                                   "<");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.OPEN_PAREN,
                                   "OPEN_PAREN",
                                   TokenPattern.PatternType.STRING,
                                   "(");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CLOSE_PAREN,
                                   "CLOSE_PAREN",
                                   TokenPattern.PatternType.STRING,
                                   ")");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.OPEN_BREACKET,
                                   "OPEN_BREACKET",
                                   TokenPattern.PatternType.STRING,
                                   "{");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CLOSE_BREACKET,
                                   "CLOSE_BREACKET",
                                   TokenPattern.PatternType.STRING,
                                   "}");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.OPEN_COLCHETES,
                                   "OPEN_COLCHETES",
                                   TokenPattern.PatternType.STRING,
                                   "[");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CLOSE_COLCHETES,
                                   "CLOSE_COLCHETES",
                                   TokenPattern.PatternType.STRING,
                                   "]");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DOUBLE_DOT,
                                   "DOUBLE_DOT",
                                   TokenPattern.PatternType.STRING,
                                   ":");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DOT_COMMA,
                                   "DOT_COMMA",
                                   TokenPattern.PatternType.STRING,
                                   ";");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.COMMA,
                                   "COMMA",
                                   TokenPattern.PatternType.STRING,
                                   ",");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DOT,
                                   "DOT",
                                   TokenPattern.PatternType.STRING,
                                   ".");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NUMBER,
                                   "NUMBER",
                                   TokenPattern.PatternType.REGEXP,
                                   "[0-9]+|[0-9]*\\.[0-9]+(E[0-9]+)?(f)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NUMBER_2_4,
                                   "NUMBER_2_4",
                                   TokenPattern.PatternType.REGEXP,
                                   "[2-4]");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NUMBER_1_4,
                                   "NUMBER_1_4",
                                   TokenPattern.PatternType.REGEXP,
                                   "[1-4]");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.WHITESPACE,
                                   "WHITESPACE",
                                   TokenPattern.PatternType.REGEXP,
                                   "[ ]+");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TAB,
                                   "TAB",
                                   TokenPattern.PatternType.REGEXP,
                                   "[\\t]");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NEWLINE,
                                   "NEWLINE",
                                   TokenPattern.PatternType.REGEXP,
                                   "[\\n]");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NEWLINE2,
                                   "NEWLINE2",
                                   TokenPattern.PatternType.REGEXP,
                                   "[\\r\\n]");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NEWLINE3,
                                   "NEWLINE3",
                                   TokenPattern.PatternType.REGEXP,
                                   "[\\n\\r]");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.FORMFEED,
                                   "FORMFEED",
                                   TokenPattern.PatternType.REGEXP,
                                   "[\\r]");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.STRING,
                                   "STRING",
                                   TokenPattern.PatternType.REGEXP,
                                   "(\".*[^\\\\]\")|('.*[^\\\\]')");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.RGBA,
                                   "RGBA",
                                   TokenPattern.PatternType.REGEXP,
                                   "[rgba]+");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.XYZW,
                                   "XYZW",
                                   TokenPattern.PatternType.REGEXP,
                                   "[xyzw]+");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.ASM,
                                   "ASM",
                                   TokenPattern.PatternType.REGEXP,
                                   "( ?i)asm");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.ASM_FRAGMENT,
                                   "ASM_FRAGMENT",
                                   TokenPattern.PatternType.STRING,
                                   "asm_fragment");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BLENDSTATE,
                                   "BLENDSTATE",
                                   TokenPattern.PatternType.STRING,
                                   "BlendState");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.COLUMN_MAJOR,
                                   "COLUMN_MAJOR",
                                   TokenPattern.PatternType.STRING,
                                   "column_major");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.COMPILE_FRAGMENT,
                                   "COMPILE_FRAGMENT",
                                   TokenPattern.PatternType.STRING,
                                   "compile_frgment");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DISCARD,
                                   "DISCARD",
                                   TokenPattern.PatternType.STRING,
                                   "discard");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DECL,
                                   "DECL",
                                   TokenPattern.PatternType.STRING,
                                   "decl");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DO,
                                   "DO",
                                   TokenPattern.PatternType.STRING,
                                   "do");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.ELSE,
                                   "ELSE",
                                   TokenPattern.PatternType.STRING,
                                   "else");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.EXTERN,
                                   "EXTERN",
                                   TokenPattern.PatternType.STRING,
                                   "extern");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.END,
                                   "END",
                                   TokenPattern.PatternType.STRING,
                                   "end");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.FALSE,
                                   "FALSE",
                                   TokenPattern.PatternType.STRING,
                                   "false");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.FOR,
                                   "FOR",
                                   TokenPattern.PatternType.STRING,
                                   "for");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.IF,
                                   "IF",
                                   TokenPattern.PatternType.STRING,
                                   "if");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.IN,
                                   "IN",
                                   TokenPattern.PatternType.STRING,
                                   "in");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.INLINE,
                                   "INLINE",
                                   TokenPattern.PatternType.STRING,
                                   "inline");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.INOUT,
                                   "INOUT",
                                   TokenPattern.PatternType.STRING,
                                   "inout");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MATRIX,
                                   "MATRIX",
                                   TokenPattern.PatternType.STRING,
                                   "matrix");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.OUT,
                                   "OUT",
                                   TokenPattern.PatternType.STRING,
                                   "out");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PACKOFFSET,
                                   "PACKOFFSET",
                                   TokenPattern.PatternType.STRING,
                                   "packoffset");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PASS,
                                   "PASS",
                                   TokenPattern.PatternType.STRING,
                                   "pass");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PIXELFRAGMENT,
                                   "PIXELFRAGMENT",
                                   TokenPattern.PatternType.STRING,
                                   "pixelfragment");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.REGISTER,
                                   "REGISTER",
                                   TokenPattern.PatternType.STRING,
                                   "register");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.RETURN,
                                   "RETURN",
                                   TokenPattern.PatternType.STRING,
                                   "return");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.ROW_MAJOR,
                                   "ROW_MAJOR",
                                   TokenPattern.PatternType.STRING,
                                   "row_major");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SAMPLER,
                                   "SAMPLER",
                                   TokenPattern.PatternType.STRING,
                                   "sampler");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SAMPLER1D,
                                   "SAMPLER1D",
                                   TokenPattern.PatternType.STRING,
                                   "sampler1D");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SAMPLER2D,
                                   "SAMPLER2D",
                                   TokenPattern.PatternType.STRING,
                                   "sampler2D");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SAMPLER3D,
                                   "SAMPLER3D",
                                   TokenPattern.PatternType.STRING,
                                   "sampler3D");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SAMPLERCUBE,
                                   "SAMPLERCUBE",
                                   TokenPattern.PatternType.STRING,
                                   "samplerCUBE");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SAMPLER_STATE,
                                   "SAMPLER_STATE",
                                   TokenPattern.PatternType.STRING,
                                   "sampler_state");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SHARED,
                                   "SHARED",
                                   TokenPattern.PatternType.STRING,
                                   "shared");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.STATEBLOCK,
                                   "STATEBLOCK",
                                   TokenPattern.PatternType.STRING,
                                   "stateblock");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.STATEBLOCK_STATE,
                                   "STATEBLOCK_STATE",
                                   TokenPattern.PatternType.STRING,
                                   "stateblock_state");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.STATIC,
                                   "STATIC",
                                   TokenPattern.PatternType.STRING,
                                   "static");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.STRING_TYPE,
                                   "STRING_TYPE",
                                   TokenPattern.PatternType.STRING,
                                   "string");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.STRUCT,
                                   "STRUCT",
                                   TokenPattern.PatternType.STRING,
                                   "struct");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TECHNIQUE,
                                   "TECHNIQUE",
                                   TokenPattern.PatternType.STRING,
                                   "technique");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TEXTURE,
                                   "TEXTURE",
                                   TokenPattern.PatternType.STRING,
                                   "texture");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TEXTURE1D,
                                   "TEXTURE1D",
                                   TokenPattern.PatternType.STRING,
                                   "texture1D");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TEXTURE2D,
                                   "TEXTURE2D",
                                   TokenPattern.PatternType.STRING,
                                   "texture2D");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TEXTURE3D,
                                   "TEXTURE3D",
                                   TokenPattern.PatternType.STRING,
                                   "texture3D");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TEXTURECUBE,
                                   "TEXTURECUBE",
                                   TokenPattern.PatternType.STRING,
                                   "textureCUBE");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TRUE,
                                   "TRUE",
                                   TokenPattern.PatternType.STRING,
                                   "true");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TYPEDEF,
                                   "TYPEDEF",
                                   TokenPattern.PatternType.STRING,
                                   "typedef");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.UNIFORM,
                                   "UNIFORM",
                                   TokenPattern.PatternType.STRING,
                                   "uniform");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.VARYING,
                                   "VARYING",
                                   TokenPattern.PatternType.STRING,
                                   "varying");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.VECTOR,
                                   "VECTOR",
                                   TokenPattern.PatternType.STRING,
                                   "vector");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.VERTEXFRAGMENT,
                                   "VERTEXFRAGMENT",
                                   TokenPattern.PatternType.STRING,
                                   "vertexfragment");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.VOID,
                                   "VOID",
                                   TokenPattern.PatternType.STRING,
                                   "void");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.VOLATILE,
                                   "VOLATILE",
                                   TokenPattern.PatternType.STRING,
                                   "volatile");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.WHILE,
                                   "WHILE",
                                   TokenPattern.PatternType.STRING,
                                   "while");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.STOP,
                                   "STOP",
                                   TokenPattern.PatternType.STRING,
                                   "stop");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.FLATTEN,
                                   "FLATTEN",
                                   TokenPattern.PatternType.STRING,
                                   "flatten");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BRANCH,
                                   "BRANCH",
                                   TokenPattern.PatternType.STRING,
                                   "branch");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.UNROLL,
                                   "UNROLL",
                                   TokenPattern.PatternType.STRING,
                                   "unroll");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.LOOP,
                                   "LOOP",
                                   TokenPattern.PatternType.STRING,
                                   "loop");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.FORCECASE,
                                   "FORCECASE",
                                   TokenPattern.PatternType.STRING,
                                   "forcecase");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CALL,
                                   "CALL",
                                   TokenPattern.PatternType.STRING,
                                   "call");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.AUTO,
                                   "AUTO",
                                   TokenPattern.PatternType.STRING,
                                   "auto");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BREAK,
                                   "BREAK",
                                   TokenPattern.PatternType.STRING,
                                   "break");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.COMPILE,
                                   "COMPILE",
                                   TokenPattern.PatternType.STRING,
                                   "compile");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CONST,
                                   "CONST",
                                   TokenPattern.PatternType.STRING,
                                   "const");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CHAR,
                                   "CHAR",
                                   TokenPattern.PatternType.STRING,
                                   "char");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CLASS,
                                   "CLASS",
                                   TokenPattern.PatternType.STRING,
                                   "class");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CASE,
                                   "CASE",
                                   TokenPattern.PatternType.STRING,
                                   "case");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CATCH,
                                   "CATCH",
                                   TokenPattern.PatternType.STRING,
                                   "catch");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DEFAULT,
                                   "DEFAULT",
                                   TokenPattern.PatternType.STRING,
                                   "default");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DELETE,
                                   "DELETE",
                                   TokenPattern.PatternType.STRING,
                                   "delete");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CONST_CAST,
                                   "CONST_CAST",
                                   TokenPattern.PatternType.STRING,
                                   "const_cast");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.CONTINUE,
                                   "CONTINUE",
                                   TokenPattern.PatternType.STRING,
                                   "continue");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.EXPLICIT,
                                   "EXPLICIT",
                                   TokenPattern.PatternType.STRING,
                                   "explicit");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.FRIEND,
                                   "FRIEND",
                                   TokenPattern.PatternType.STRING,
                                   "friend");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DYNAMIC_CAST,
                                   "DYNAMIC_CAST",
                                   TokenPattern.PatternType.STRING,
                                   "dynamic_cast");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.ENUM,
                                   "ENUM",
                                   TokenPattern.PatternType.STRING,
                                   "enum");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.MUTABLE,
                                   "MUTABLE",
                                   TokenPattern.PatternType.STRING,
                                   "mutable");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NAMESPACE,
                                   "NAMESPACE",
                                   TokenPattern.PatternType.STRING,
                                   "namespace");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.GOTO,
                                   "GOTO",
                                   TokenPattern.PatternType.STRING,
                                   "goto");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.LONG,
                                   "LONG",
                                   TokenPattern.PatternType.STRING,
                                   "long");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRIVATE,
                                   "PRIVATE",
                                   TokenPattern.PatternType.STRING,
                                   "private");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PROTECTED,
                                   "PROTECTED",
                                   TokenPattern.PatternType.STRING,
                                   "protected");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NEW,
                                   "NEW",
                                   TokenPattern.PatternType.STRING,
                                   "new");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.OPERATOR,
                                   "OPERATOR",
                                   TokenPattern.PatternType.STRING,
                                   "operator");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PUBLIC,
                                   "PUBLIC",
                                   TokenPattern.PatternType.STRING,
                                   "public");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.REINTERPRET_CAST,
                                   "REINTERPRET_CAST",
                                   TokenPattern.PatternType.STRING,
                                   "reinterpret_cast");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SHORT,
                                   "SHORT",
                                   TokenPattern.PatternType.STRING,
                                   "short");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.STATIC_CAST,
                                   "STATIC_CAST",
                                   TokenPattern.PatternType.STRING,
                                   "static_cast");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SIGNED,
                                   "SIGNED",
                                   TokenPattern.PatternType.STRING,
                                   "signed");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SIZEOF,
                                   "SIZEOF",
                                   TokenPattern.PatternType.STRING,
                                   "sizeof");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.SWITCH,
                                   "SWITCH",
                                   TokenPattern.PatternType.STRING,
                                   "switch");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TEMPLATE,
                                   "TEMPLATE",
                                   TokenPattern.PatternType.STRING,
                                   "template");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.THIS,
                                   "THIS",
                                   TokenPattern.PatternType.STRING,
                                   "this");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.THROW,
                                   "THROW",
                                   TokenPattern.PatternType.STRING,
                                   "throw");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TRY,
                                   "TRY",
                                   TokenPattern.PatternType.STRING,
                                   "try");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TYPENAME,
                                   "TYPENAME",
                                   TokenPattern.PatternType.STRING,
                                   "typename");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.UNION,
                                   "UNION",
                                   TokenPattern.PatternType.STRING,
                                   "union");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.UNSIGNED,
                                   "UNSIGNED",
                                   TokenPattern.PatternType.STRING,
                                   "unsigned");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.USING,
                                   "USING",
                                   TokenPattern.PatternType.STRING,
                                   "using");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.VIRTUAL,
                                   "VIRTUAL",
                                   TokenPattern.PatternType.STRING,
                                   "virtual");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BINORMAL,
                                   "BINORMAL",
                                   TokenPattern.PatternType.STRING,
                                   "BINORMAL");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BLENDINDICES,
                                   "BLENDINDICES",
                                   TokenPattern.PatternType.STRING,
                                   "BLENDINDICES");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BLENDWEIGHT,
                                   "BLENDWEIGHT",
                                   TokenPattern.PatternType.STRING,
                                   "BLENDWEIGHT");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NORMAL,
                                   "NORMAL",
                                   TokenPattern.PatternType.STRING,
                                   "NORMAL");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.POSITIONT,
                                   "POSITIONT",
                                   TokenPattern.PatternType.STRING,
                                   "POSITIONT");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.VFACE,
                                   "VFACE",
                                   TokenPattern.PatternType.STRING,
                                   "VFACE");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.VPOS,
                                   "VPOS",
                                   TokenPattern.PatternType.STRING,
                                   "VPOS");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.FOG,
                                   "FOG",
                                   TokenPattern.PatternType.STRING,
                                   "FOG");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TESSFACTOR,
                                   "TESSFACTOR",
                                   TokenPattern.PatternType.STRING,
                                   "TESSFACTOR");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DEPTH,
                                   "DEPTH",
                                   TokenPattern.PatternType.STRING,
                                   "DEPTH");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.POSITION,
                                   "POSITION",
                                   TokenPattern.PatternType.REGEXP,
                                   "POSITION([0-9])?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TEXCOORD,
                                   "TEXCOORD",
                                   TokenPattern.PatternType.REGEXP,
                                   "TEXCOORD([0-9])?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TEXUNIT,
                                   "TEXUNIT",
                                   TokenPattern.PatternType.REGEXP,
                                   "TEXUNIT([0-9])?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.COLOR,
                                   "COLOR",
                                   TokenPattern.PatternType.REGEXP,
                                   "COLOR([0-9])?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.TANGENT,
                                   "TANGENT",
                                   TokenPattern.PatternType.REGEXP,
                                   "TANGENT([0-9])?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PSIZE,
                                   "PSIZE",
                                   TokenPattern.PatternType.STRING,
                                   "PSIZE");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.WORLD,
                                   "WORLD",
                                   TokenPattern.PatternType.REGEXP,
                                   "WORLD(I)?(T)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.VIEW,
                                   "VIEW",
                                   TokenPattern.PatternType.REGEXP,
                                   "VIEW(I)?(T)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PROJ,
                                   "PROJ",
                                   TokenPattern.PatternType.REGEXP,
                                   "PROJ(I)?(T)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.WORLDVIEW,
                                   "WORLDVIEW",
                                   TokenPattern.PatternType.REGEXP,
                                   "WORLDVIEW(I)?(T)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.WORLDPROJ,
                                   "WORLDPROJ",
                                   TokenPattern.PatternType.REGEXP,
                                   "WORLDPROJ(I)?(T)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.VIEWPROJ,
                                   "VIEWPROJ",
                                   TokenPattern.PatternType.REGEXP,
                                   "VIEWPROJ(I)?(T)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.WORLDVIEWPROJ,
                                   "WORLDVIEWPROJ",
                                   TokenPattern.PatternType.REGEXP,
                                   "WORLDVIEWPROJ(I)?(T)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.FLOAT,
                                   "FLOAT",
                                   TokenPattern.PatternType.REGEXP,
                                   "float([2-4](x[2-4])?)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.INT,
                                   "INT",
                                   TokenPattern.PatternType.REGEXP,
                                   "int([2-4](x[2-4])?)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.HALF,
                                   "HALF",
                                   TokenPattern.PatternType.REGEXP,
                                   "half([2-4](x[2-4])?)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.DOUBLE,
                                   "DOUBLE",
                                   TokenPattern.PatternType.REGEXP,
                                   "double([2-4](x[2-4])?)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BOOL,
                                   "BOOL",
                                   TokenPattern.PatternType.REGEXP,
                                   "bool([2-4](x[2-4])?)?");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BASIC_FLOAT,
                                   "BASIC_FLOAT",
                                   TokenPattern.PatternType.STRING,
                                   "float");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BASIC_INT,
                                   "BASIC_INT",
                                   TokenPattern.PatternType.STRING,
                                   "int");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BASIC_HALF,
                                   "BASIC_HALF",
                                   TokenPattern.PatternType.STRING,
                                   "half");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BASIC_BOOL,
                                   "BASIC_BOOL",
                                   TokenPattern.PatternType.STRING,
                                   "bool");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BASIC_DOUBLE,
                                   "BASIC_DOUBLE",
                                   TokenPattern.PatternType.STRING,
                                   "double");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.BASIC_UINT,
                                   "BASIC_UINT",
                                   TokenPattern.PatternType.STRING,
                                   "uint");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRE_DEFINE,
                                   "PRE_DEFINE",
                                   TokenPattern.PatternType.REGEXP,
                                   "#define[^\\n\\r]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRE_IF,
                                   "PRE_IF",
                                   TokenPattern.PatternType.REGEXP,
                                   "#if[^\\n\\r]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRE_ELSEIF,
                                   "PRE_ELSEIF",
                                   TokenPattern.PatternType.REGEXP,
                                   "#elseif[^\\n\\r]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRE_ENDIF,
                                   "PRE_ENDIF",
                                   TokenPattern.PatternType.REGEXP,
                                   "#endif[^\\n\\r]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRE_IFDEF,
                                   "PRE_IFDEF",
                                   TokenPattern.PatternType.REGEXP,
                                   "#ifdef[^\\n\\r]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRE_IFNDEF,
                                   "PRE_IFNDEF",
                                   TokenPattern.PatternType.REGEXP,
                                   "#ifndef[^\\n\\r]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRE_ERROR,
                                   "PRE_ERROR",
                                   TokenPattern.PatternType.REGEXP,
                                   "#error[^\\n\\r]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRE_INCLUDE,
                                   "PRE_INCLUDE",
                                   TokenPattern.PatternType.REGEXP,
                                   "#include[^\\n\\r]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRE_LINE,
                                   "PRE_LINE",
                                   TokenPattern.PatternType.REGEXP,
                                   "#line[^\\n\\r]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.PRE_PRAGMA,
                                   "PRE_PRAGMA",
                                   TokenPattern.PatternType.REGEXP,
                                   "#pragma[^\\n\\r]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.NOINTERPOLATION,
                                   "NOINTERPOLATION",
                                   TokenPattern.PatternType.STRING,
                                   "nointerpolation");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.IDENTIFIER,
                                   "IDENTIFIER",
                                   TokenPattern.PatternType.REGEXP,
                                   "[A-Za-z_][A-Za-z0-9_]*");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.QUOTED_STRING,
                                   "QUOTED_STRING",
                                   TokenPattern.PatternType.REGEXP,
                                   "\"([^\"]|\"\")*+\"");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.COMMENT,
                                   "COMMENT",
                                   TokenPattern.PatternType.REGEXP,
                                   "/\\*([^*]|\\*[^/])*\\*/");
        AddPattern(pattern);

        pattern = new TokenPattern((int) HlslConstants.COMMENTCPP,
                                   "COMMENTCPP",
                                   TokenPattern.PatternType.REGEXP,
                                   "//[^\\n\\r]*");
        AddPattern(pattern);
    }
Exemplo n.º 40
0
 /**
  * Clears the current match information.
  */
 public void Clear() {
     length = 0;
     pattern = null;
 }