licence_audit/spdx_expression
SPDX expression syntax, independent of licence policy and text retrieval. Identifiers are checked for syntax, not membership in the SPDX licence list.
Types
pub type Expression {
Licence(id: String)
With(licence: String, exception: String)
And(left: Expression, right: Expression)
Or(left: Expression, right: Expression)
}
Constructors
-
Licence(id: String) -
With(licence: String, exception: String) -
And(left: Expression, right: Expression) -
Or(left: Expression, right: Expression)
pub type ParseError {
InvalidExpression
ExpressionTooLarge
NestingTooDeep
}
Constructors
-
InvalidExpression -
ExpressionTooLarge -
NestingTooDeep
Values
pub fn matching_tokens(expression: String) -> List(String)
Normalize matching tokens while preserving custom reference case and syntax.
pub fn parse(input: String) -> Result(Expression, ParseError)
Parse SPDX operators in precedence order: WITH, AND, OR. Limit untrusted input to 64 KiB, 1024 tokens, and 64 nested parentheses.