//*
        // * Parses a production pattern. A parse tree node may or may
        // * not be created depending on the analyzer callbacks.
        // *
        // * @param pattern the production pattern to parse
        // *
        // * @return the parse tree node created, or null
        // *
        // * @throws ParseException if the input couldn't be parsed
        // * correctly
        //

        private Node ParsePattern(ProductionPattern pattern)
        {
            ProductionPatternAlternative alt        = default(ProductionPatternAlternative);
            ProductionPatternAlternative defaultAlt = default(ProductionPatternAlternative);

            defaultAlt = pattern.DefaultAlternative;
            for (int i = 0; i <= pattern.Count - 1; i++)
            {
                alt = pattern[i];
                if (!object.ReferenceEquals(defaultAlt, alt) && IsNext(alt))
                {
                    return(ParseAlternative(alt));
                }
            }
            if (defaultAlt == null || !IsNext(defaultAlt))
            {
                ThrowParseException(FindUnion(pattern));
            }
            return(ParseAlternative(defaultAlt));
        }
        //*
        // * Finds the look-ahead set for a production pattern alternative.
        // * The pattern position and maximum look-ahead length must be
        // * specified. It is also possible to specify a look-ahead set
        // * filter, which will make sure that unnecessary token sequences
        // * will be avoided.
        // *
        // * @param alt the production pattern alternative
        // * @param length the maximum look-ahead length
        // * @param pos the pattern element position
        // * @param stack the call stack used for loop detection
        // * @param filter the look-ahead set filter
        // *
        // * @return the look-ahead set for the pattern alternative
        // *
        // * @throws ParserCreationException if an infinite loop was found
        // * in the grammar
        //

        private LookAheadSet FindLookAhead(ProductionPatternAlternative alt, int length, int pos, CallStack stack, LookAheadSet filter)
        {
            LookAheadSet first    = default(LookAheadSet);
            LookAheadSet follow   = default(LookAheadSet);
            LookAheadSet overlaps = default(LookAheadSet);

            // Check trivial cases
            if (length <= 0 || pos >= alt.Count)
            {
                return(new LookAheadSet(0));
            }

            // Find look-ahead for this element
            first = FindLookAhead(alt[pos], length, stack, filter);
            if (alt[pos].MinCount == 0)
            {
                first.AddEmpty();
            }

            // Find remaining look-ahead
            if (filter == null)
            {
                length -= first.GetMinLength();
                if (length > 0)
                {
                    follow = FindLookAhead(alt, length, pos + 1, stack, null);
                    first  = first.CreateCombination(follow);
                }
            }
            else if (filter.IsOverlap(first))
            {
                overlaps = first.CreateOverlaps(filter);
                length  -= overlaps.GetMinLength();
                filter   = filter.CreateFilter(overlaps);
                follow   = FindLookAhead(alt, length, pos + 1, stack, filter);
                first.RemoveAll(overlaps);
                first.AddAll(overlaps.CreateCombination(follow));
            }

            return(first);
        }
        //*
        // * Parses a production pattern alternative. A parse tree node
        // * may or may not be created depending on the analyzer
        // * callbacks.
        // *
        // * @param alt the production pattern alternative
        // *
        // * @return the parse tree node created, or null
        // *
        // * @throws ParseException if the input couldn't be parsed
        // * correctly
        //

        private Node ParseAlternative(ProductionPatternAlternative alt)
        {
            Production node = default(Production);

            node = new Production(alt.Pattern);
            EnterNode(node);
            for (int i = 0; i <= alt.Count - 1; i++)
            {
                try
                {
                    ParseElement(node, alt[i]);
                }
                catch (ParseException e)
                {
                    AddError(e, true);
                    NextToken();
                    i -= 1;
                }
            }
            return(ExitNode(node));
        }
        //*
        // * Calculates the look-ahead needed for the specified production
        // * pattern. This method attempts to resolve any conflicts and
        // * stores the results in the pattern look-ahead object.
        // *
        // * @param pattern the production pattern
        // *
        // * @throws ParserCreationException if the look-ahead set couldn't
        // * be determined due to inherent ambiguities
        //

        private void CalculateLookAhead(ProductionPattern pattern)
        {
            ProductionPatternAlternative alt = default(ProductionPatternAlternative);
            LookAheadSet result = default(LookAheadSet);

            LookAheadSet[] alternatives = null;
            LookAheadSet   conflicts    = default(LookAheadSet);
            LookAheadSet   previous     = new LookAheadSet(0);
            int            length       = 1;
            int            i            = 0;
            CallStack      stack        = new CallStack();

            // Calculate simple look-ahead
            stack.Push(pattern.Name, 1);
            result       = new LookAheadSet(1);
            alternatives = new LookAheadSet[pattern.Count];
            for (i = 0; i <= pattern.Count - 1; i++)
            {
                alt             = pattern[i];
                alternatives[i] = FindLookAhead(alt, 1, 0, stack, null);
                alt.LookAhead   = alternatives[i];
                result.AddAll(alternatives[i]);
            }
            if (pattern.LookAhead == null)
            {
                pattern.LookAhead = result;
            }
            conflicts = FindConflicts(pattern, 1);

            // Resolve conflicts
            while (conflicts.Size() > 0)
            {
                length += 1;
                stack.Clear();
                stack.Push(pattern.Name, length);
                conflicts.AddAll(previous);
                for (i = 0; i <= pattern.Count - 1; i++)
                {
                    alt = pattern[i];
                    if (alternatives[i].Intersects(conflicts))
                    {
                        alternatives[i] = FindLookAhead(alt, length, 0, stack, conflicts);
                        alt.LookAhead   = alternatives[i];
                    }
                    if (alternatives[i].Intersects(conflicts))
                    {
                        if (pattern.DefaultAlternative == null)
                        {
                            pattern.DefaultAlternative = alt;
                        }
                        else if (!object.ReferenceEquals(pattern.DefaultAlternative, alt))
                        {
                            result = alternatives[i].CreateIntersection(conflicts);
                            ThrowAmbiguityException(pattern.Name, null, result);
                        }
                    }
                }
                previous  = conflicts;
                conflicts = FindConflicts(pattern, length);
            }
            for (i = 0; i <= pattern.Count - 1; i++)
            {
                // Resolve conflicts inside rules
                CalculateLookAhead(pattern[i], 0);
            }
        }
