index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. 'use strict';
  2. const Parser = require('./parser');
  3. const AtWord = require('./atword');
  4. const Colon = require('./colon');
  5. const Comma = require('./comma');
  6. const Comment = require('./comment');
  7. const Func = require('./function');
  8. const Num = require('./number');
  9. const Operator = require('./operator');
  10. const Paren = require('./paren');
  11. const Str = require('./string');
  12. const UnicodeRange = require('./unicode-range');
  13. const Value = require('./value');
  14. const Word = require('./word');
  15. let parser = function (source, options) {
  16. return new Parser(source, options);
  17. };
  18. parser.atword = function (opts) {
  19. return new AtWord(opts);
  20. };
  21. parser.colon = function (opts) {
  22. return new Colon(Object.assign({ value: ':' }, opts));
  23. };
  24. parser.comma = function (opts) {
  25. return new Comma(Object.assign({ value: ',' }, opts));
  26. };
  27. parser.comment = function (opts) {
  28. return new Comment(opts);
  29. };
  30. parser.func = function (opts) {
  31. return new Func(opts);
  32. };
  33. parser.number = function (opts) {
  34. return new Num(opts);
  35. };
  36. parser.operator = function (opts) {
  37. return new Operator(opts);
  38. };
  39. parser.paren = function (opts) {
  40. return new Paren(Object.assign({ value: '(' }, opts));
  41. };
  42. parser.string = function (opts) {
  43. return new Str(Object.assign({ quote: '\'' }, opts));
  44. };
  45. parser.value = function (opts) {
  46. return new Value(opts);
  47. };
  48. parser.word = function (opts) {
  49. return new Word(opts);
  50. };
  51. parser.unicodeRange = function (opts) {
  52. return new UnicodeRange(opts);
  53. };
  54. module.exports = parser;