Skip to content

Commit

Permalink
speed up lexer parsing (#88)
Browse files Browse the repository at this point in the history
* speed up lexer parsing
  • Loading branch information
erikyo authored May 5, 2024
1 parent d18bbdb commit 2f94ed7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/poparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ Parser.prototype.types = {
* String matches for lexer
*/
Parser.prototype.symbols = {
quotes: /["']/,
comments: /#/,
whitespace: /\s/,
key: /[\w\-[\]]/,
keyNames: /^(?:msgctxt|msgid(?:_plural)?|msgstr(?:\[\d+])?)$/
Expand All @@ -146,15 +144,15 @@ Parser.prototype._lexer = function (chunk) {
switch (this._state) {
case this.states.none:
case this.states.obsolete:
if (chr.match(this.symbols.quotes)) {
if (chr === '"' || chr === "'") {
this._node = {
type: this.types.string,
value: '',
quote: chr
};
this._lex.push(this._node);
this._state = this.states.string;
} else if (chr.match(this.symbols.comments)) {
} else if (chr === "#") {
this._node = {
type: this.types.comments,
value: ''
Expand Down

0 comments on commit 2f94ed7

Please sign in to comment.