UNPKG

buffer-apg-js

Version:

JavaScript APG, an ABNF Parser Generator

50 lines (49 loc) 1.6 kB
<!DOCTYPE html> <html lang="en"> <head> <title>apg-exp</title> <meta charset="utf-8"> <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>Method: defineUdt()</h1> <p> <b>APG</b> parsers provide for user-written, phrase-matching functions. These are called "User Defined Terminals" or UDTs. UDTs can be used in <b>apg-exp</b> pattern syntax as well. This provides the user the opportunity to hand write a JavaScript function for special phrase-matching needs. The <kbd>defineUdt()</kbd> method is used to tell <b>apg-exp</b> what function to use. </p> <h3>Syntax</h3> <pre> var exp = new apgExp(pattern[, flags]); exp.defineUdt(name, function); </pre> <h3>Parameters</h3> <ul> <li>name: string: The name of the UDT as specified in the pattern syntax.</li> <li>function: a function reference to the user-written UDT.</li> </ul> <h3>Return</h3> <p><i>none</i></p> <h3>Examples</h3> <p> The use of <b>APG</b>'s UDTs is beyond the scope of this guide. See the <a href="https://github.com/ldthomas/apg-js2-examples/tree/master/apg-exp">examples</a> in the GitHub repository. </p> </div> </div> <div id="footer"></div> </div> </body> </html>