Skip to content

pkorzh/toker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#toker

General purpose lexical analyzer

##Usage

var toker = require('toker');

var lex = new toker.LexicalAnalyzer('.p {color: #fff}', {
	keywords: ['@mixin', '@include', '@extend'],
	identifierStart: /[#@$_a-zA-Z]/,
	identifierPart: /([$_a-zA-Z-]|[0-9])/
});

console.log(lex.getTokens());

##Options

identifierStart and identifierPart

Default:

identifierStart = /[$_a-zA-Z]/
identifierPart = /([$_a-zA-Z]|[0-9])/;

Re to check is lexeme is an identifier

keywords

List of tokens to mark as keywords.

Default:

'break', 'case', 'catch', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'finally', 'for', 'function', 'if', 'in', 'instanceof', 'new', 'return', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'class', 'const', 'enum', 'export', 'extends', 'import', 'super'

operators

List of operators.

Default:

    '{', '}', '(', ')', '[', ']', '.', ';', ',', '?', '', '===', '==', '=', '!==', '!=', '!', '<<=', '<<', '<=', '<', '>>>=', '>>>', '>>=', '>>', '>=', '>', '+=', '++', '+', '-=', '--', '-', '*=', '*', '/=', '/', '%=', '%', '&&', '&=', '&', '||', '|=', '|', '^=', '^', '~'

punctuators

Default:

'.', '(', ')', ';', ',', '{', '}', '[', ']', ':', '?', '~'

About

General purpose lexical analizer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published