Skip to content

shfx/node-lexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-lexer

Early version of my simple node lexer.

Example

var Lexer = require('node-lexer').Lexer;

var tokens = {
  words:       /^[a-z]+/i,
  whitespaces: /^[ ]+/,
  numbers:     /^\d+/,
  string: [
    /^".*?[^\\]"/,
    /^'.*?[^\\]'/
  ]
}

var lex = new Lexer(tokens);

lex.on('token', function(token){
  console.log(token);
});

lex.on('end', function(){
  console.log('End parsing');
})

lex.tokenize('test 123 "le puff"');

About

Basic lexer

Resources

Stars

Watchers

Forks

Packages

No packages published