1
0

scope_parser.rb 401 B

12345678910
  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