You have noticed that the snippets of TP code in my previous posts now have pretty colors. I created a custom fork of GitHub’s pygments.rb that adds a lexer for FANUC TP. I’m going to maintain and improve this custom fork for a while until the lexer is a bit more complete, then I will see about submitting the patch to the official Pygments project.
Here’s an example:
/PROG EXAMPLE
/ATTR
OWNER = ASCBIN;
COMMENT = "Example TP file";
PROG_SIZE = 2651;
CREATE = DATE 14-01-02 TIME 10:12:44;
MODIFIED = DATE 14-01-02 TIME 10:12:44;
FILE_NAME = ;
VERSION = 0;
LINE_COUNT = 21;
MEMORY_SIZE = 3195;
PROTECT = READ_WRITE;
TCD: STACK_SIZE = 0,
TASK_PRIORITY = 50,
TIME_SLICE = 0,
BUSY_LAMP_OFF = 0,
ABORT_REQUEST = 0,
PAUSE_REQUEST = 0;
DEFAULT_GROUP = 1,*,*,*,*;
CONTROL_CODE = 00000000 00000000;
/APPL
LINE_TRACK;
LINE_TRACK_SCHEDULE_NUMBER : 1;
LINE_TRACK_BOUNDARY_NUMBER : 1;
CONTINUE_TRACK_AT_PROG_END : TRUE;
/MN
1: ! Example comment ;
2: ;
3: LBL[1] ;
4: R[1:Some Register]=1 ;
5: DO[1:Some Output]=ON ;
6: ;
7: CALL MY_SUBROUTINE ;
8: ;
9: IF R[2:Another register]>=3,JMP LBL[999] ;
10: ;
11:L PR[1:Some PR] max_speed CNT20 VOFFSET,VR[1] ACC R[100] ;
12: ;
13: UTOOL_NUM=5 ;
14: //PAYLOAD[2] ;
15: ;
16: F[1]=(OFF) ;
17: ;
18: WAIT .20(sec) ;
19: JMP LBL[1] ;
20: ;
21: LBL[999] ;
/POS
/END