%% name = PhoneNumber

%% {
	attr_accessor :phone_number
}
digit = [0-9]
space = " "
dash = "-"
LP = "("
RP = ")"

country_code = < digit > { text }
area_code = < digit[3] > { text }
prefix = < digit[3] > { text }
suffix = < digit[4] > { text }

phone_number = LP? area_code:ac RP? space* prefix:p space* dash? space* suffix:s space* { "(#{ac}) #{p}-#{s}" } 

root = phone_number:pn { @phone_number = pn }
		| country_code:c space* phone_number:pn { @phone_number = "+#{c} #{pn}" }