sormy / flex-js Goto Github PK
View Code? Open in Web Editor NEWFLEX.JS - fast lexer (tokenizer, scanner) for JavaScript inspired by FLEX lexer generator
License: MIT License
FLEX.JS - fast lexer (tokenizer, scanner) for JavaScript inspired by FLEX lexer generator
License: MIT License
use for ... in loop would always get the object property like: any,select, where。 I think this is should not be there
I wrote your basic sample in VSCode
const Lexer = require('flex-js');
var lexer = new Lexer();
// options
lexer.setIgnoreCase(true); // does not make sense for this scanner, just for reference
// definitions
lexer.addDefinition('DIGIT', /[0-9]/);
// rules
lexer.addRule(/{DIGIT}+\.{DIGIT}+/, function (lexer) {
console.log('Found float: ' + lexer.text);
});
lexer.addRule(/\s+/);
// code
lexer.setSource('1.2 3.4 5.6');
lexer.lex();
and I got an error
...\node_modules\flex-js\src\Lexer.js:647
re.lastIndex = this.index;
^
TypeError: Cannot set property 'lastIndex' of undefined
at Lexer.execRegExp (...\node_modules\flex-js\src\Lexer.js:647:16)
I am not sure what is the problem but I handled the error with a line of code
if (!re) return undefined;
Can you guide me?
I wrote a block of code
const Lexer = require('flex-js');
const lexer = new Lexer();
lexer.setIgnoreCase(true);
const s = "* @return this is a test.";
lexer.addDefinition('COMMENT', /\s*\*\s+/);
lexer.addDefinition('RETURN', /@return/);
lexer.addDefinition('DESCRIPTION', /.*/);
lexer.addRule(/{COMMENT}{RETURN}{DESCRIPTION}/, function (lexer : any) {
console.log('Found' + lexer.text);
});
lexer.setSource(s);
lexer.lex();
How to get the tokens in sequence?
COMMENT: *
RETURN: @return
DESCRIPTION: this is a test.
Hi! Thanks for this great library.
I'm wondering if it would be possible to add support for Unicode regular expressions? Currently, it seems that the "u" flag is discarded when the lexer compiles a rule. Unicode regular expressions are necessary to properly match non BMP characters (e.g. emojis) as well as use Unicode properties as character classes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.