UNPKG

cst

Version:

JavaScript CST Implementation

98 lines (73 loc) 3.54 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); var _createClass2 = require('babel-runtime/helpers/createClass'); var _createClass3 = _interopRequireDefault(_createClass2); var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); var _inherits2 = require('babel-runtime/helpers/inherits'); var _inherits3 = _interopRequireDefault(_inherits2); var _ModuleDeclaration2 = require('../ModuleDeclaration'); var _ModuleDeclaration3 = _interopRequireDefault(_ModuleDeclaration2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var ImportDeclaration = function (_ModuleDeclaration) { (0, _inherits3.default)(ImportDeclaration, _ModuleDeclaration); function ImportDeclaration(childNodes) { (0, _classCallCheck3.default)(this, ImportDeclaration); return (0, _possibleConstructorReturn3.default)(this, (ImportDeclaration.__proto__ || (0, _getPrototypeOf2.default)(ImportDeclaration)).call(this, 'ImportDeclaration', childNodes)); } (0, _createClass3.default)(ImportDeclaration, [{ key: '_acceptChildren', value: function _acceptChildren(children) { children.passToken('Keyword', 'import'); children.skipNonCode(); var specifiers = []; var source = null; if (children.isNode('ImportDefaultSpecifier')) { specifiers.push(children.passModuleSpecifier()); children.skipNonCode(); if (children.isToken('Punctuator', ',')) { children.moveNext(); children.skipNonCode(); } } else if (children.isNode('ImportNamespaceSpecifier')) { specifiers.push(children.passModuleSpecifier()); children.skipNonCode(); } if (children.isToken('Punctuator', '{')) { children.passToken('Punctuator', '{'); children.skipNonCode(); while (!children.isToken('Punctuator', '}')) { specifiers.push(children.passModuleSpecifier()); children.skipNonCode(); if (children.isToken('Punctuator', ',')) { children.moveNext(); children.skipNonCode(); } } children.passToken('Punctuator', '}'); children.skipNonCode(); } if (children.isToken('Identifier', 'from')) { children.passToken('Identifier', 'from'); children.skipNonCode(); } source = children.passNode('StringLiteral'); if (!children.isEnd) { children.skipNonCode(); children.passToken('Punctuator', ';'); } children.assertEnd(); this.specifiers = specifiers; this.source = source; } }]); return ImportDeclaration; }(_ModuleDeclaration3.default); exports.default = ImportDeclaration; //# sourceMappingURL=ImportDeclaration.js.map