lib/core.js
function processLexeme(buffer, lexeme) {
    var newMode
    var endMode
    var origin

    modeBuffer += buffer

    if (lexeme === undefined) {
      addSiblings(processBuffer(), currentChildren)

      return 0
    }

    newMode = subMode(lexeme, top)

    if (newMode) {
      addSiblings(processBuffer(), currentChildren)

      startNewMode(newMode, lexeme)

      return newMode.returnBegin ? 0 : lexeme.length
    }

    endMode = endOfMode(top, lexeme)

    if (endMode) {
      origin = top

      if (!(origin.returnEnd || origin.excludeEnd)) {
        modeBuffer += lexeme
      }

      addSiblings(processBuffer(), currentChildren)

      // Close open modes.
      do {
        if (top.className) {
          pop()
        }

        relevance += top.relevance
        top = top.parent
      } while (top !== endMode.parent)

      if (origin.excludeEnd) {
        addText(lexeme, currentChildren)
      }

      modeBuffer = ''

      if (endMode.starts) {
        startNewMode(endMode.starts, '')
      }

      return origin.returnEnd ? 0 : lexeme.length
    }

    if (isIllegal(lexeme, top)) {
      throw fault(
        'Illegal lexeme "%s" for mode "%s"',
        lexeme,
        top.className || '<unnamed>'
      )
    }

    // Parser should not reach this point as all types of lexemes should be
    // caught earlier, but if it does due to some bug make sure it advances
    // at least one character forward to prevent infinite looping.
    modeBuffer += lexeme

    return lexeme.length || /* istanbul ignore next */ 1
  }
function processLexeme(buffer, lexeme) {
    var newMode
    var endMode
    var origin

    modeBuffer += buffer

    if (lexeme === undefined) {
      addSiblings(processBuffer(), currentChildren)

      return 0
    }

    newMode = subMode(lexeme, top)

    if (newMode) {
      addSiblings(processBuffer(), currentChildren)

      startNewMode(newMode, lexeme)

      return newMode.returnBegin ? 0 : lexeme.length
    }

    endMode = endOfMode(top, lexeme)

    if (endMode) {
      origin = top

      if (!(origin.returnEnd || origin.excludeEnd)) {
        modeBuffer += lexeme
      }

      addSiblings(processBuffer(), currentChildren)

      // Close open modes.
      do {
        if (top.className) {
          pop()
        }

        relevance += top.relevance
        top = top.parent
      } while (top !== endMode.parent)

      if (origin.excludeEnd) {
        addText(lexeme, currentChildren)
      }

      modeBuffer = ''

      if (endMode.starts) {
        startNewMode(endMode.starts, '')
      }

      return origin.returnEnd ? 0 : lexeme.length
    }

    if (isIllegal(lexeme, top)) {
      throw fault(
        'Illegal lexeme "%s" for mode "%s"',
        lexeme,
        top.className || '<unnamed>'
      )
    }

    // Parser should not reach this point as all types of lexemes should be
    // caught earlier, but if it does due to some bug make sure it advances
    // at least one character forward to prevent infinite looping.
    modeBuffer += lexeme

    return lexeme.length || /* istanbul ignore next */ 1
  }
function processLexeme ( buffer , lexeme ) { var newMode var endMode var origin modeBuffer += buffer if ( lexeme === undefined ) { addSiblings ( processBuffer ( ) , currentChildren ) return 0 } newMode = subMode ( lexeme , top ) if ( newMode ) { addSiblings ( processBuffer ( ) , currentChildren ) startNewMode ( newMode , lexeme ) return newMode . returnBegin ? 0 : lexeme . length } endMode = endOfMode ( top , lexeme ) if ( endMode ) { origin = top if ( ! ( origin . returnEnd || origin . excludeEnd ) ) { modeBuffer += lexeme } addSiblings ( processBuffer ( ) , currentChildren ) // Close open modes. do { if ( top . className ) { pop ( ) } relevance += top . relevance top = top . parent } while ( top !== endMode . parent ) if ( origin . excludeEnd ) { addText ( lexeme , currentChildren ) } modeBuffer = '' if ( endMode . starts ) { startNewMode ( endMode . starts , '' ) } return origin . returnEnd ? 0 : lexeme . length } if ( isIllegal ( lexeme , top ) ) { throw fault ( 'Illegal lexeme "%s" for mode "%s"' , lexeme , top . className || '<unnamed>' ) } // Parser should not reach this point as all types of lexemes should be // caught earlier, but if it does due to some bug make sure it advances // at least one character forward to prevent infinite looping. modeBuffer += lexeme return lexeme . length || /* istanbul ignore next */ 1 }
Process a lexeme.  Returns next position.
Process a lexeme . Returns next position .