1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 'use strict'
-
- var assert = require('assert')
- var asciiPunctuation = require('../character/ascii-punctuation.js')
- var codes = require('../character/codes.js')
- var types = require('../constant/types.js')
-
- function _interopDefaultLegacy(e) {
- return e && typeof e === 'object' && 'default' in e ? e : {default: e}
- }
-
- var assert__default = /*#__PURE__*/ _interopDefaultLegacy(assert)
-
- var characterEscape = {
- name: 'characterEscape',
- tokenize: tokenizeCharacterEscape
- }
-
- function tokenizeCharacterEscape(effects, ok, nok) {
- return start
-
- function start(code) {
- assert__default['default'](code === codes.backslash, 'expected `\\`')
- effects.enter(types.characterEscape)
- effects.enter(types.escapeMarker)
- effects.consume(code)
- effects.exit(types.escapeMarker)
- return open
- }
-
- function open(code) {
- if (asciiPunctuation(code)) {
- effects.enter(types.characterEscapeValue)
- effects.consume(code)
- effects.exit(types.characterEscapeValue)
- effects.exit(types.characterEscape)
- return ok
- }
-
- return nok(code)
- }
- }
-
- module.exports = characterEscape
|