UNPKG

uri-template-router

Version:

Match a URI to a pattern in a collection of URI Templates

57 lines (55 loc) 2.43 kB
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>abnf.rb</title> </head> <body> <h1><a name="label-0" id="label-0">ABNF</a></h1><!-- RDLabel: "ABNF" --> <p>convert ABNF to Regexp.</p> <h2><a name="label-1" id="label-1">Example</a></h2><!-- RDLabel: "Example" --> <pre># IPv6 [RFC2373] p %r{\A#{ABNF.regexp &lt;&lt;'End'}\z}o =~ "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210" IPv6address = hexpart [ ":" IPv4address ] IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT hexpart = hexseq | hexseq "::" [ hexseq ] | "::" [ hexseq ] hexseq = hex4 *( ":" hex4) hex4 = 1*4HEXDIG End</pre> <p>Note that this is wrong because it doesn't match to "::13.1.68.3".</p> <pre># URI-reference [RFC2396] p %r{\A#{ABNF.regexp &lt;&lt;'End'}\z}o URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] ... digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" End</pre> <h2><a name="label-2" id="label-2">ABNF</a></h2><!-- RDLabel: "ABNF" --> <h3><a name="label-3" id="label-3">class methods</a></h3><!-- RDLabel: "class methods" --> <dl> <dt><a name="label-4" id="label-4"><code>ABNF.regexp(<var>abnf_description</var>, <var>start_symbol</var>=<var>nil</var>)</code></a></dt><!-- RDLabel: "ABNF.regexp" --> <dd> <p>converts <var>abnf_description</var> to a Regexp object corresponding with <var>start_symbol</var>.</p> <p>If <var>start_symbol</var> is not specified, first symbol in <var>abnf_description</var> is used.</p></dd> <dt><a name="label-5" id="label-5"><code>ABNF.regexp_tree(<var>abnf_description</var>, <var>start_symbol</var>=<var>nil</var>)</code></a></dt><!-- RDLabel: "ABNF.regexp_tree" --> <dd> converts <var>abnf_description</var> to a <a href="regexptree.html">RegexpTree</a> object corresponding with <var>start_symbol</var>.</dd> </dl> <h3><a name="label-6" id="label-6">constants</a></h3><!-- RDLabel: "constants" --> <dl> <dt><a name="label-7" id="label-7"><code>TooComplex</code></a></dt><!-- RDLabel: "TooComplex" --> <dd> is a subclass of StandardError. It is raised when ABNF grammar is too complex to convert to Regexp.</dd> </dl> <h1><a name="label-8" id="label-8">Note</a></h1><!-- RDLabel: "Note" --> <ul> <li>Wrong ABNF description produces wrong regexp.</li> </ul> </body> </html>