UNPKG

buffer-apg-js

Version:

JavaScript APG, an ABNF Parser Generator

116 lines (115 loc) 7.53 kB
<!DOCTYPE html> <html lang="en"> <head> <title>apg-exp</title> <meta charset="utf-8"> <link rel="stylesheet" href="./css/apgexp.css" type="text/css" /> <link rel="stylesheet" href="./css/BrightSide.css" type="text/css" /> <script type="text/javascript" src="./import.js"></script> </head> <body> <div id="wrap"> <div id="header"></div> <div id="content-wrap"> <img src="./images/PointLobosCropped.jpg" width="820" height="120" alt="headerphoto" class="no-border" /> <div id="sidebar"></div> <div id="main-2col"> <!-- page content goes here --> <h1>Debug Mode</h1> <h3>Syntax</h3> <pre> var exp = new apgExp(pattern, "d"); </pre> <p>Debug mode exposes the <b>APG</b> trace object</a> as <kbd>exp.trace</kbd>. It can be used to display the path of the parser through the parse tree. If the debug property is <kbd>false</kbd>, <kbd>exp.trace</kbd> is undefined. </p> <h3>Example</h3> <p> <pre> var pattern, str, exp, result; pattern = 'word = alpha *(alpha / num)\n'; pattern += 'alpha = %d65-90 / %d97-122\n'; pattern += 'num = %d48-57\n'; exp = new apgExp(pattern, "yd"); str = "ab12"; result = exp.exec(str); if(result){ var htmlPage = exp.trace.toHtmlPage(); /* display as HTML page */ var html = exp.trace.toHtml(); /* display in HTML page */ console.log(html); } /* returns */ </pre> <h1>JavaScript APG Trace</h1> <h3>&nbsp;&nbsp;&nbsp;&nbsp;display mode: ASCII</h3> <h5>&nbsp;&nbsp;&nbsp;&nbsp;Thu May 19 2016 14:06:20 GMT-0400 (EDT)</h5> <table class="apg-last2-left-table"> <tr><th>(a)</th><th>(b)</th><th>(c)</th><th>(d)</th><th>(e)</th><th>(f)</th><th>operator</th><th>phrase</th></tr> <tr><td>0</td><td>13</td><td>0</td><td>0</td><td>0</td><td><span class="apg-active">&darr;&nbsp;</span></td><td>RNM(word) </td><td><span class="apg-remainder">ab12</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>1</td><td>2</td><td>0</td><td>0</td><td>1</td><td><span class="apg-active">&darr;&nbsp;</span></td><td>.RNM(alpha) </td><td><span class="apg-remainder">ab12</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>2</td><td>1</td><td>0</td><td>1</td><td>1</td><td><span class="apg-match">&uarr;M</span></td><td>.RNM(alpha) </td><td><span class="apg-match">a</span><span class="apg-remainder">b12</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>3</td><td>4</td><td>1</td><td>0</td><td>1</td><td><span class="apg-active">&darr;&nbsp;</span></td><td>.RNM(alpha) </td><td><span class="apg-remainder">b12</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>4</td><td>3</td><td>1</td><td>1</td><td>1</td><td><span class="apg-match">&uarr;M</span></td><td>.RNM(alpha) </td><td><span class="apg-match">b</span><span class="apg-remainder">12</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>5</td><td>6</td><td>2</td><td>0</td><td>1</td><td><span class="apg-active">&darr;&nbsp;</span></td><td>.RNM(alpha) </td><td><span class="apg-remainder">12</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>6</td><td>5</td><td>2</td><td>0</td><td>1</td><td><span class="apg-nomatch">&uarr;N</span></td><td>.RNM(alpha) </td><td><span class="apg-remainder">12</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>7</td><td>8</td><td>2</td><td>0</td><td>1</td><td><span class="apg-active">&darr;&nbsp;</span></td><td>.RNM(num) </td><td><span class="apg-remainder">12</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>8</td><td>7</td><td>2</td><td>1</td><td>1</td><td><span class="apg-match">&uarr;M</span></td><td>.RNM(num) </td><td><span class="apg-match">1</span><span class="apg-remainder">2</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>9</td><td>10</td><td>3</td><td>0</td><td>1</td><td><span class="apg-active">&darr;&nbsp;</span></td><td>.RNM(alpha) </td><td><span class="apg-remainder">2</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>10</td><td>9</td><td>3</td><td>0</td><td>1</td><td><span class="apg-nomatch">&uarr;N</span></td><td>.RNM(alpha) </td><td><span class="apg-remainder">2</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>11</td><td>12</td><td>3</td><td>0</td><td>1</td><td><span class="apg-active">&darr;&nbsp;</span></td><td>.RNM(num) </td><td><span class="apg-remainder">2</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>12</td><td>11</td><td>3</td><td>1</td><td>1</td><td><span class="apg-match">&uarr;M</span></td><td>.RNM(num) </td><td><span class="apg-match">2</span><span class="apg-line-end">&bull;</span></td></tr> <tr><td>13</td><td>0</td><td>0</td><td>4</td><td>0</td><td><span class="apg-match">&uarr;M</span></td><td>RNM(word) </td><td><span class="apg-match">ab12</span><span class="apg-line-end">&bull;</span></td></tr> <tr><th>(a)</th><th>(b)</th><th>(c)</th><th>(d)</th><th>(e)</th><th>(f)</th><th>operator</th><th>phrase</th></tr> </table> </table> <p class="apg-mono">legend:<br> (a)&nbsp;-&nbsp;line number<br> (b)&nbsp;-&nbsp;matching line number<br> (c)&nbsp;-&nbsp;phrase offset<br> (d)&nbsp;-&nbsp;phrase length<br> (e)&nbsp;-&nbsp;tree depth<br> (f)&nbsp;-&nbsp;operator state<br> &nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-active">&darr;</span>&nbsp;&nbsp;phrase opened<br> &nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-match">&uarr;M</span> phrase matched<br> &nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-empty">&uarr;E</span> empty phrase matched<br> &nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-nomatch">&uarr;N</span> phrase not matched<br> operator&nbsp;-&nbsp;ALT, CAT, REP, RNM, TRG, TLS, TBS<sup>&dagger;</sup>, UDT, AND, NOT, BKA, BKN, BKR, ABG, AEN<sup>&Dagger;</sup><br> phrase&nbsp;&nbsp;&nbsp;-&nbsp;up to 80 characters of the phrase being matched<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-match">matched characters</span><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-lh-match">matched characters in look ahead mode</span><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-lb-match">matched characters in look behind mode</span><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-remainder">remainder characters(not yet examined by parser)</span><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-ctrl-char">control characters, TAB, LF, CR, etc. (ASCII mode only)</span><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-empty">&#120634;</span> empty string<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-line-end">&bull;</span> end of input string<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<span class="apg-line-end">&hellip;</span> input string display truncated<br> </p> <p class="apg-mono"> <sup>&dagger;</sup>original ABNF operators:<br> ALT - alternation<br> CAT - concatenation<br> REP - repetition<br> RNM - rule name<br> TRG - terminal range<br> TLS - terminal literal string (case insensitive)<br> TBS - terminal binary string (case sensitive)<br> <br> <sup>&Dagger;</sup>super set SABNF operators:<br> UDT - user-defined terminal<br> AND - positive look ahead<br> NOT - negative look ahead<br> BKA - positive look behind<br> BKN - negative look behind<br> BKR - back reference<br> ABG - anchor - begin of input string<br> AEN - anchor - end of input string<br> </p> </div> </div> <div id="footer"></div> </div> </body> </html>