<!-- Generated by documentation.js. Update this documentation by updating the source code. -->### Table of Contents*   [lexgen-code][1]
*   [buildLexer][2]
    *   [Parameters][3]
*   [reset][4]
    *   [Parameters][5]
*   [next][6]
*   [save][7]
*   [formatError][8]
    *   [Parameters][9]## lexgen-codeThis module exports the functions buildLexer and nearleyLexer
that allows to create lexical analyzers**Meta***   **since**: 28/03/2223 22/03/2022
*   **author**: Casiano Rodríguez León \<crguezl\@ull.edu.es>## buildLexerCreates a lexical analyzer### Parameters*   `regexps` **[array][10]** An array of regular expressions.
    Regexps must be named using a parenthesis. Example: `/(?<NAME>.)/`.
    The whole regexp must be inside the parenthesis.
    The names SPACE and ERROR are special:<br><br>
    1\. SPACE. If something matches a parenthesis named SPACE it will
    be ignored<br><br>
    2\. ERROR. It is a special value reserved for the implementation.
    When something doesn't match any of the provided regexps it will
    be returned as error. The error will span from the point where nothing
    matched to the next whitespace(\s)<br><br>
    **Note**: When two regexps can match the one that appears
    earlier will be chosen*   Throws **[Error][11]** Will throw if each regular expression isn't named
    or has more than one nameReturns **[Object][12]** The map of valid tokens and a lexical analyzer in form of a function## resetSets the internal buffer to data, and restores line/col/state info taken from save().
Compatibility not tested### Parameters*   `data` &#x20;
*   `info` &#x20;## nextReturns e.g. {type, value, line, col, …}. Only the value attribute is required.## saveReturns an object describing the current line/col etc. This allows nearley.JS
to preserve this information between feed() calls, and also to support Parser#rewind().
The exact structure is lexer-specific; nearley doesn't care what's in it.## formatErrorReturns a string with an error message describing the line/col of the offending token.
You might like to include a preview of the line in question.### Parameters*   `token` &#x20;[1]: #lexgen-code[2]: #buildlexer[3]: #parameters[4]: #reset[5]: #parameters-1[6]: #next[7]: #save[8]: #formaterror[9]: #parameters-2[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
