www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

parseData.js (1261B)


      1 /**
      2  * The resulting parse tree nodes of the parse tree.
      3  *
      4  * It is possible to provide position information, so that a ParseNode can
      5  * fulfil a role similar to a Token in error reporting.
      6  * For details on the corresponding properties see Token constructor.
      7  * Providing such information can lead to better error reporting.
      8  *
      9  * @param {string}  type       type of node, like e.g. "ordgroup"
     10  * @param {?object} value      type-specific representation of the node
     11  * @param {string}  mode       parse mode in action for this node,
     12  *                             "math" or "text"
     13  * @param {Token=} firstToken  first token of the input for this node,
     14  *                             will omit position information if unset
     15  * @param {Token=} lastToken   last token of the input for this node,
     16  *                             will default to firstToken if unset
     17  */
     18 function ParseNode(type, value, mode, firstToken, lastToken) {
     19     this.type = type;
     20     this.value = value;
     21     this.mode = mode;
     22     if (firstToken && (!lastToken || lastToken.lexer === firstToken.lexer)) {
     23         this.lexer = firstToken.lexer;
     24         this.start = firstToken.start;
     25         this.end = (lastToken || firstToken).end;
     26     }
     27 }
     28 
     29 module.exports = {
     30     ParseNode: ParseNode,
     31 };
     32