Loading TOC...

MarkLogic 9 Product Documentation
clang.lexer

clang.lexer(
   variant as String,
   [normalization as String?],
   [args as Sequence],
   [library as String]
) as element(lang.lexer)

Summary

This function constructs a custom lexer configuration item, suitable for use with clang.userLanguagePlugin.

Parameters
variant The name of the lexer plugin, either the name of one of the built-in lexers, or the name of a user-defined lexer capability. The latter should be the name of a LexerUDF capability registered by your plugin when MarkLogic calls Registry::registerLexer.
normalization The normalization that should be used to present text runs to the plugin lexer. Either "NFC" or "NFD". Default: NFC.
args A sequence of arguments that will be passed to the initialization of the plugin lexer as a sequence of strings.
library The name of the library containing variant. You should use an empty string when configuring a built-in plugin. If you omit this parameter, the library from the enclosing plugin configuration is used. See the Usage Notes for details.

Usage Notes

If you specify a library name in clang.lexer and when passing a lexer to clang.userLanguagePlugin then the value in the lexer takes precedence over the value in the plugin configuration.

For a built-in lexer, specify an empty string for the library name, or omit the library parameter and specify an empty string in clang.userLanguagePlugin.

For a user-defined plugin, the library name should be of the form plugin_path/plugin_id, such as "native/sample_plugin". If you omit this parameter, then the library value from clang.userLanguagePlugin will be used.

See Also

Example

// Create a lexer config item for a user-defined plugin.
'use strict';
const clang = require('/MarkLogic/custom-language');

clang.lexer('special_lexer','NFD', (), 'native/sample_plugin');
    

Example

// Create a lexer config item from a built-in plugin (atilika), and
// pass in a configuration option.
'use strict';
const clang = require('/MarkLogic/custom-language');

clang:lexer('atilika', null, 
            Sequence.from(['normal-mode']), '')
    

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.