summaryrefslogtreecommitdiffstats
path: root/aconf/path/address/init.lua
blob: c62487f2f60c02b041876f4652a436830889f6f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--[[
Copyright (c) 2012-2015 Kaarle Ritvanen
See LICENSE file for license details
--]]

local object = require('aconf.object')
local class = object.class

local special = require('aconf.path.address.special')
local base = require('aconf.path.base')


local M = {
   special={
      enum_keys=special.EnumKeys(),
      value=special.Value(),
      value_equals=special.ValueEquals
   }
}

local _special = {['#']=M.special.enum_keys, ['&']=M.special.value}


local AddressSyntax = class(base.Syntax)

function AddressSyntax:get_special(comp)
   if comp:sub(1, 1) == '@' then
      return special.ValueEquals(#comp > 1 and comp:sub(2, -1) or nil)
   end
   return _special[comp] or object.super(self, AddressSyntax):get_special(comp)
end

return AddressSyntax():export(M)