示例#1
0
        private void EvalCommentsState(char token, bool escaped)
        {
            switch (commentsState)
            {
            case CommentsState.None:
                if (!escaped)
                {
                    if (token == '#')
                    {
                        if (patternState == PatternState.StartGroup)
                        {
                            commentsState = CommentsState.CommentsGroup;
                        }
                        else if (ignorePatternWhitespace)
                        {
                            commentsState = CommentsState.CommentsLine;
                        }
                        else
                        {
                            EvalGroupState(token, escaped);
                        }
                    }
                    else
                    {
                        EvalGroupState(token, escaped);
                    }
                }
                else
                {
                    EvalGroupState(token, escaped);
                }
                break;

            case CommentsState.CommentsLine:
                if (token == 'n' && escaped)
                {
                    commentsState = CommentsState.None;
                }
                break;

            case CommentsState.CommentsGroup:
                if (token == ')' && !escaped)
                {
                    CommentsGroupFound(startGroupIndex, currentIndex + 1);

                    groupLevel--;
                    patternState    = previousPatternState;
                    startGroupIndex = previousStartGroupIndex;

                    commentsState = CommentsState.None;
                }
                break;
            }
        }
示例#2
0
        private void EvalCommentsState(char token, bool escaped)
        {
            switch (commentsState)
            {
                case CommentsState.None:
                    if (!escaped)
                    {
                        if (token == '#')
                        {
                            if (patternState == PatternState.StartGroup)
                            {
                                commentsState = CommentsState.CommentsGroup;
                            }
                            else if (ignorePatternWhitespace)
                            {
                                commentsState = CommentsState.CommentsLine;
                            }
                            else
                            {
                                EvalGroupState(token, escaped);
                            }
                        }
                        else
                        {
                            EvalGroupState(token, escaped);
                        }
                    }
                    else
                    {
                        EvalGroupState(token, escaped);
                    }
                    break;
                case CommentsState.CommentsLine:
                    if(token == 'n' && escaped)
                    {
                        commentsState = CommentsState.None;
                    }
                    break;
                case CommentsState.CommentsGroup:
                    if (token == ')' && !escaped)
                    {
                        CommentsGroupFound(startGroupIndex, currentIndex+1);

                        groupLevel--;
                        patternState = previousPatternState;
                        startGroupIndex = previousStartGroupIndex;

                        commentsState = CommentsState.None;
                    }
                    break;
            }
        }
 public static CommentsState ReduceAddAction(CommentsState state, CommentsAddAction action) =>