You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
401 B

  1. # frozen_string_literal: true
  2. class ScopeParser < Parslet::Parser
  3. rule(:term) { match('[a-z]').repeat(1).as(:term) }
  4. rule(:colon) { str(':') }
  5. rule(:access) { (str('write') | str('read')).as(:access) }
  6. rule(:namespace) { str('admin').as(:namespace) }
  7. rule(:scope) { ((namespace >> colon).maybe >> ((access >> colon >> term) | access | term)).as(:scope) }
  8. root(:scope)
  9. end