• Jump To … +
    api.js attributes.js node-exports.js parser.js rule-attributes.js rule-dependencies.js sabnf-grammar.js scanner-callbacks.js scanner-grammar.js scanner.js semantic-callbacks.js show-rules.js syntax-callbacks.js web-exports.js converter.js node-exports.js transformers.js web-exports.js apg-conv.js help.js apg-exp.js exec.js flags.js parse-replacement.js replace-grammar.js replace.js result.js sabnf-generator.js split.js web-exports.js ast.js circular-buffer.js emitcss.js identifiers.js node-exports.js parser.js stats.js style.js trace.js utilities.js web-exports.js apg.js command-line.js LICENSE.md README.md index.md
  • identifiers.js

  • §
    /*  *************************************************************************************
     *   copyright: Copyright (c) 2021 Lowell D. Thomas, all rights reserved
     *     license: BSD-2-Clause (https://opensource.org/licenses/BSD-2-Clause)
     *   ********************************************************************************* */
  • §

    This module exposes a list of named identifiers, shared across the parser generator and the parsers that are generated.

    module.exports = {
  • §

    Identifies the operator type. Used by the generator to indicate operator types in the grammar object. Used by the parser when interpreting the grammar object.

      /* the original ABNF operators */
      ALT: 1 /* alternation */,
      CAT: 2 /* concatenation */,
      REP: 3 /* repetition */,
      RNM: 4 /* rule name */,
      TRG: 5 /* terminal range */,
      TBS: 6 /* terminal binary string, case sensitive */,
      TLS: 7 /* terminal literal string, case insensitive */,
      /* the super set, SABNF operators */
      UDT: 11 /* user-defined terminal */,
      AND: 12 /* positive look ahead */,
      NOT: 13 /* negative look ahead */,
      BKR: 14 /* back reference to a previously matched rule name */,
      BKA: 15 /* positive look behind */,
      BKN: 16 /* negative look behind */,
      ABG: 17 /* anchor - begin of string */,
      AEN: 18 /* anchor - end of string */,
  • §

    Used by the parser and the user’s RNM and UDT callback functions. Identifies the parser state as it traverses the parse tree nodes.

    • ACTIVE - indicates the downward direction through the parse tree node.
    • MATCH - indicates the upward direction and a phrase, of length > 0, has been successfully matched
    • EMPTY - indicates the upward direction and a phrase, of length = 0, has been successfully matched
    • NOMATCH - indicates the upward direction and the parser failed to match any phrase at all
      ACTIVE: 100,
      MATCH: 101,
      EMPTY: 102,
      NOMATCH: 103,
  • §

    Used by AST translator (semantic analysis) and the user’s callback functions to indicate the direction of flow through the AST nodes.

    • SEM_PRE - indicates the downward (pre-branch) direction through the AST node.
    • SEM_POST - indicates the upward (post-branch) direction through the AST node.
      SEM_PRE: 200,
      SEM_POST: 201,
  • §

    Used by the user’s callback functions to indicate to the AST translator (semantic analysis) how to proceed.

    • SEM_OK - normal return value
    • SEM_SKIP - if a callback function returns this value from the SEM_PRE state, the translator will skip processing all AST nodes in the branch below the current node. Ignored if returned from the SEM_POST state.
      SEM_OK: 300,
      SEM_SKIP: 301,
  • §

    Used in attribute generation to distinguish the necessary attribute categories.

    • ATTR_N - non-recursive
    • ATTR_R - recursive
    • ATTR_MR - belongs to a mutually-recursive set
      ATTR_N: 400,
      ATTR_R: 401,
      ATTR_MR: 402,
  • §

    Look around values indicate whether the parser is in look ahead or look behind mode. Used by the tracing facility to indicate the look around mode in the trace records display.

    • LOOKAROUND_NONE - the parser is in normal parsing mode
    • LOOKAROUND_AHEAD - the parse is in look-ahead mode, phrase matching for operator AND(&) or NOT(!)
    • LOOKAROUND_BEHIND - the parse is in look-behind mode, phrase matching for operator BKA(&&) or BKN(!!)
      LOOKAROUND_NONE: 500,
      LOOKAROUND_AHEAD: 501,
      LOOKAROUND_BEHIND: 502,
  • §

    Back reference rule mode indicators

    • BKR_MODE_UM - the back reference is using universal mode
    • BKR_MODE_PM - the back reference is using parent frame mode
    • BKR_MODE_CS - the back reference is using case-sensitive phrase matching
    • BKR_MODE_CI - the back reference is using case-insensitive phrase matching
      BKR_MODE_UM: 601,
      BKR_MODE_PM: 602,
      BKR_MODE_CS: 603,
      BKR_MODE_CI: 604,
    };