Esempio n. 1
0
        private BooleanExpression ParseSimpleExpression()
        {
            BooleanExpression expression = null;

            switch (this.token)
            {
            case TokenType.LeftParenthesis:
                this.MoveNext();
                BooleanExpression c = this.ParseOrOperator();
                this.AssertTokenType(TokenType.RightParenthesis);
                expression = c;
                break;

            case TokenType.Identity:
                this.MoveNext();
                expression = new IdentityExpression(this.ParseWordExpression());
                break;

            case TokenType.Role:
                this.MoveNext();
                expression = new RoleExpression(this.ParseWordExpression());
                break;

            case TokenType.Not:
                this.MoveNext();
                expression = new NotOperator(this.ParseOrOperator());
                break;

            default:
                TokenType[] types = new TokenType[]
                {
                    TokenType.LeftParenthesis,
                    TokenType.Identity,
                    TokenType.Role,
                    TokenType.Not
                };

                throw new SyntaxException(
                          string.Format(CultureInfo.CurrentCulture, Fwk.Security.Properties.Resource.UnexpectedTokenMessage,
                                        ConcatTokenNames(types),
                                        this.lexer.Current,
                                        this.GetIndex()),
                          this.GetIndex());
            }

            return(expression);
        }
Esempio n. 2
0
        private BooleanExpression ParseSimpleExpression()
        {
            BooleanExpression expression = null;

            switch (this.token)
            {
                case TokenType.LeftParenthesis:
                    this.MoveNext();
                    BooleanExpression c = this.ParseOrOperator();
                    this.AssertTokenType(TokenType.RightParenthesis);
                    expression = c;
                    break;
                case TokenType.Identity:
                    this.MoveNext();
                    expression = new IdentityExpression(this.ParseWordExpression());
                    break;
                case TokenType.Role:
                    this.MoveNext();
                    expression = new RoleExpression(this.ParseWordExpression());
                    break;
                case TokenType.Not:
                    this.MoveNext();
                    expression = new NotOperator(this.ParseOrOperator());
                    break;
                default:
                    TokenType[] types = new TokenType[]
                        {
                            TokenType.LeftParenthesis,
                            TokenType.Identity,
                            TokenType.Role,
                            TokenType.Not
                        };

                    throw new SyntaxException(
                        string.Format(CultureInfo.CurrentCulture, Fwk.Security.Properties.Resource.UnexpectedTokenMessage,
                            ConcatTokenNames(types),
                            this.lexer.Current,
                            this.GetIndex()),
                        this.GetIndex());
            }

            return expression;
        }