File size: 2,740 Bytes
bc20498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";import _createClass from "@babel/runtime/helpers/createClass";import _inherits from "@babel/runtime/helpers/inherits";import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";function _createSuper(Derived) {var hasNativeReflectConstruct = _isNativeReflectConstruct();return function _createSuperInternal() {var Super = _getPrototypeOf(Derived),result;if (hasNativeReflectConstruct) {var NewTarget = _getPrototypeOf(this).constructor;result = Reflect.construct(Super, arguments, NewTarget);} else {result = Super.apply(this, arguments);}return _possibleConstructorReturn(this, result);};}function _isNativeReflectConstruct() {try {var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));} catch (t) {}return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {return !!t;})();}import EventEmitter from 'events';var

BaseLexer = /*#__PURE__*/function (_EventEmitter) {_inherits(BaseLexer, _EventEmitter);var _super = _createSuper(BaseLexer);
  function BaseLexer() {var _this;var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};_classCallCheck(this, BaseLexer);
    _this = _super.call(this);
    _this.keys = [];
    _this.functions = options.functions || ['t'];return _this;
  }_createClass(BaseLexer, [{ key: "validateString", value:

    function validateString(string) {
      var regex = new RegExp('^' + BaseLexer.stringPattern + '$', 'i');
      return regex.test(string);
    } }, { key: "functionPattern", value:

    function functionPattern() {
      return '(?:' + this.functions.join('|').replace('.', '\\.') + ')';
    } }], [{ key: "singleQuotePattern", get:

    function get() {
      return "'(?:[^'].*?[^\\\\])?'";
    } }, { key: "doubleQuotePattern", get:

    function get() {
      return '"(?:[^"].*?[^\\\\])?"';
    } }, { key: "backQuotePattern", get:

    function get() {
      return '`(?:[^`].*?[^\\\\])?`';
    } }, { key: "variablePattern", get:

    function get() {
      return '(?:[A-Z0-9_.-]+)';
    } }, { key: "stringPattern", get:

    function get() {
      return (
        '(?:' +
        [BaseLexer.singleQuotePattern, BaseLexer.doubleQuotePattern].join('|') +
        ')');

    } }, { key: "stringOrVariablePattern", get:

    function get() {
      return (
        '(?:' +
        [
        BaseLexer.singleQuotePattern,
        BaseLexer.doubleQuotePattern,
        BaseLexer.variablePattern].
        join('|') +
        ')');

    } }]);return BaseLexer;}(EventEmitter);export { BaseLexer as default };
//# sourceMappingURL=base-lexer.js.map