版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

47 строки
983 B

  1. const {
  2. TOKEN_COMMENT_START,
  3. TOKEN_COMMENT_END,
  4. TOKEN_COMMENT_CONTENT
  5. } = require('../constants/token-types')
  6. function handleCommentStart (state, token) {
  7. state.currentNode.content.start = token
  8. state.caretPosition++
  9. return state
  10. }
  11. function handleCommentContent (state, token) {
  12. state.currentNode.content.value = token
  13. state.caretPosition++
  14. return state
  15. }
  16. function handleCommentEnd (state, token) {
  17. state.currentNode.content.end = token
  18. state.currentNode = state.currentNode.parentRef
  19. state.currentContext = state.currentContext.parentRef
  20. state.caretPosition++
  21. return state
  22. }
  23. module.exports = function comment (token, state) {
  24. if (token.type === TOKEN_COMMENT_START) {
  25. return handleCommentStart(state, token)
  26. }
  27. if (token.type === TOKEN_COMMENT_CONTENT) {
  28. return handleCommentContent(state, token)
  29. }
  30. if (token.type === TOKEN_COMMENT_END) {
  31. return handleCommentEnd(state, token)
  32. }
  33. state.caretPosition++
  34. return state
  35. }