示例#1
0
        public static bool IsValidPrecedingToken(this LicenseTokenType current, LicenseTokenType precedingToken)
        {
            switch (current)
            {
            case LicenseTokenType.OPENING_BRACKET:     // Legal preceding tokens: None, Operator, OpeningBracket
                return(precedingToken.IsOperator() || current == precedingToken);

            case LicenseTokenType.CLOSING_BRACKET:     // Legal preceding tokens: ClosingBracket, Identifier
                return(precedingToken == LicenseTokenType.IDENTIFIER || precedingToken == LicenseTokenType.CLOSING_BRACKET);

            case LicenseTokenType.IDENTIFIER:     // Legal preceding tokens: None, Operator, OpeningBracket
                return(precedingToken.IsOperator() || precedingToken == LicenseTokenType.OPENING_BRACKET);

            case LicenseTokenType.AND:     // Legal preceding tokens: Identifier, ClosingBracket
            case LicenseTokenType.WITH:
            case LicenseTokenType.OR:
                return(precedingToken == LicenseTokenType.IDENTIFIER || precedingToken == LicenseTokenType.CLOSING_BRACKET);

            default:
                return(false);
            }
        }
 internal LicenseExpressionToken(string value, LicenseTokenType tokenType)
 {
     Value     = value ?? throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.ArgumentCannotBeNullOrEmpty, nameof(value)));
     TokenType = tokenType;
 }
示例#3
0
 public static bool IsOperator(this LicenseTokenType tokenType)
 {
     return(tokenType == LicenseTokenType.WITH || tokenType == LicenseTokenType.AND || tokenType == LicenseTokenType.OR);
 }