Sha256: 52baa8d418d9227bb04e6efa7ad7164756800a28abc27c4c7d276bb46c607230

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

grammar SpdxGrammar

  rule spdx_expression
    compound_expression / none / no_assertion
  end

  rule compound_expression
    '(' body ')' <CompoundExpression>
  end

  rule body
    ( compound_expression / and / or / with / license_ref / document_ref / license )* <Body>
  end

  rule and
    space "AND" space !reserve_words <LogicalAnd>
  end

  rule or
    space "OR" space !reserve_words <LogicalOr>
  end

  rule with
    space "WITH" space license_exception <With>
  end

  rule license
    [a-zA-Z0-9\-\.\+]+ &{|seq| Spdx.license_exists?(seq.first.text_value) || Spdx.license_exists?(seq.first.text_value.delete_suffix('+')) }  <License>
  end

  rule license_ref
    "LicenseRef-" [a-zA-Z0-9\-\.]+ <LicenseRef>
  end

  rule document_ref
    "DocumentRef-" [a-zA-Z0-9\-\.]+ ":" license_ref <DocumentRef>
  end

  rule license_exception
    [a-zA-Z0-9\-\.]+ &{|seq| Spdx.exception_exists?(seq.first.text_value) } <LicenseException>
  end

  rule reserve_words
    "AND" / "OR" / "WITH"
  end

  rule none
    "NONE" <None>
  end

  rule no_assertion
    "NOASSERTION" <NoAssertion>
  end

  rule space
    [\s]+
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spdx-3.1.0 lib/spdx_parser.treetop
spdx-3.0.1 lib/spdx_parser.treetop
spdx-3.0.0 lib/spdx_parser.treetop