tp.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. module.exports = function(hljs) {
  2. var TPID = {
  3. className: 'number',
  4. begin: '[1-9][0-9]*', /* no leading zeros */
  5. relevance: 0
  6. };
  7. var TPLABEL = {
  8. className: 'symbol',
  9. begin: ':[^\\]]+'
  10. };
  11. var TPDATA = {
  12. className: 'built_in',
  13. begin: '(AR|P|PAYLOAD|PR|R|SR|RSR|LBL|VR|UALM|MESSAGE|UTOOL|UFRAME|TIMER|' +
  14. 'TIMER_OVERFLOW|JOINT_MAX_SPEED|RESUME_PROG|DIAG_REC)\\[', end: '\\]',
  15. contains: [
  16. 'self',
  17. TPID,
  18. TPLABEL
  19. ]
  20. };
  21. var TPIO = {
  22. className: 'built_in',
  23. begin: '(AI|AO|DI|DO|F|RI|RO|UI|UO|GI|GO|SI|SO)\\[', end: '\\]',
  24. contains: [
  25. 'self',
  26. TPID,
  27. hljs.QUOTE_STRING_MODE, /* for pos section at bottom */
  28. TPLABEL
  29. ]
  30. };
  31. return {
  32. keywords: {
  33. keyword:
  34. 'ABORT ACC ADJUST AND AP_LD BREAK CALL CNT COL CONDITION CONFIG DA DB ' +
  35. 'DIV DETECT ELSE END ENDFOR ERR_NUM ERROR_PROG FINE FOR GP GUARD INC ' +
  36. 'IF JMP LINEAR_MAX_SPEED LOCK MOD MONITOR OFFSET Offset OR OVERRIDE ' +
  37. 'PAUSE PREG PTH RT_LD RUN SELECT SKIP Skip TA TB TO TOOL_OFFSET ' +
  38. 'Tool_Offset UF UT UFRAME_NUM UTOOL_NUM UNLOCK WAIT X Y Z W P R STRLEN ' +
  39. 'SUBSTR FINDSTR VOFFSET PROG ATTR MN POS',
  40. literal:
  41. 'ON OFF max_speed LPOS JPOS ENABLE DISABLE START STOP RESET'
  42. },
  43. contains: [
  44. TPDATA,
  45. TPIO,
  46. {
  47. className: 'keyword',
  48. begin: '/(PROG|ATTR|MN|POS|END)\\b'
  49. },
  50. {
  51. /* this is for cases like ,CALL */
  52. className: 'keyword',
  53. begin: '(CALL|RUN|POINT_LOGIC|LBL)\\b'
  54. },
  55. {
  56. /* this is for cases like CNT100 where the default lexemes do not
  57. * separate the keyword and the number */
  58. className: 'keyword',
  59. begin: '\\b(ACC|CNT|Skip|Offset|PSPD|RT_LD|AP_LD|Tool_Offset)'
  60. },
  61. {
  62. /* to catch numbers that do not have a word boundary on the left */
  63. className: 'number',
  64. begin: '\\d+(sec|msec|mm/sec|cm/min|inch/min|deg/sec|mm|in|cm)?\\b',
  65. relevance: 0
  66. },
  67. hljs.COMMENT('//', '[;$]'),
  68. hljs.COMMENT('!', '[;$]'),
  69. hljs.COMMENT('--eg:', '$'),
  70. hljs.QUOTE_STRING_MODE,
  71. {
  72. className: 'string',
  73. begin: '\'', end: '\''
  74. },
  75. hljs.C_NUMBER_MODE,
  76. {
  77. className: 'variable',
  78. begin: '\\$[A-Za-z0-9_]+'
  79. }
  80. ]
  81. };
  82. };