mirror of https://github.com/vacp2p/research.git
abnf phone uri example
This commit is contained in:
parent
17c5d87462
commit
1105dfa7fc
|
@ -0,0 +1,32 @@
|
|||
telephone-uri = "tel:" telephone-subscriber
|
||||
telephone-subscriber = global-number / local-number
|
||||
global-number = global-number-digits *par
|
||||
local-number = local-number-digits *par context *par
|
||||
par = parameter / extension / isdn-subaddress
|
||||
isdn-subaddress = ";isub=" 1*uric
|
||||
extension = ";ext=" 1*phonedigit
|
||||
context = ";phone-context=" descriptor
|
||||
descriptor = domainname / global-number-digits
|
||||
global-number-digits = "+" *phonedigit DIGIT *phonedigit
|
||||
local-number-digits =
|
||||
*phonedigit-hex (HEXDIG / "*" / "#") *phonedigit-hex
|
||||
domainname = *( domainlabel "." ) toplabel [ "." ]
|
||||
domainlabel = alphanum
|
||||
/ alphanum *( alphanum / "-" ) alphanum
|
||||
toplabel = ALPHA / ALPHA *( alphanum / "-" ) alphanum
|
||||
parameter = ";" pname ["=" pvalue ]
|
||||
pname = 1*( alphanum / "-" )
|
||||
pvalue = 1*paramchar
|
||||
paramchar = param-unreserved / unreserved / pct-encoded
|
||||
unreserved = alphanum / mark
|
||||
mark = "-" / "_" / "." / "!" / "~" / "*" /
|
||||
"'" / "(" / ")"
|
||||
pct-encoded = "%" HEXDIG HEXDIG
|
||||
param-unreserved = "[" / "]" / "/" / ":" / "&" / "+" / "$"
|
||||
phonedigit = DIGIT / [ visual-separator ]
|
||||
phonedigit-hex = HEXDIG / "*" / "#" / [ visual-separator ]
|
||||
visual-separator = "-" / "." / "(" / ")"
|
||||
alphanum = ALPHA / DIGIT
|
||||
reserved = ";" / "/" / "?" / ":" / "@" / "&" /
|
||||
"=" / "+" / "$" / ","
|
||||
uric = reserved / unreserved / pct-encoded
|
|
@ -1,16 +1,9 @@
|
|||
(ns hello-abnf.core
|
||||
(:require [instaparse.core :as insta]))
|
||||
|
||||
(defn foo
|
||||
"I don't do a whole lot."
|
||||
[x]
|
||||
(println x "Hello, World!"))
|
||||
(def phone-uri-parser
|
||||
(insta/parser "https://raw.githubusercontent.com/Engelberg/instaparse/master/test/data/phone_uri.txt"
|
||||
:input-format :abnf))
|
||||
|
||||
(def as-and-bs
|
||||
(insta/parser
|
||||
"S = AB*
|
||||
AB = A B
|
||||
A = 'a'+
|
||||
B = 'b'+"))
|
||||
|
||||
(as-and-bs "aaaaabbbaaaabb")
|
||||
(phone-uri-parser "tel:+1-201-555-0123")
|
||||
;; => [:telephone-uri "tel:" [:telephone-subscriber [:global-number [:global-number-digits "+" [:DIGIT "1"] [:phonedigit [:visual-separator "-"]] [:phonedigit [:DIGIT "2"]] [:phonedigit [:DIGIT "0"]] [:phonedigit [:DIGIT "1"]] [:phonedigit [:visual-separator "-"]] [:phonedigit [:DIGIT "5"]] [:phonedigit [:DIGIT "5"]] [:phonedigit [:DIGIT "5"]] [:phonedigit [:visual-separator "-"]] [:phonedigit [:DIGIT "0"]] [:phonedigit [:DIGIT "1"]] [:phonedigit [:DIGIT "2"]] [:phonedigit [:DIGIT "3"]]]]]]
|
||||
|
|
Loading…
Reference in New Issue