source: node_modules/highlight.js/lib/languages/tp.js@ 65b6638

main
Last change on this file since 65b6638 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

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