module Canql

grammar Registry
  rule registry
    space registry:(registry_code / registry_abbr) <Nodes::RegistryNode>
  end

  rule processing_registry
    space registry:(registry_code / registry_abbr) <Nodes::ProcessingRegistryNode>
  end

  rule registry_code
    [0-9] 2..2 <Nodes::RegistryCodeNode>
  end

  rule registry_abbr
    (england / east_mids / thames / east / yorkshire / north_east / north_west /
      west_mids / south_west_supra / south_west / wessex / london / limbo /
      northern_supra / midlands_east_supra)
  end

  rule thames
    ('thames valley' / 'thames')
    {
      def to_registrycode
        'thames'
      end
    }
  end

  rule east_mids
    ('east mids' / 'east midlands and south yorkshire' / 'east midlands')
    {
      def to_registrycode
        'east_mids'
      end
    }
  end

  rule yorkshire
    'yorkshire'
    {
      def to_registrycode
        'yorkshire'
      end
    }
  end

  rule north_east
    'north east'
    {
      def to_registrycode
        'north_east'
      end
    }
  end

  rule north_west
    'north west'
    {
      def to_registrycode
        'north_west'
      end
    }
  end

  rule west_mids
    ('west mids' / 'west midlands')
    {
      def to_registrycode
        'west_mids'
      end
    }
  end

  rule south_west
    'south west'
    {
      def to_registrycode
        'south_west'
      end
    }
  end

  rule wessex
    'wessex'
    {
      def to_registrycode
        'wessex'
      end
    }
  end

  rule london
    ('london and south east' / 'london')
    {
      def to_registrycode
        'london'
      end
    }
  end

  rule east
    ('east of england' / 'east')
    {
      def to_registrycode
        'east'
      end
    }
  end

  rule limbo
    'limbo'
    {
      def to_registrycode
        'limbo'
      end
    }
  end

  rule england
    'england'
    {
      def to_registrycode
        'england'
      end
    }
  end

  rule northern_supra
    ('northern supra' / 'northern')
    {
      def to_registrycode
        'northern_supra'
      end
    }
  end

  rule midlands_east_supra
    ('midlands & east supra' / 'midlands & east')
    {
      def to_registrycode
        'midlands_east_supra'
      end
    }
  end

  rule south_west_supra
    'south west supra'
    {
      def to_registrycode
        'south_west_supra'
      end
    }
  end
end

end