示例#5
0
        ///<summary>Initializes the parser by creating all the production
        ///patterns.</summary>
        ///
        ///<exception cref='ParserCreationException'>if the parser
        ///couldn't be initialized correctly</exception>
        private void CreatePatterns()
        {
            ProductionPattern            pattern = default(ProductionPattern);
            ProductionPatternAlternative alt     = default(ProductionPatternAlternative);

            pattern = new ProductionPattern((int)ExpressionConstants.EXPRESSION, "Expression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.XOR_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.XOR_EXPRESSION, "XorExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.OR_EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_1, 0, -1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.OR_EXPRESSION, "OrExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.AND_EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_2, 0, -1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.AND_EXPRESSION, "AndExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.NOT_EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_3, 0, -1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.NOT_EXPRESSION, "NotExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.NOT, 0, 1);
            alt.AddProduction((int)ExpressionConstants.IN_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.IN_EXPRESSION, "InExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.COMPARE_EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_4, 0, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.IN_TARGET_EXPRESSION, "InTargetExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.FIELD_PROPERTY_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.IN_LIST_TARGET_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.IN_LIST_TARGET_EXPRESSION, "InListTargetExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.LEFT_PAREN, 1, 1);
            alt.AddProduction((int)ExpressionConstants.ARGUMENT_LIST, 1, 1);
            alt.AddToken((int)ExpressionConstants.RIGHT_PAREN, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.COMPARE_EXPRESSION, "CompareExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.SHIFT_EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_6, 0, -1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.SHIFT_EXPRESSION, "ShiftExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.ADDITIVE_EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_8, 0, -1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.ADDITIVE_EXPRESSION, "AdditiveExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.MULTIPLICATIVE_EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_10, 0, -1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.MULTIPLICATIVE_EXPRESSION, "MultiplicativeExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.POWER_EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_12, 0, -1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.POWER_EXPRESSION, "PowerExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.NEGATE_EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_13, 0, -1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.NEGATE_EXPRESSION, "NegateExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.SUB, 0, 1);
            alt.AddProduction((int)ExpressionConstants.MEMBER_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.MEMBER_EXPRESSION, "MemberExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.BASIC_EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_14, 0, -1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.MEMBER_ACCESS_EXPRESSION, "MemberAccessExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.DOT, 1, 1);
            alt.AddProduction((int)ExpressionConstants.MEMBER_FUNCTION_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.BASIC_EXPRESSION, "BasicExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.LITERAL_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.EXPRESSION_GROUP, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.MEMBER_FUNCTION_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.SPECIAL_FUNCTION_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.MEMBER_FUNCTION_EXPRESSION, "MemberFunctionExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.FIELD_PROPERTY_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.FUNCTION_CALL_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.FIELD_PROPERTY_EXPRESSION, "FieldPropertyExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.IDENTIFIER, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.SPECIAL_FUNCTION_EXPRESSION, "SpecialFunctionExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.IF_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.CAST_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.IF_EXPRESSION, "IfExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.IF, 1, 1);
            alt.AddToken((int)ExpressionConstants.LEFT_PAREN, 1, 1);
            alt.AddProduction((int)ExpressionConstants.EXPRESSION, 1, 1);
            alt.AddToken((int)ExpressionConstants.ARGUMENT_SEPARATOR, 1, 1);
            alt.AddProduction((int)ExpressionConstants.EXPRESSION, 1, 1);
            alt.AddToken((int)ExpressionConstants.ARGUMENT_SEPARATOR, 1, 1);
            alt.AddProduction((int)ExpressionConstants.EXPRESSION, 1, 1);
            alt.AddToken((int)ExpressionConstants.RIGHT_PAREN, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.CAST_EXPRESSION, "CastExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.CAST, 1, 1);
            alt.AddToken((int)ExpressionConstants.LEFT_PAREN, 1, 1);
            alt.AddProduction((int)ExpressionConstants.EXPRESSION, 1, 1);
            alt.AddToken((int)ExpressionConstants.ARGUMENT_SEPARATOR, 1, 1);
            alt.AddProduction((int)ExpressionConstants.CAST_TYPE_EXPRESSION, 1, 1);
            alt.AddToken((int)ExpressionConstants.RIGHT_PAREN, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.CAST_TYPE_EXPRESSION, "CastTypeExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.IDENTIFIER, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_15, 0, -1);
            alt.AddToken((int)ExpressionConstants.ARRAY_BRACES, 0, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.INDEX_EXPRESSION, "IndexExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.LEFT_BRACE, 1, 1);
            alt.AddProduction((int)ExpressionConstants.ARGUMENT_LIST, 1, 1);
            alt.AddToken((int)ExpressionConstants.RIGHT_BRACE, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.FUNCTION_CALL_EXPRESSION, "FunctionCallExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.IDENTIFIER, 1, 1);
            alt.AddToken((int)ExpressionConstants.LEFT_PAREN, 1, 1);
            alt.AddProduction((int)ExpressionConstants.ARGUMENT_LIST, 0, 1);
            alt.AddToken((int)ExpressionConstants.RIGHT_PAREN, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.ARGUMENT_LIST, "ArgumentList");
            alt     = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.EXPRESSION, 1, 1);
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_16, 0, -1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.LITERAL_EXPRESSION, "LiteralExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.INTEGER, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.REAL, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.STRING_LITERAL, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.BOOLEAN_LITERAL_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.HEX_LITERAL, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.CHAR_LITERAL, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.NULL_LITERAL, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.DATETIME, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.TIMESPAN, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.BOOLEAN_LITERAL_EXPRESSION, "BooleanLiteralExpression");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.TRUE, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.FALSE, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern = new ProductionPattern((int)ExpressionConstants.EXPRESSION_GROUP, "ExpressionGroup");
            alt     = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.LEFT_PAREN, 1, 1);
            alt.AddProduction((int)ExpressionConstants.EXPRESSION, 1, 1);
            alt.AddToken((int)ExpressionConstants.RIGHT_PAREN, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_1, "Subproduction1");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.XOR, 1, 1);
            alt.AddProduction((int)ExpressionConstants.OR_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_2, "Subproduction2");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.OR, 1, 1);
            alt.AddProduction((int)ExpressionConstants.AND_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_3, "Subproduction3");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.AND, 1, 1);
            alt.AddProduction((int)ExpressionConstants.NOT_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_4, "Subproduction4");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.IN, 1, 1);
            alt.AddProduction((int)ExpressionConstants.IN_TARGET_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_5, "Subproduction5");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.EQ, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.GT, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.LT, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.GTE, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.LTE, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.NE, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_6, "Subproduction6");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_5, 1, 1);
            alt.AddProduction((int)ExpressionConstants.SHIFT_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_7, "Subproduction7");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.LEFT_SHIFT, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.RIGHT_SHIFT, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_8, "Subproduction8");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_7, 1, 1);
            alt.AddProduction((int)ExpressionConstants.ADDITIVE_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_9, "Subproduction9");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.ADD, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.SUB, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_10, "Subproduction10");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_9, 1, 1);
            alt.AddProduction((int)ExpressionConstants.MULTIPLICATIVE_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_11, "Subproduction11");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.MUL, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.DIV, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.MOD, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_12, "Subproduction12");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)SynteticPatterns.SUBPRODUCTION_11, 1, 1);
            alt.AddProduction((int)ExpressionConstants.POWER_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_13, "Subproduction13");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.POWER, 1, 1);
            alt.AddProduction((int)ExpressionConstants.NEGATE_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_14, "Subproduction14");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.MEMBER_ACCESS_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            alt = new ProductionPatternAlternative();
            alt.AddProduction((int)ExpressionConstants.INDEX_EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_15, "Subproduction15");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.DOT, 1, 1);
            alt.AddToken((int)ExpressionConstants.IDENTIFIER, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);

            pattern           = new ProductionPattern((int)SynteticPatterns.SUBPRODUCTION_16, "Subproduction16");
            pattern.Synthetic = true;
            alt = new ProductionPatternAlternative();
            alt.AddToken((int)ExpressionConstants.ARGUMENT_SEPARATOR, 1, 1);
            alt.AddProduction((int)ExpressionConstants.EXPRESSION, 1, 1);
            pattern.AddAlternative(alt);
            AddPattern(pattern);
        }