CLexer
A C port of the whitequark/parser's lexer.
Initially based on whitequark/parser#248 (thanks @alexdowad).
Can be use on Linux/Mac/Windows, requires MRI.
Installation
$ gem install c_lexer
Usage
c_lexer doesn't change any parser classes.
It provides 3 classes:
-
Parser::CLexer(C version of the lexer) -
Parser::Ruby25WithCLexer(a subclass ofparser/ruby25that usesParser::CLexerfor lexing) -
Parser::Ruby26WithCLexer(a subclass ofparser/ruby26that usesParser::CLexerfor lexing)
If you want CLexer to be a default lexer you can use the following patch:
require 'parser'
require 'c_lexer'
module Parser
dedenter = Lexer::Dedenter
remove_const(:Lexer)
Lexer = CLexer
Lexer::Dedenter = dedenter
remove_const(:Ruby26)
Ruby26 = Ruby26WithCLexer
endVersioning
c_lexer follows versioning of the parser gem to avoid confusions like
"which version of c_lexer should be used with the parser vX.Y.Z". For parser 2.5.1.0 you should use c_lexer 2.5.1.0.X.
c_lexer supports all versions of parser starting from 2.5.1.0
Development
- Make sure that you have
ragelinstalled. - Clone the repo and fetch submodules with
git submodule update --init. - The parser gem is located under
vendor/parser. -
rake ruby_parser:generategenerateslexer.rband parsers for theparsergem. -
rake c_lexer:generategenerateslexer.c. -
rake compilecompileslexer.ctolexer.so(orlexer.bundledepending on your platform). -
rake testrunsparsertests usingc_lexeras a default lexer.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/opal/c_lexer.
Before submitting a bug report, please, make sure that parser is not affected by the same issue.
If it's a parser bug please report it to the parser repo and we will backport it afterwards.