License New BSD license
Lines 95
Keywords
COBOL (5) ILE (1) lexer (6) pygments (6)
Included in this Library
Permissions
Owner: Theodore Test
Viewable by Everyone
Editable by All Siafoo Users
Hide
Bored? Check out the Recent Activity on Siafoo Join Siafoo Now or Learn More

ILE COBOL Pygments Lexer Atom Feed 0

In Brief A Pygments lexer for ILE COBOL, one of the languages supported under the Integrated Language Environment for the IBM i operating system (formerly known as OS/400 and i5/OS). This is the ILE COBOL lexer used by Siafoo.
# 's
  1import re
2
3from pygments.lexer import RegexLexer, include, bygroups, using, this
4from pygments.token import Error, Punctuation, Text, Comment, Operator, Keyword, Name, String, Number
5
6class ILE_COBOLLexer(RegexLexer):
7 name = 'ILE_COBOL'
8 aliases = ['ILE_COBOL', 'ile_cobol']
9 filenames = ['*.cbl','*.CBL']
10 mimetypes = []
11
12
13 # Really only five major sorts of highlighting --
14 # Reserved Words, Comments, Numbers, Strings, and Punctuation
15 # Due to COBOL implementation details, even what modern languages consider 'operators'
16 # are treated as Reserved Words.
17
18 tokens = {
19 'root': [
20 (r'\*.*\n', Comment),
21 include('strings'),
22 include('core'),
23 include('nums'),
24 (r'[\s]+', Text)
25 ],
26 'core':[(r'\b(FOREGROUND-COLOR|TEST|END-UNSTRING|REPLACING|SEGMENT-LIMIT|PROCEDURE-POINTER|END-PERFORM|'
27 r'FROM|RIGHT|RECURSIVE|RESERVE|COPY|ZERO-FILL|END-START|'
28 r'ALPHANUMERIC-EDITED|START|TIMES|VALUE|KANJI|INTO|SUPPRESS|'
29 r'SPACE|STRING|TYPEDEF|DIVISION|STATUS|END-ADD|DAY|'
30 r'=|THAN|COMP|COMMA|PROCESSING|TO|-|'
31 r'\*\*|ADDRESS|END-EVALUATE|INSTALLATION|PICTURE|TRAILING|NULL|'
32 r'SPACES|DEBUG-CONTENTS|LOCAL-STORAGE|REMOVAL|NUMBER|CHARACTER|LOCALE|'
33 r'DEPENDING|INVOKE|SECURE|USE|ZEROES|OBJECT-COMPUTER|>|'
34 r'USING|KEY|IDENTIFICATION|UNDERLINE|REWRITE|GREATER|FALSE|'
35 r'PROGRAM-ID|TRUE|END-XML|EMPTY-CHECK|CONVERTING|DEBUG-SUB-1|CORR|'
36 r'ADD|END-DIVIDE|WRITE|USAGE|CRT-UNDER|DUPLICATES|PROMPT|'
37 r'LENGTH-CHECK|CONFIGURATION|CLOSE|TRAILING-SIGN|INDICATE|REPLACE|DBCS|'
38 r'PRIOR|COLUMN|AREA|REFERENCE|CRT|SET|DEBUGGING|'
39 r'DISPLAY|ORDER|ASCENDING|OVERFLOW|HIGHLIGHT|REFERENCES|PROGRAM|'
40 r'NO|DBCS-EDITED|STOP|SECTION|EVALUATE|INDEX|DEBUG-LINE|'
41 r'>=|DESCRIBED|DATE-COMPILED|AT|LEFT-JUSTIFY|TIME|THROUGH|'
42 r'CONTINUE|END-INVOKE|INITIATE|I-O|UP|LOW-VALUES|ATTRIBUTE|'
43 r'QUOTES|SIZE|END-ACCEPT|ROLLING|RELEASE|ERROR|UPDATE|'
44 r'SYMBOLIC|ALTERNATE|SKIP3|JUST|END|ALSO|CODE-SET|'
45 r'ADVANCING|I-O-CONTROL|TAPE|BLANK|ALPHABETIC-UPPER|BLINK|/|'
46 r'DECIMAL-POINT|DYNAMIC|REQUIRED|OPEN|FILLER|END-IF|CURSOR|'
47 r'RIGHT-JUSTIFY|PROCEED|BLOCK|HIGH-VALUE|DOWN|ACCEPT|MODULES|'
48 r'COMP-1|SORT-RETURN|DELETE|OR|RETURN-CODE|OUTPUT|VARYING|'
49 r'END-REWRITE|LENGTH|PROCESS|PARSE|CLASS|REVERSE-VIDEO|CONTAINS|'
50 r'OF|ON|END-CALL|FIRST|SYSIN|DELIMITER|MERGE|'
51 r'INVALID|COMMIT|END-READ|DECLARATIVES|REVERSED|COMPUTATIONAL-3|COMPUTATIONAL-2|'
52 r'BINARY|RENAMES|DELIMITED|GLOBAL|LINKAGE|<|\*|'
53 r'BEFORE|END-DISPLAY|FOREGROUND-COLOUR|END-OF-PAGE|SUBSTITUTE|EVERY|PIC|'
54 r'BOTTOM|ALTER|REEL|JUSTIFIED|INITIALIZE|CONTROL-AREA|FILE|'
55 r'WHEN-COMPILED|MOVE|WHEN|LESS|DEBUG-NAME|MULTIPLE|TRANSACTION|'
56 r'RESET|POINTER|MEMORY|ARE|CALL|ACCESS|SAME|'
57 r'NEGATIVE|DISPLAY-1|ALPHABETIC-LOWER|IF|ID|ROUNDED|CANCEL|'
58 r'IN|COMPUTATIONAL-4|ZEROS|OTHER|ALIAS|IS|LEADING|'
59 r'SORT-MERGE|CONSOLE|RANDOM|END-SUBTRACT|SCREEN|MODE|SEQUENTIAL|'
60 r'RECORD|INDIC|COMP-4|COMP-3|COMP-2|OMITTED|EJECT|'
61 r'BEEP|CONTROL|DATA|NULL-MAP|COMPUTE|LINAGE|CHARACTERS|'
62 r'CONTROLS|DATE|BACKGROUND-COLOUR|LINES|<=|TOP|DAY-OF-WEEK|'
63 r'EXCEPTION|SD|PAGE|TYPE|POSITION|REWIND|PREFIX|'
64 r'INSPECT|NULL-KEY-MAP|HIGH-VALUES|LIKE|RUN|SUBFILE|ALL|'
65 r'DESCENDING|ZERO|CONTENT|STANDARD|SPACE-FILL|COMMITMENT|LOCK|'
66 r'CLOCK-UNITS|SORT|LEFT|AUTO-SKIP|OCCURS|DEBUG-SUB-3|DEBUG-SUB-2|'
67 r'ORGANIZATION|WORDS|BACKGROUND-COLOR|COLLATING|UNTIL|EXTERNALLY-DESCRIBED-KEY|DROP|'
68 r'ALPHABET|RETURNING|REPOSITORY|PACKED-DECIMAL|END-COMPUTE|NATIVE|WITH|'
69 r'COL|METACLASS|ASSIGN|FD|STANDARD-1|END-STRING|STANDARD-2|'
70 r'NUMERIC-EDITED|WORKING-STORAGE|READ|TITLE|END-WRITE|THEN|REMAINDER|'
71 r'RERUN|NOT|TERMINAL|INPUT-OUTPUT|ACQUIRE|POSITIVE|GIVING|'
72 r'SPECIAL-NAMES|MULTIPLY|DB-FORMAT-NAME|AND|UNIT|GENERATE|OPTIONAL|'
73 r'TALLYING|INPUT|INDEXED|EXTERNAL|END-MULTIPLY|ALPHANUMERIC|ELSE|'
74 r'END-DELETE|SEQUENCE|FOR|DIVIDE|REDEFINES|NULLS|COUNT|'
75 r'STARTING|VLR|SECURITY|EXIT|INDICATORS|DEBUG-ITEM|FILE-CONTROL|'
76 r'RECORDS|BY|LIBRARY|MODIFIED|SOURCE-COMPUTER|\+|SUBTRACT|'
77 r'AUTHOR|END-SEARCH|SEARCH|LINAGE-COUNTER|SELECT|LINE|PROCEDURES|'
78 r'ROLLBACK|SKIP1|CURRENCY|SKIP2|LABEL|SYNC|UPON|'
79 r'INITIAL|GOBACK|BELL|SYNCHRONIZED|RETURN|CODE|AUTO|'
80 r'FUNCTION|AREAS|ALPHABETIC|VALUES|PADDING|LOW-VALUE|AFTER|'
81 r'FILE-STREAM|COMPUTATIONAL|ENTRY|PROCEDURE|CORRESPONDING|GO|ENTER|'
82 r'RELATIVE|SIGN|FOOTING|NATIONAL|EQUAL|SENTENCE|OFF|'
83 r'FULL|COMPUTATIONAL-1|END-RETURN|COMMON|THRU|PRINTING|NEXT|'
84 r'NUMERIC|SEPARATE|QUOTE|LAST|DATE-WRITTEN|UNSTRING|SYSOUT|'
85 r'EOP|ENVIRONMENT|OBJECT|NO-ECHO|PERFORM|FORMAT|EXTEND|'
86 r'EBCDIC|INDICATOR)\s*\b', Keyword),
87 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
88 (r'(\.)',Punctuation)],
89
90 'strings': [
91 (r'"(\\|\[0-7]+|\.|[^"])*"', String.Double),
92 (r"'(\\|\[0-7]+|\.|[^'])*'", String.Single),
93 ],
94
95 'nums': [
96 (r'\d+(?![.Ee])', Number.Integer),
97 (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
98 (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float)
99 ],
100 }

A Pygments lexer for ILE COBOL, one of the languages supported under the Integrated Language Environment for the IBM i operating system (formerly known as OS/400 and i5/OS). This is the ILE COBOL lexer used by Siafoo.