From 514fb3d28b6b77343bdbcbfcc18e26e71b384fb4 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Mon, 18 Feb 2013 02:49:05 +0100 Subject: Added support for EasyTrieve, JCL and (Web)FOCUS. --- pygments/lexers/_mapping.py | 3 + pygments/lexers/other.py | 272 +++++++++++++++++++++++++++++++++++++++++++- tests/examplefiles/test.ezt | 18 +++ tests/examplefiles/test.fex | 225 ++++++++++++++++++++++++++++++++++++ tests/examplefiles/test.jcl | 30 +++++ 5 files changed, 546 insertions(+), 2 deletions(-) create mode 100644 tests/examplefiles/test.ezt create mode 100644 tests/examplefiles/test.fex create mode 100644 tests/examplefiles/test.jcl diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 53e09176..5c4275d0 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -93,6 +93,7 @@ LEXERS = { 'DylanLidLexer': ('pygments.lexers.compiled', 'DylanLID', ('dylan-lid', 'lid'), ('*.lid', '*.hdp'), ('text/x-dylan-lid',)), 'ECLLexer': ('pygments.lexers.other', 'ECL', ('ecl',), ('*.ecl',), ('application/x-ecl',)), 'ECLexer': ('pygments.lexers.compiled', 'eC', ('ec',), ('*.ec', '*.eh'), ('text/x-echdr', 'text/x-ecsrc')), + 'EasyTrieveLexer': ('pygments.lexers.other', 'EasyTrieve', ('easytrieve',), ('*.ezt',), ('text/x-easytrieve',)), 'ElixirConsoleLexer': ('pygments.lexers.functional', 'Elixir iex session', ('iex',), (), ('text/x-elixir-shellsession',)), 'ElixirLexer': ('pygments.lexers.functional', 'Elixir', ('elixir', 'ex', 'exs'), ('*.ex', '*.exs'), ('text/x-elixir',)), 'ErbLexer': ('pygments.lexers.templates', 'ERB', ('erb',), (), ('application/x-ruby-templating',)), @@ -146,6 +147,7 @@ LEXERS = { 'JavascriptLexer': ('pygments.lexers.web', 'JavaScript', ('js', 'javascript'), ('*.js',), ('application/javascript', 'application/x-javascript', 'text/x-javascript', 'text/javascript')), 'JavascriptPhpLexer': ('pygments.lexers.templates', 'JavaScript+PHP', ('js+php', 'javascript+php'), (), ('application/x-javascript+php', 'text/x-javascript+php', 'text/javascript+php')), 'JavascriptSmartyLexer': ('pygments.lexers.templates', 'JavaScript+Smarty', ('js+smarty', 'javascript+smarty'), (), ('application/x-javascript+smarty', 'text/x-javascript+smarty', 'text/javascript+smarty')), + 'JclLexer': ('pygments.lexers.other', 'JCL', ('jcl',), ('*.jcl',), ('text/x-jcl',)), 'JsonLexer': ('pygments.lexers.web', 'JSON', ('json',), ('*.json',), ('application/json',)), 'JspLexer': ('pygments.lexers.templates', 'Java Server Page', ('jsp',), ('*.jsp',), ('application/x-jsp',)), 'JuliaConsoleLexer': ('pygments.lexers.math', 'Julia console', ('jlcon',), (), ()), @@ -288,6 +290,7 @@ LEXERS = { 'VerilogLexer': ('pygments.lexers.hdl', 'verilog', ('verilog', 'v'), ('*.v',), ('text/x-verilog',)), 'VhdlLexer': ('pygments.lexers.hdl', 'vhdl', ('vhdl',), ('*.vhdl', '*.vhd'), ('text/x-vhdl',)), 'VimLexer': ('pygments.lexers.text', 'VimL', ('vim',), ('*.vim', '.vimrc', '.exrc', '.gvimrc', '_vimrc', '_exrc', '_gvimrc', 'vimrc', 'gvimrc'), ('text/x-vim',)), + 'WebFocusLexer': ('pygments.lexers.other', 'WebFOCUS', ('webfocus', 'FOCUS', 'focus'), ('*.fex',), ('text/x-webfocus', 'text/x-focus')), 'XQueryLexer': ('pygments.lexers.web', 'XQuery', ('xquery', 'xqy', 'xq', 'xql', 'xqm'), ('*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm'), ('text/xquery', 'application/xquery')), 'XmlDjangoLexer': ('pygments.lexers.templates', 'XML+Django/Jinja', ('xml+django', 'xml+jinja'), (), ('application/xml+django', 'application/xml+jinja')), 'XmlErbLexer': ('pygments.lexers.templates', 'XML+Ruby', ('xml+erb', 'xml+ruby'), (), ('application/xml+ruby',)), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index c8557922..18d3059d 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -14,7 +14,8 @@ import re from pygments.lexer import RegexLexer, include, bygroups, using, \ this, combined, ExtendedRegexLexer from pygments.token import Error, Punctuation, Literal, Token, \ - Text, Comment, Operator, Keyword, Name, String, Number, Generic + Text, Comment, Operator, Keyword, Name, String, Number, Generic, Other, \ + Whitespace from pygments.util import get_bool_opt from pygments.lexers.web import HtmlLexer @@ -35,7 +36,8 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer', 'ECLLexer', 'UrbiscriptLexer', 'OpenEdgeLexer', 'BroLexer', 'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer', 'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer', - 'CbmBasicV2Lexer', 'AutoItLexer'] + 'CbmBasicV2Lexer', 'AutoItLexer', 'EasyTrieveLexer', 'JclLexer', + 'WebFocusLexer'] class ECLLexer(RegexLexer): @@ -3665,3 +3667,269 @@ class AutoItLexer(RegexLexer): (r'[^\S\n]', Text), ], } + + +class EasyTrieveLexer(RegexLexer): + """ + EasyTrieve (Classic and Plus) are programming languages tailored to + generating reports and are mainly used in mainframe related environments. + + This lexer is designed for EasyTrieve Plus 6.4. + """ + name = 'EasyTrieve' + aliases = ['easytrieve'] + filenames = ['*.ezt'] + mimetypes = ['text/x-easytrieve'] + flags = re.IGNORECASE + + # TODO: Treat only the first 72 characters as source code and the rest as comment. + # TODO: After some reserved words such as 'define', even keywords are names. + # TODO: Consider continuation characters '+' and '-' + # TODO: Treat the 'not' character as operator. + + tokens = { + 'root': [ + # Note: We cannot use r'\b' at the start and end of keywords + # because EasyTrieve Plus delimiter characters are: + # + # * space ( ) + # * apostrophe (') + # * period (.) + # * comma (,) + # * paranthesis ( and ) + # * colon (:) + (r'(after-break|after-line|after-screen|aim|and|attr|before|' + r'before-break|before-line|before-screen|bushu|by|call|case|' + r'checkpoint|chkp|chkp-status|clear|close|col|color|commit|' + r'control|copy|cursor|d|declare|default|define|delete|denwa|' + r'display|dli|do|duplicate|e|else|else-if|end|end-case|end-do|' + r'end-if|end-proc|endpage|endtable|enter|eof|eq|error|exit|' + r'external|ezlib|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|' + r'f20|f21|f22|f23|f24|f25|f26|f27|f28|f29|f3|f30|f31|f32|f33|' + r'f34|f35|f36|f4|f5|f6|f7|f8|f9|fetch|file|file-status|fill|' + r'final|first|first-dup|for|ge|get|go|goto|gq|gr|gt|heading|' + r'hex|high-values|idd|idms|if|in|insert|job|justify|kanji-date|' + r'kanji-date-long|kanji-time|key|key-pressed|kokugo|kun|' + r'last-dup|le|level|like|line|line-count|line-number|link|list|' + r'low-values|lq|ls|lt|mask|matched|mend|message|move|mstart|ne|' + r'newpage|nomask|noprint|not|note|noverify|nq|null|of|or|' + r'otherwise|pa1|pa2|pa3|page-count|page-number|parm-register|' + r'path-id|pattern|perform|point|pos|primary|print|proc|' + r'procedure|program|put|read|record|record-count|record-length|' + r'refresh|release|renum|repeat|report|report-input|reshow|' + r'restart|retrieve|return-code|rollback|row|s|screen|search|' + r'secondary|select|sequence|size|skip|sokaku|sort|sql|stop|sum|' + r'sysdate|sysdate-long|sysin|sysipt|syslst|sysprint|syssnap|' + r'systime|tally|term-columns|term-name|term-rows|termination|' + r'title|to|transfer|trc|unique|until|update|uppercase|user|' + r'userid|value|verify|w|when|while|work|write|x|xdm|xrst)[ \'.,():]', + Keyword.Reserved), + # These are not actually keywords but section separators so + # treating them differently from names seems in order. + # TODO: Fix: (r'(param|report)[ \'.,():]', Keyword), + (r'[\[\](){}<>;,]', Punctuation), + (r'[-+/=&%]', Operator), + (r'[0-9]+\.[0-9]*', Number.Float), + (r'[0-9]+', Number.Integer), + (r"'(''|[^'])*'", String), + (r'\*.*\n', Comment.Single), + (r'\.', Operator), + (r'\s+', Whitespace), + (r'[^ \'.,():]+', Name) # Everything else just belongs to a name + ] + } + + +class JclLexer(RegexLexer): + """ + Job Control Language (JCL) is a scripting language used on IBM mainframe + operating systems to instruct the system on how to run a batch job or + start a subsystem. + + For more information, refer to the + `MVS Job Control Language Reference `_ + """ + name = 'JCL' + aliases = ['jcl'] + filenames = ['*.jcl'] + mimetypes = ['text/x-jcl'] + flags = re.IGNORECASE + + tokens = { + 'root': [ + (r'//\*.*\n', Comment.Single), + (r'//', Keyword.Pseudo, 'statement'), + (r'/\*', Keyword.Pseudo, 'jes2_statement'), + # TODO: JES3 statement + (r'.*\n', Other) # Input text or inline code in any language. + ], + 'statement': [ + (r'\s*\n', Whitespace, 'root'), + (r'([a-z][a-z_0-9]*)(\s+)(exec|job)(\s*)', + bygroups(Name.Label, Whitespace, Keyword.Reserved, Whitespace), + 'option'), + (r'[a-z][a-z_0-9]*', Name.Variable, 'statement_command'), + (r'\s+', Whitespace, 'statement_command'), + ], + 'statement_command': [ + (r'\s+(command|cntl|dd|endctl|endif|else|include|jcllib|' + r'output|pend|proc|set|then|xmit)', Keyword.Reserved, 'option'), + include('option') + ], + 'jes2_statement': [ + (r'\s*\n', Whitespace, 'root'), + (r'\$', Keyword, 'option'), + (r'\b(jobparam|message|netacct|notify|output|priority|route|' + r'setup|signoff|xeq|xmit)\b', Keyword, 'option'), + ], + 'option': [ + (r'\n', Text, 'root'), + (r'\*', Name.Builtin), + (r'[\[\](){}<>;,]', Punctuation), + (r'[-+*/=&%]', Operator), + (r'[a-zA-Z_][a-zA-Z_0-9]*', Name), + (r'[0-9]+\.[0-9]*', Number.Float), + (r'\.[0-9]+', Number.Float), + (r'[0-9]+', Number.Integer), + (r"'", String, 'option_string'), + (r'\s+', Whitespace), + ], + 'option_string': [ + (r"(\n)(//)", bygroups(Text, Keyword.Pseudo)), + (r"''", String), + (r"[^']", String), + (r"'", String, 'option'), + ] + } + + +class WebFocusLexer(RegexLexer): + """ + WebFOCUS und FOCUS are business intelligence tools mainly used in + mainframe related environments. + + For more information, refer to the + `Information Builders product page `_. + """ + name = 'WebFOCUS' + aliases = ['webfocus', 'FOCUS', 'focus'] + filenames = ['*.fex'] + mimetypes = ['text/x-webfocus', 'text/x-focus'] + flags = re.IGNORECASE + + # TODO: Consolidate rules common to 'focus' and 'dialog_manager' with 'include' or something. + # TODO: Find out if FIDEL supports "" to escape " and if so implement it. + # TODO: Add support for backslash escapes in single quote strings (and maybe double quote too?). + # TODO: Support dialog manager FIDEL input modifiers such as '.nodisplay'. + # TODO: Highlight function name after DEFINE FUNCTION. + # TODO: Highlight field name for all field types, not only numeric ones. + tokens = { + 'root': [ + (r'-\*.*\n', Comment.Single), + (r'-', Punctuation, 'dialog_manager'), + include('focus') + ], + 'focus': [ + (r'\n', Text, 'root'), + (r'\s*(across|add|alloc|as|by|clear|column-total|compute|count|' + r'crtform|decode|define|dynam|else|end|ex|exceeds|exec|file|' + r'filter|footing|for|format|free|heading|highest|hold|if|' + r'in-groups-of|in-ranges-of|join|list|lowest|match|modify|' + r'multilines|newpage|nomatch|noprint|nototal|on|over|' + r'page-break|print|printonly|ranked|recap|recompute|redefines|' + r'reject|row-total|rows|savb|save|set|sub-total|subfoot|' + r'subhead|subtotal|sum|summarize|table|the|then|tiles|total|' + r'update|when|where|with|within)\b', Keyword.Reserved), + (r'"', String, 'focus_fidel'), + (r'\b(missing)\b', Name.Constant), + (r'\b(asq|ave|cnt|cnt|ct|dst|fst|lst|max|min|pct|rcpt|st|sum|' + r'tot)\.', Operator), + # FOCUS field declaration including display options. + (r'([a-z][a-z_0-9]*)([/])([adfip]*[0-9]+(\.[0-9]+)[-%bcdelmnrsty]*)', + bygroups(Name.Variable, Operator, Keyword.Type)), + # Rules common to 'focus' and 'dialog_manager'. + (r'\b(and|contains|div|eq|exceeds|excludes|from|ge|gt|in|' + r'includes|is|is-from|is-from|is-less-than|is-more-than|' + r'is-not-missing|le|like|lt|mod|ne|not|not-from|omits|or|to)\b', + Operator), + (r'[-+*/=|!]', Operator), + (r'[(){}<>;,]', Punctuation), + (r'[a-z_][a-z_0-9]*', Literal), + (r'[&]+[a-z_][a-z_0-9]*', Literal), + (r'[0-9]+\.[0-9]*', Number.Float), + (r'\.[0-9]+', Number.Float), + (r'[0-9]+', Number.Integer), + (r"'(''|[^'])*'", String), + (r'\s+', Whitespace) + ], + 'dialog_manager': [ + # Detect possible labels in first word of dialog manager line. + (r'\s*type\b', Keyword.Reserved, 'dialog_manager_type'), + (r'[:][a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), + (r'"', String, 'dialog_manager_fidel'), + # TODO: Get rid of redundant dialog manager keyword rule which + # already could be handled by the included + # 'dialog_manager_others'. However, we currently need it to not + # recognize classic labels without ':' too soon. + (r'\b([?]|close|cms|crtclear|crtform|default|defaults|else|exit|' + r'goto|htmlform|if|include|mvs|pass|prompt|quit|read|repeat|' + r'run|set|then|tso|type|window|write)\b', Keyword.Reserved, + 'dialog_manager_others'), + (r'[a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), + include('dialog_manager_others'), + ], + 'dialog_manager_others': [ + (r'\n', Text, 'root'), + (r'\s*type\b', Keyword.Reserved, 'dialog_manager_type'), + (r'[:][a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), + (r'\b([?]|close|cms|crtclear|crtform|default|defaults|else|exit|' + r'goto|htmlform|if|include|mvs|pass|prompt|quit|read|repeat|' + r'run|set|then|tso|type|window|write)\b', Keyword.Reserved), + # Rules common to 'focus' and 'dialog_manager'. + (r'\b(and|contains|div|eq|exceeds|excludes|from|ge|gt|in|' + r'includes|is|is-from|is-from|is-less-than|is-more-than|' + r'is-not-missing|le|like|lt|mod|ne|not|not-from|omits|or|to)\b', + Operator), + (r'[-+*/=|!]', Operator), + (r'[(){}<>;,]', Punctuation), + (r'[a-z_][a-z_0-9]*', Literal), + (r'[&]+[a-z_][a-z_0-9]*', Name.Variable), + (r'[0-9]+\.[0-9]*', Number.Float), + (r'\.[0-9]+', Number.Float), + (r'[0-9]+', Number.Integer), + (r"'(''|[^'])*'", String), + (r'\s+', Whitespace) + ], + 'dialog_manager_type': [ + # For -TYPE, render everything as ``String`` except variables. + (r'\n', Text, 'root'), + (r'[&]+[a-z_][a-z_0-9]*\.*', Name.Variable), + (r'[^&\n]*', String) + ], + 'dialog_manager_fidel': [ + (r'"', String, 'dialog_manager_fidel_end'), + (r'([<])([&][a-z][a-z_0-9]*)([/])([0-9]+)', + bygroups(Keyword.Reserved, Name.Variable, Operator, Number.Integer)), + (r'.', String) + ], + 'dialog_manager_fidel_end': [ + (r'\n', Text, 'root'), + (r'\s*', Whitespace) + ], + 'focus_fidel': [ + (r'"', String, 'focus_fidel_end'), + (r'[&]+[a-z][a-z_0-9]*', Name.Variable), + (r'\>', Keyword.Reserved), + # Line continuation. + (r'\<0x\s*\n', Keyword.Reserved), + (r'([<])([a-z][a-z_0-9]*)', + bygroups(Keyword.Reserved, Name.Variable)), + (r'([<])([+-/]?)([0-9]+)', + bygroups(Keyword.Reserved, Operator, Number.Integer)), + (r'.', String) + ], + 'focus_fidel_end': [ + (r'\n', Text, 'root'), + (r'\s*', Whitespace) + ] + } diff --git a/tests/examplefiles/test.ezt b/tests/examplefiles/test.ezt new file mode 100644 index 00000000..8ef53089 --- /dev/null +++ b/tests/examplefiles/test.ezt @@ -0,0 +1,18 @@ +* EasyTrieve Plus Test Programm. + +* Environtment section. +PARM DEBUG(FLOW FLDCHK) + +* Library Section +FILE PERSNL FB(150 1800) + NAME 17 8 A + EMP# 9 5 N * <-- '#' is a valid character for names. + DEPT 98 3 N. GROSS 94 4 P 2 + * ^ 2 field definitions in 1 line. + +* Activity Section +JOB INPUT PERSNL NAME FIRST-PROGRAM + PRINT PAY-RPT +REPORT PAY-RPT LINESIZE 80 + TITLE 01 'PERSONNEL REPORT EXAMPLE-1' + LINE 01 DEPT NAME EMP# GROSS diff --git a/tests/examplefiles/test.fex b/tests/examplefiles/test.fex new file mode 100644 index 00000000..92d0b0f6 --- /dev/null +++ b/tests/examplefiles/test.fex @@ -0,0 +1,225 @@ +-* WebFOCUS test source file for pygments. + +-* Some basic commands +-TYPE hello world! +-SET &NAME='John'; +-TYPE hello &NAME ! +-SET &DATETMP = DATECVT((DATEADD((DATECVT(&DATEIN, 'I8YYMD', 'YYMD')),'M', -6)),'YYMD','I8YYMD'); + +-GOTO LABEL1; +-TYPE Skip me + +-* Label using classic syntax. +-LABEL1 + +-* Label using modern syntax. +-:LABEL2 + +-* Use FIDEL with MODIFY. +MODIFY FILE EMPLOYEE +CRTFORM + "EMPLOYEE UPDATE" + "EMPLOYEE ID #: : BANK, EMPLOYEES AND SALARIES " + "<10 . +-HTMLFORM CSTERM +-SET &ECHO = ALL; +-* +-* Replaces IDCAMS SYSIN +-* +DYNAM ALLOC FILE CATCTL NEW RECFM FB - + LRECL 80 BLKSIZE 3120 SPACE 1,1 TRK REUSE +-* +-* Replaces IDCAMS SYSPRINT +-* +DYNAM ALLOC FILE CATLST NEW RECFM VBA - + LRECL 125 BLKSIZE 27998 SPACE 2,1 TRK REUSE +-* +-* PRINT80 is a MFD used to read an 80 byte field named CONTENTS +-* +DYNAM ALLOC FILE PRNT80 NEW RECFM FB - + LRECL 80 BLKSIZE 3120 SPACE 1,1 TRK REUSE +-* +-RUN +-* +-* Create the tape dataset name mask (first five nodes) +-* +-SET &CAT1 = ' LISTC LVL(' || '''' || +- 'PN0100.A143200.P87.P87800.STERM' || '''' || ') VOL'; +-* +-WRITE CATCTL &CAT1 +-* +-RUN +-* +-* Call the user written subroutine (i.e., GETCAT) to retrieve a list of tape datasets +-* +-SET &X = ' '; +-SET &X = GETCAT(&X,'A1'); +-* +-* TABLE the catalog listing of tape datasets to a HOLD file +-* +DEFINE FILE PRNT80 + DSNAME/A44 = SUBSTR (80,CONTENTS,1,44,44,'A44'); +END +-* +TABLE FILE PRNT80 + PRINT DSNAME + ON TABLE HOLD +END +-* +DYNAM FREE FILE CATCTL +DYNAM FREE FILE CATLST +DYNAM FREE FILE PRNT80 +-* +-RUN +-* +-*----------------------------------------------------------------------- +-* +-* Create the HTML drop down list +-* +DEFINE FILE HOLD + NODE_POS/I3 = POSIT (DSNAME,44,'.SEM',4,'I3'); + WHATSEM/A4 = SUBSTR (44,DSNAME,NODE_POS+4,44,4,'A4'); + SEMWK/A2 = EDIT (WHATSEM,'$$99'); + SEMYR/A2 = EDIT (WHATSEM,'99$$'); + SEMESTERY2K/A6 = IF SEMYR LT '50' THEN ('20' | WHATSEM) + ELSE ('19' | WHATSEM); + D_SEM/A8 = DECODE SEMWK (03 'Spring' + 20 'Summer 1' + 26 'Summer 2' + 36 'Fall' + ELSE 'ERROR'); + SEMTXT/A16 = D_SEM | ' - ' | WHATSEM; +-* Create the dynamic html for the drop down list + SEMESTER/A50 = ''; +END +-* +TABLE FILE HOLD + SUM SEMESTER +-* Want the most recent semester first + BY HIGHEST SEMESTERY2K NOPRINT + ON TABLE SET HOLDLIST PRINTONLY + ON TABLE HOLD AS HOLDSEMS +END +-* +-RUN +-* +-*----------------------------------------------------------------------- +-* +-SET &SPACE = '&' || 'nbsp;'; +-* +-* Display the HTML form to allow users to select semester/cycle +-* +-HTMLFORM CSTERM diff --git a/tests/examplefiles/test.jcl b/tests/examplefiles/test.jcl new file mode 100644 index 00000000..51c5de1b --- /dev/null +++ b/tests/examplefiles/test.jcl @@ -0,0 +1,30 @@ +//IS198CPY JOB (PYGM-TEST-001),'PYGMENTS TEST JOB', +// CLASS=L, MSGCLASS=X, TIME=(00,10) +//* Copy 'OLDFILE' to 'NEWFILE'. +//COPY01 EXEC PGM=IEBGENER +//SYSPRINT DD SYSOUT=* +//SYSUT1 DD DSN=OLDFILE,DISP=SHR +//SYSUT2 DD DSN=NEWFILE, +// DISP=(NEW,CATLG,DELETE), +// SPACE=(CYL,(40,5),RLSE), +// DCB=(LRECL=115,BLKSIZE=1150) +//SYSIN DD DUMMY +/* +//* Test line continuation in strings. +//CONT01 EXEC PGM=IEFBR14,PARM='THIS IS A LONG PARAMETER WITHIN APOST +// ROPHES, CONTINUED IN COLUMN 15 OF THE NEXT RECORD' +//* Sort a couple of lines and show the result in the job log. +//SORT01 EXEC PGM=IEFBR14 +//SORTIN DD * +spam +eggs +ham +/* +//SORTOUT DD SYSOUT=* +/* +//* Test line continuation with comment at the end of a line +//STP4 EXEC PROC=BILLING,COND.PAID=((20,LT),EVEN), +// COND.LATE=(60,GT,FIND), +// COND.BILL=((20,GE),(30,LT,CHGE)) THIS STATEMENT CALLS X +// THE BILLING PROCEDURE AND SPECIFIES RETURN CODE TESTS X +// FOR THREE PROCEDURE STEPS. -- cgit v1.2.1 From bb1611634bdef386c29c9558074efdd5bcfafbab Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Wed, 20 Feb 2013 02:27:09 +0100 Subject: Renamed mainframe example files from test.* to example.*. --- tests/examplefiles/example.ezt | 18 ++++ tests/examplefiles/example.fex | 225 +++++++++++++++++++++++++++++++++++++++++ tests/examplefiles/example.jcl | 30 ++++++ tests/examplefiles/test.ezt | 18 ---- tests/examplefiles/test.fex | 225 ----------------------------------------- tests/examplefiles/test.jcl | 30 ------ 6 files changed, 273 insertions(+), 273 deletions(-) create mode 100644 tests/examplefiles/example.ezt create mode 100644 tests/examplefiles/example.fex create mode 100644 tests/examplefiles/example.jcl delete mode 100644 tests/examplefiles/test.ezt delete mode 100644 tests/examplefiles/test.fex delete mode 100644 tests/examplefiles/test.jcl diff --git a/tests/examplefiles/example.ezt b/tests/examplefiles/example.ezt new file mode 100644 index 00000000..8ef53089 --- /dev/null +++ b/tests/examplefiles/example.ezt @@ -0,0 +1,18 @@ +* EasyTrieve Plus Test Programm. + +* Environtment section. +PARM DEBUG(FLOW FLDCHK) + +* Library Section +FILE PERSNL FB(150 1800) + NAME 17 8 A + EMP# 9 5 N * <-- '#' is a valid character for names. + DEPT 98 3 N. GROSS 94 4 P 2 + * ^ 2 field definitions in 1 line. + +* Activity Section +JOB INPUT PERSNL NAME FIRST-PROGRAM + PRINT PAY-RPT +REPORT PAY-RPT LINESIZE 80 + TITLE 01 'PERSONNEL REPORT EXAMPLE-1' + LINE 01 DEPT NAME EMP# GROSS diff --git a/tests/examplefiles/example.fex b/tests/examplefiles/example.fex new file mode 100644 index 00000000..92d0b0f6 --- /dev/null +++ b/tests/examplefiles/example.fex @@ -0,0 +1,225 @@ +-* WebFOCUS test source file for pygments. + +-* Some basic commands +-TYPE hello world! +-SET &NAME='John'; +-TYPE hello &NAME ! +-SET &DATETMP = DATECVT((DATEADD((DATECVT(&DATEIN, 'I8YYMD', 'YYMD')),'M', -6)),'YYMD','I8YYMD'); + +-GOTO LABEL1; +-TYPE Skip me + +-* Label using classic syntax. +-LABEL1 + +-* Label using modern syntax. +-:LABEL2 + +-* Use FIDEL with MODIFY. +MODIFY FILE EMPLOYEE +CRTFORM + "EMPLOYEE UPDATE" + "EMPLOYEE ID #: : BANK, EMPLOYEES AND SALARIES " + "<10 . +-HTMLFORM CSTERM +-SET &ECHO = ALL; +-* +-* Replaces IDCAMS SYSIN +-* +DYNAM ALLOC FILE CATCTL NEW RECFM FB - + LRECL 80 BLKSIZE 3120 SPACE 1,1 TRK REUSE +-* +-* Replaces IDCAMS SYSPRINT +-* +DYNAM ALLOC FILE CATLST NEW RECFM VBA - + LRECL 125 BLKSIZE 27998 SPACE 2,1 TRK REUSE +-* +-* PRINT80 is a MFD used to read an 80 byte field named CONTENTS +-* +DYNAM ALLOC FILE PRNT80 NEW RECFM FB - + LRECL 80 BLKSIZE 3120 SPACE 1,1 TRK REUSE +-* +-RUN +-* +-* Create the tape dataset name mask (first five nodes) +-* +-SET &CAT1 = ' LISTC LVL(' || '''' || +- 'PN0100.A143200.P87.P87800.STERM' || '''' || ') VOL'; +-* +-WRITE CATCTL &CAT1 +-* +-RUN +-* +-* Call the user written subroutine (i.e., GETCAT) to retrieve a list of tape datasets +-* +-SET &X = ' '; +-SET &X = GETCAT(&X,'A1'); +-* +-* TABLE the catalog listing of tape datasets to a HOLD file +-* +DEFINE FILE PRNT80 + DSNAME/A44 = SUBSTR (80,CONTENTS,1,44,44,'A44'); +END +-* +TABLE FILE PRNT80 + PRINT DSNAME + ON TABLE HOLD +END +-* +DYNAM FREE FILE CATCTL +DYNAM FREE FILE CATLST +DYNAM FREE FILE PRNT80 +-* +-RUN +-* +-*----------------------------------------------------------------------- +-* +-* Create the HTML drop down list +-* +DEFINE FILE HOLD + NODE_POS/I3 = POSIT (DSNAME,44,'.SEM',4,'I3'); + WHATSEM/A4 = SUBSTR (44,DSNAME,NODE_POS+4,44,4,'A4'); + SEMWK/A2 = EDIT (WHATSEM,'$$99'); + SEMYR/A2 = EDIT (WHATSEM,'99$$'); + SEMESTERY2K/A6 = IF SEMYR LT '50' THEN ('20' | WHATSEM) + ELSE ('19' | WHATSEM); + D_SEM/A8 = DECODE SEMWK (03 'Spring' + 20 'Summer 1' + 26 'Summer 2' + 36 'Fall' + ELSE 'ERROR'); + SEMTXT/A16 = D_SEM | ' - ' | WHATSEM; +-* Create the dynamic html for the drop down list + SEMESTER/A50 = ''; +END +-* +TABLE FILE HOLD + SUM SEMESTER +-* Want the most recent semester first + BY HIGHEST SEMESTERY2K NOPRINT + ON TABLE SET HOLDLIST PRINTONLY + ON TABLE HOLD AS HOLDSEMS +END +-* +-RUN +-* +-*----------------------------------------------------------------------- +-* +-SET &SPACE = '&' || 'nbsp;'; +-* +-* Display the HTML form to allow users to select semester/cycle +-* +-HTMLFORM CSTERM diff --git a/tests/examplefiles/example.jcl b/tests/examplefiles/example.jcl new file mode 100644 index 00000000..51c5de1b --- /dev/null +++ b/tests/examplefiles/example.jcl @@ -0,0 +1,30 @@ +//IS198CPY JOB (PYGM-TEST-001),'PYGMENTS TEST JOB', +// CLASS=L, MSGCLASS=X, TIME=(00,10) +//* Copy 'OLDFILE' to 'NEWFILE'. +//COPY01 EXEC PGM=IEBGENER +//SYSPRINT DD SYSOUT=* +//SYSUT1 DD DSN=OLDFILE,DISP=SHR +//SYSUT2 DD DSN=NEWFILE, +// DISP=(NEW,CATLG,DELETE), +// SPACE=(CYL,(40,5),RLSE), +// DCB=(LRECL=115,BLKSIZE=1150) +//SYSIN DD DUMMY +/* +//* Test line continuation in strings. +//CONT01 EXEC PGM=IEFBR14,PARM='THIS IS A LONG PARAMETER WITHIN APOST +// ROPHES, CONTINUED IN COLUMN 15 OF THE NEXT RECORD' +//* Sort a couple of lines and show the result in the job log. +//SORT01 EXEC PGM=IEFBR14 +//SORTIN DD * +spam +eggs +ham +/* +//SORTOUT DD SYSOUT=* +/* +//* Test line continuation with comment at the end of a line +//STP4 EXEC PROC=BILLING,COND.PAID=((20,LT),EVEN), +// COND.LATE=(60,GT,FIND), +// COND.BILL=((20,GE),(30,LT,CHGE)) THIS STATEMENT CALLS X +// THE BILLING PROCEDURE AND SPECIFIES RETURN CODE TESTS X +// FOR THREE PROCEDURE STEPS. diff --git a/tests/examplefiles/test.ezt b/tests/examplefiles/test.ezt deleted file mode 100644 index 8ef53089..00000000 --- a/tests/examplefiles/test.ezt +++ /dev/null @@ -1,18 +0,0 @@ -* EasyTrieve Plus Test Programm. - -* Environtment section. -PARM DEBUG(FLOW FLDCHK) - -* Library Section -FILE PERSNL FB(150 1800) - NAME 17 8 A - EMP# 9 5 N * <-- '#' is a valid character for names. - DEPT 98 3 N. GROSS 94 4 P 2 - * ^ 2 field definitions in 1 line. - -* Activity Section -JOB INPUT PERSNL NAME FIRST-PROGRAM - PRINT PAY-RPT -REPORT PAY-RPT LINESIZE 80 - TITLE 01 'PERSONNEL REPORT EXAMPLE-1' - LINE 01 DEPT NAME EMP# GROSS diff --git a/tests/examplefiles/test.fex b/tests/examplefiles/test.fex deleted file mode 100644 index 92d0b0f6..00000000 --- a/tests/examplefiles/test.fex +++ /dev/null @@ -1,225 +0,0 @@ --* WebFOCUS test source file for pygments. - --* Some basic commands --TYPE hello world! --SET &NAME='John'; --TYPE hello &NAME ! --SET &DATETMP = DATECVT((DATEADD((DATECVT(&DATEIN, 'I8YYMD', 'YYMD')),'M', -6)),'YYMD','I8YYMD'); - --GOTO LABEL1; --TYPE Skip me - --* Label using classic syntax. --LABEL1 - --* Label using modern syntax. --:LABEL2 - --* Use FIDEL with MODIFY. -MODIFY FILE EMPLOYEE -CRTFORM - "EMPLOYEE UPDATE" - "EMPLOYEE ID #: : BANK, EMPLOYEES AND SALARIES " - "<10 . --HTMLFORM CSTERM --SET &ECHO = ALL; --* --* Replaces IDCAMS SYSIN --* -DYNAM ALLOC FILE CATCTL NEW RECFM FB - - LRECL 80 BLKSIZE 3120 SPACE 1,1 TRK REUSE --* --* Replaces IDCAMS SYSPRINT --* -DYNAM ALLOC FILE CATLST NEW RECFM VBA - - LRECL 125 BLKSIZE 27998 SPACE 2,1 TRK REUSE --* --* PRINT80 is a MFD used to read an 80 byte field named CONTENTS --* -DYNAM ALLOC FILE PRNT80 NEW RECFM FB - - LRECL 80 BLKSIZE 3120 SPACE 1,1 TRK REUSE --* --RUN --* --* Create the tape dataset name mask (first five nodes) --* --SET &CAT1 = ' LISTC LVL(' || '''' || -- 'PN0100.A143200.P87.P87800.STERM' || '''' || ') VOL'; --* --WRITE CATCTL &CAT1 --* --RUN --* --* Call the user written subroutine (i.e., GETCAT) to retrieve a list of tape datasets --* --SET &X = ' '; --SET &X = GETCAT(&X,'A1'); --* --* TABLE the catalog listing of tape datasets to a HOLD file --* -DEFINE FILE PRNT80 - DSNAME/A44 = SUBSTR (80,CONTENTS,1,44,44,'A44'); -END --* -TABLE FILE PRNT80 - PRINT DSNAME - ON TABLE HOLD -END --* -DYNAM FREE FILE CATCTL -DYNAM FREE FILE CATLST -DYNAM FREE FILE PRNT80 --* --RUN --* --*----------------------------------------------------------------------- --* --* Create the HTML drop down list --* -DEFINE FILE HOLD - NODE_POS/I3 = POSIT (DSNAME,44,'.SEM',4,'I3'); - WHATSEM/A4 = SUBSTR (44,DSNAME,NODE_POS+4,44,4,'A4'); - SEMWK/A2 = EDIT (WHATSEM,'$$99'); - SEMYR/A2 = EDIT (WHATSEM,'99$$'); - SEMESTERY2K/A6 = IF SEMYR LT '50' THEN ('20' | WHATSEM) - ELSE ('19' | WHATSEM); - D_SEM/A8 = DECODE SEMWK (03 'Spring' - 20 'Summer 1' - 26 'Summer 2' - 36 'Fall' - ELSE 'ERROR'); - SEMTXT/A16 = D_SEM | ' - ' | WHATSEM; --* Create the dynamic html for the drop down list - SEMESTER/A50 = ''; -END --* -TABLE FILE HOLD - SUM SEMESTER --* Want the most recent semester first - BY HIGHEST SEMESTERY2K NOPRINT - ON TABLE SET HOLDLIST PRINTONLY - ON TABLE HOLD AS HOLDSEMS -END --* --RUN --* --*----------------------------------------------------------------------- --* --SET &SPACE = '&' || 'nbsp;'; --* --* Display the HTML form to allow users to select semester/cycle --* --HTMLFORM CSTERM diff --git a/tests/examplefiles/test.jcl b/tests/examplefiles/test.jcl deleted file mode 100644 index 51c5de1b..00000000 --- a/tests/examplefiles/test.jcl +++ /dev/null @@ -1,30 +0,0 @@ -//IS198CPY JOB (PYGM-TEST-001),'PYGMENTS TEST JOB', -// CLASS=L, MSGCLASS=X, TIME=(00,10) -//* Copy 'OLDFILE' to 'NEWFILE'. -//COPY01 EXEC PGM=IEBGENER -//SYSPRINT DD SYSOUT=* -//SYSUT1 DD DSN=OLDFILE,DISP=SHR -//SYSUT2 DD DSN=NEWFILE, -// DISP=(NEW,CATLG,DELETE), -// SPACE=(CYL,(40,5),RLSE), -// DCB=(LRECL=115,BLKSIZE=1150) -//SYSIN DD DUMMY -/* -//* Test line continuation in strings. -//CONT01 EXEC PGM=IEFBR14,PARM='THIS IS A LONG PARAMETER WITHIN APOST -// ROPHES, CONTINUED IN COLUMN 15 OF THE NEXT RECORD' -//* Sort a couple of lines and show the result in the job log. -//SORT01 EXEC PGM=IEFBR14 -//SORTIN DD * -spam -eggs -ham -/* -//SORTOUT DD SYSOUT=* -/* -//* Test line continuation with comment at the end of a line -//STP4 EXEC PROC=BILLING,COND.PAID=((20,LT),EVEN), -// COND.LATE=(60,GT,FIND), -// COND.BILL=((20,GE),(30,LT,CHGE)) THIS STATEMENT CALLS X -// THE BILLING PROCEDURE AND SPECIFIES RETURN CODE TESTS X -// FOR THREE PROCEDURE STEPS. -- cgit v1.2.1 From 117caaeb9d100b37f7a3f652f5c33cc1b62c30ba Mon Sep 17 00:00:00 2001 From: roskakori Date: Wed, 20 Feb 2013 03:22:35 +0100 Subject: Added support for option comments. --- pygments/lexers/other.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 18d3059d..701f98b9 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -365,7 +365,7 @@ class SmalltalkLexer(RegexLexer): include('literals'), ], 'afterobject' : [ - (r'! !$', Keyword , '#pop'), # squeak chunk delimeter + (r'! !$', Keyword , '#pop'), # squeak chunk delimiter include('whitespaces'), (r'\b(ifTrue:|ifFalse:|whileTrue:|whileFalse:|timesRepeat:)', Name.Builtin, '#pop'), @@ -3773,7 +3773,7 @@ class JclLexer(RegexLexer): ], 'statement_command': [ (r'\s+(command|cntl|dd|endctl|endif|else|include|jcllib|' - r'output|pend|proc|set|then|xmit)', Keyword.Reserved, 'option'), + r'output|pend|proc|set|then|xmit)\s*', Keyword.Reserved, 'option'), include('option') ], 'jes2_statement': [ @@ -3792,13 +3792,18 @@ class JclLexer(RegexLexer): (r'\.[0-9]+', Number.Float), (r'[0-9]+', Number.Integer), (r"'", String, 'option_string'), - (r'\s+', Whitespace), + (r'\s+', Whitespace, 'option_comment'), + (r'\.', Punctuation), ], 'option_string': [ (r"(\n)(//)", bygroups(Text, Keyword.Pseudo)), (r"''", String), (r"[^']", String), (r"'", String, 'option'), + ], + 'option_comment': [ + (r'\n', Text, 'root'), + (r'.*', Comment.Single), ] } -- cgit v1.2.1 From b05cda5226e10dbfdfe9a939277db909dcf1624d Mon Sep 17 00:00:00 2001 From: roskakori Date: Wed, 20 Feb 2013 03:27:16 +0100 Subject: Cleaned up indentation. --- pygments/lexers/other.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 701f98b9..240becdc 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -1963,11 +1963,11 @@ class AsymptoteLexer(RegexLexer): from pygments.lexers._asybuiltins import ASYFUNCNAME, ASYVARNAME for index, token, value in \ RegexLexer.get_tokens_unprocessed(self, text): - if token is Name and value in ASYFUNCNAME: - token = Name.Function - elif token is Name and value in ASYVARNAME: - token = Name.Variable - yield index, token, value + if token is Name and value in ASYFUNCNAME: + token = Name.Function + elif token is Name and value in ASYVARNAME: + token = Name.Variable + yield index, token, value class PostScriptLexer(RegexLexer): -- cgit v1.2.1 From 2c3d320beee9e4dfa039e96cbc629af80ca0da08 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Wed, 20 Feb 2013 17:36:30 +0100 Subject: * Added example for JCL option comment. * Fixed broken white space in example JCL job header. --- tests/examplefiles/example.jcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/examplefiles/example.jcl b/tests/examplefiles/example.jcl index 51c5de1b..fb006369 100644 --- a/tests/examplefiles/example.jcl +++ b/tests/examplefiles/example.jcl @@ -1,12 +1,12 @@ //IS198CPY JOB (PYGM-TEST-001),'PYGMENTS TEST JOB', -// CLASS=L, MSGCLASS=X, TIME=(00,10) +// CLASS=L,MSGCLASS=X,TIME=(00,10) //* Copy 'OLDFILE' to 'NEWFILE'. //COPY01 EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=OLDFILE,DISP=SHR //SYSUT2 DD DSN=NEWFILE, // DISP=(NEW,CATLG,DELETE), -// SPACE=(CYL,(40,5),RLSE), +// SPACE=(CYL,(40,5),RLSE), Some comment // DCB=(LRECL=115,BLKSIZE=1150) //SYSIN DD DUMMY /* -- cgit v1.2.1 From 3260756274b472351f56d9ce0e8a227d5f98c9be Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Wed, 20 Feb 2013 17:38:28 +0100 Subject: Added EasyTrieve 'not' operator. --- pygments/lexers/other.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 240becdc..57598e1a 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3685,7 +3685,6 @@ class EasyTrieveLexer(RegexLexer): # TODO: Treat only the first 72 characters as source code and the rest as comment. # TODO: After some reserved words such as 'define', even keywords are names. # TODO: Consider continuation characters '+' and '-' - # TODO: Treat the 'not' character as operator. tokens = { 'root': [ @@ -3728,7 +3727,7 @@ class EasyTrieveLexer(RegexLexer): # treating them differently from names seems in order. # TODO: Fix: (r'(param|report)[ \'.,():]', Keyword), (r'[\[\](){}<>;,]', Punctuation), - (r'[-+/=&%]', Operator), + (ur'[-+/=&%¬]', Operator), (r'[0-9]+\.[0-9]*', Number.Float), (r'[0-9]+', Number.Integer), (r"'(''|[^'])*'", String), -- cgit v1.2.1 From 5b3aa5ce59965a6663e0451ca5600c16091ad31d Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Wed, 20 Feb 2013 17:44:16 +0100 Subject: Fixed endless loop in case a WebFOCUS FIDEL segment contained any non white space characters after the terminating double quote. --- pygments/lexers/other.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 57598e1a..9607e327 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3918,7 +3918,7 @@ class WebFocusLexer(RegexLexer): ], 'dialog_manager_fidel_end': [ (r'\n', Text, 'root'), - (r'\s*', Whitespace) + (r'\s+', Whitespace) ], 'focus_fidel': [ (r'"', String, 'focus_fidel_end'), @@ -3934,6 +3934,6 @@ class WebFocusLexer(RegexLexer): ], 'focus_fidel_end': [ (r'\n', Text, 'root'), - (r'\s*', Whitespace) + (r'\s+', Whitespace) ] } -- cgit v1.2.1 From 149dc5f44ec02a0ec06ff14a39262b97fa1d192b Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Fri, 22 Feb 2013 02:06:43 +0100 Subject: * Added guessing for EasyTrieve, JCL and (Web)FOCUS lexer. * Removed comment containing "<-" from EasyTrieve example so it won't be guessed to be a source code for the S language. * Improved guessing for Mason language so it does not interpret FOCUS FIDEL variable references as Mason calling components. * Cleaned up indentation. --- pygments/lexers/other.py | 154 ++++++++++++++++++++++++++++++++++++----- pygments/lexers/templates.py | 10 +-- tests/examplefiles/example.ezt | 2 +- tests/test_lexers_other.py | 53 ++++++++++++++ 4 files changed, 197 insertions(+), 22 deletions(-) create mode 100644 tests/test_lexers_other.py diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 9607e327..446e6eff 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3734,10 +3734,70 @@ class EasyTrieveLexer(RegexLexer): (r'\*.*\n', Comment.Single), (r'\.', Operator), (r'\s+', Whitespace), - (r'[^ \'.,():]+', Name) # Everything else just belongs to a name + (r'[^ \'.,():]+', Name) # Everything else just belongs to a name ] } + def analyse_text(text): + """ + Perform a structural analysis for basic EasyTrieve constructs. + """ + result = 0.0 + hasEndProc = False + hasFile = False + hasJob = False + hasProc = False + hasParam = False + hasReport = False + isBroken = False + + # Scan the source for lines starting with indicators. + for line in text.split('\n'): + words = line.split() + if (len(words) >= 2): + first_word = words[0] + if not hasReport: + if not hasJob: + if not hasFile: + if not hasParam: + if first_word == 'PARAM': + hasParam = True + if first_word == 'FILE': + hasFile = True + if first_word == 'JOB': + hasJob = True + elif first_word == 'PROC': + hasProc = True + elif first_word == 'END-PROC': + hasEndProc = True + elif first_word == 'REPORT': + hasReport = True + + # Weight the findings. + if not isBroken and hasJob and (hasProc == hasEndProc): + if hasParam: + if hasProc: + # Found PARAM, JOB and PROC/END-PROC: + # pretty sure this is EasyTrieve. + result = 0.8 + else: + # Found PARAM and JOB: probably this is EasyTrieve + result = 0.5 + else: + # Found JOB and possibly other keywords: might be EasyTrieve + result = 0.11 + if hasParam: + # Note: PARAM is not a proper English word, so this is + # regarded a much better indicator for EasyTrieve than + # the other words. + result += 0.2 + if hasFile: + result += 0.01 + if hasReport: + result += 0.01 + assert 0.0 <= result <= 1.0 + return result + class JclLexer(RegexLexer): """ @@ -3760,7 +3820,7 @@ class JclLexer(RegexLexer): (r'//', Keyword.Pseudo, 'statement'), (r'/\*', Keyword.Pseudo, 'jes2_statement'), # TODO: JES3 statement - (r'.*\n', Other) # Input text or inline code in any language. + (r'.*\n', Other) # Input text or inline code in any language. ], 'statement': [ (r'\s*\n', Whitespace, 'root'), @@ -3806,6 +3866,20 @@ class JclLexer(RegexLexer): ] } + _JOB_HEADER_PATTERN = re.compile(r'^//[a-z#$@][a-z0-9#$@]{0,7}\s+job(\s+.*)?$', re.IGNORECASE) + + def analyse_text(text): + """ + Recognize JCL job by header. + """ + result = 0.0 + lines = text.split('\n') + if len(lines) > 0: + if JclLexer._JOB_HEADER_PATTERN.match(lines[0]): + result = 1.0 + assert 0.0 <= result <= 1.0 + return result + class WebFocusLexer(RegexLexer): """ @@ -3865,8 +3939,8 @@ class WebFocusLexer(RegexLexer): (r'[0-9]+', Number.Integer), (r"'(''|[^'])*'", String), (r'\s+', Whitespace) - ], - 'dialog_manager': [ + ], + 'dialog_manager': [ # Detect possible labels in first word of dialog manager line. (r'\s*type\b', Keyword.Reserved, 'dialog_manager_type'), (r'[:][a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), @@ -3881,8 +3955,8 @@ class WebFocusLexer(RegexLexer): 'dialog_manager_others'), (r'[a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), include('dialog_manager_others'), - ], - 'dialog_manager_others': [ + ], + 'dialog_manager_others': [ (r'\n', Text, 'root'), (r'\s*type\b', Keyword.Reserved, 'dialog_manager_type'), (r'[:][a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), @@ -3903,24 +3977,24 @@ class WebFocusLexer(RegexLexer): (r'[0-9]+', Number.Integer), (r"'(''|[^'])*'", String), (r'\s+', Whitespace) - ], - 'dialog_manager_type': [ + ], + 'dialog_manager_type': [ # For -TYPE, render everything as ``String`` except variables. (r'\n', Text, 'root'), (r'[&]+[a-z_][a-z_0-9]*\.*', Name.Variable), (r'[^&\n]*', String) - ], - 'dialog_manager_fidel': [ + ], + 'dialog_manager_fidel': [ (r'"', String, 'dialog_manager_fidel_end'), (r'([<])([&][a-z][a-z_0-9]*)([/])([0-9]+)', bygroups(Keyword.Reserved, Name.Variable, Operator, Number.Integer)), (r'.', String) - ], - 'dialog_manager_fidel_end': [ + ], + 'dialog_manager_fidel_end': [ (r'\n', Text, 'root'), (r'\s+', Whitespace) - ], - 'focus_fidel': [ + ], + 'focus_fidel': [ (r'"', String, 'focus_fidel_end'), (r'[&]+[a-z][a-z_0-9]*', Name.Variable), (r'\>', Keyword.Reserved), @@ -3931,9 +4005,55 @@ class WebFocusLexer(RegexLexer): (r'([<])([+-/]?)([0-9]+)', bygroups(Keyword.Reserved, Operator, Number.Integer)), (r'.', String) - ], - 'focus_fidel_end': [ + ], + 'focus_fidel_end': [ (r'\n', Text, 'root'), (r'\s+', Whitespace) - ] + ] } + + def analyse_text(text): + """ + Perform a heuristic analysis for certain very common WebFOCUS + constructs. + """ + result = 0.0 + hasComment = False + hasExec = False + hasInclude = False + hasSet = False + hasTableFile = False + + # Scan the source lines for indicators. + for line in text.lower().split('\n'): + if line.startswith('-'): + words = line[1:].split() + wordCount = len(words) + if wordCount > 0: + firstWord = words[0] + if firstWord.startswith('*'): + hasComment = True + elif wordCount > 1: + if firstWord == 'include': + hasInclude = True + elif (firstWord == 'set') and words[1].startswith('&'): + hasSet = True + else: + words = line.split() + wordCount = len(words) + if wordCount > 1: + if words[0] in ('ex', 'exec'): + hasExec = True + elif (words[0] in ('table', 'tablef')) \ + and (words[1] == 'file'): + hasTableFile = True + if hasComment: + result += 0.2 + if hasExec or hasInclude: + result += 0.1 + if hasTableFile: + result += 0.2 + if hasSet: + result += 0.1 + assert 0.0 <= result <= 1.0 + return result diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py index b3e70d05..55fb75dd 100644 --- a/pygments/lexers/templates.py +++ b/pygments/lexers/templates.py @@ -559,10 +559,12 @@ class MasonLexer(RegexLexer): } def analyse_text(text): - rv = 0.0 - if re.search('<&', text) is not None: - rv = 1.0 - return rv + result = 0.0 + if re.search(r'', text) is not None: + result = 1.0 + elif re.search(r'<&.+&>', text, re.DOTALL) is not None: + result = 0.11 + return result class MakoLexer(RegexLexer): diff --git a/tests/examplefiles/example.ezt b/tests/examplefiles/example.ezt index 8ef53089..68a849dd 100644 --- a/tests/examplefiles/example.ezt +++ b/tests/examplefiles/example.ezt @@ -6,7 +6,7 @@ PARM DEBUG(FLOW FLDCHK) * Library Section FILE PERSNL FB(150 1800) NAME 17 8 A - EMP# 9 5 N * <-- '#' is a valid character for names. + EMP# 9 5 N * Note: '#' is a valid character for names. DEPT 98 3 N. GROSS 94 4 P 2 * ^ 2 field definitions in 1 line. diff --git a/tests/test_lexers_other.py b/tests/test_lexers_other.py new file mode 100644 index 00000000..3c64fd43 --- /dev/null +++ b/tests/test_lexers_other.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +""" + Tests for other lexers + ~~~~~~~~~~~~~~~~~~~~~~ + + :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" +import glob +import os +import unittest + +from pygments.lexers import guess_lexer +from pygments.lexers.other import EasyTrieveLexer, JclLexer, WebFocusLexer + + +def _exampleFilePath(filename): + return os.path.join(os.path.dirname(__file__), 'examplefiles', filename) + + +class _AnalyseTextTest(unittest.TestCase): + def setUp(self): + raise NotImplementedError('self.lexer must be set') + + def testCanRecognizeAndGuessExampleFiles(self): + for pattern in self.lexer.filenames: + exampleFilesPattern = _exampleFilePath(pattern) + for exampleFilePath in glob.glob(exampleFilesPattern): + exampleFile = open(exampleFilePath, 'rb') + try: + text = exampleFile.read() + probability = self.lexer.analyse_text(text) + self.assertTrue(probability > 0, + '%s must recognize %r' % (self.lexer.name, exampleFilePath)) + guessedLexer = guess_lexer(text) + self.assertEqual(guessedLexer.name, self.lexer.name) + finally: + exampleFile.close() + + +class EasyTrieveLexerTest(_AnalyseTextTest): + def setUp(self): + self.lexer = EasyTrieveLexer() + + +class JclLexerTest(_AnalyseTextTest): + def setUp(self): + self.lexer = JclLexer() + + +class WebFocusLexerTest(_AnalyseTextTest): + def setUp(self): + self.lexer = WebFocusLexer() -- cgit v1.2.1 From af2ddb5febe5d7f51cea3d9211c9099b99b586a5 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Fri, 22 Feb 2013 03:59:43 +0100 Subject: Fixed EasyTrieve lexer, which is now case sensitive and expects keywords in upper case. --- pygments/lexers/other.py | 53 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 446e6eff..0b2a31e6 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3680,7 +3680,6 @@ class EasyTrieveLexer(RegexLexer): aliases = ['easytrieve'] filenames = ['*.ezt'] mimetypes = ['text/x-easytrieve'] - flags = re.IGNORECASE # TODO: Treat only the first 72 characters as source code and the rest as comment. # TODO: After some reserved words such as 'define', even keywords are names. @@ -3697,35 +3696,35 @@ class EasyTrieveLexer(RegexLexer): # * comma (,) # * paranthesis ( and ) # * colon (:) - (r'(after-break|after-line|after-screen|aim|and|attr|before|' - r'before-break|before-line|before-screen|bushu|by|call|case|' - r'checkpoint|chkp|chkp-status|clear|close|col|color|commit|' - r'control|copy|cursor|d|declare|default|define|delete|denwa|' - r'display|dli|do|duplicate|e|else|else-if|end|end-case|end-do|' - r'end-if|end-proc|endpage|endtable|enter|eof|eq|error|exit|' - r'external|ezlib|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|' - r'f20|f21|f22|f23|f24|f25|f26|f27|f28|f29|f3|f30|f31|f32|f33|' - r'f34|f35|f36|f4|f5|f6|f7|f8|f9|fetch|file|file-status|fill|' - r'final|first|first-dup|for|ge|get|go|goto|gq|gr|gt|heading|' - r'hex|high-values|idd|idms|if|in|insert|job|justify|kanji-date|' - r'kanji-date-long|kanji-time|key|key-pressed|kokugo|kun|' - r'last-dup|le|level|like|line|line-count|line-number|link|list|' - r'low-values|lq|ls|lt|mask|matched|mend|message|move|mstart|ne|' - r'newpage|nomask|noprint|not|note|noverify|nq|null|of|or|' - r'otherwise|pa1|pa2|pa3|page-count|page-number|parm-register|' - r'path-id|pattern|perform|point|pos|primary|print|proc|' - r'procedure|program|put|read|record|record-count|record-length|' - r'refresh|release|renum|repeat|report|report-input|reshow|' - r'restart|retrieve|return-code|rollback|row|s|screen|search|' - r'secondary|select|sequence|size|skip|sokaku|sort|sql|stop|sum|' - r'sysdate|sysdate-long|sysin|sysipt|syslst|sysprint|syssnap|' - r'systime|tally|term-columns|term-name|term-rows|termination|' - r'title|to|transfer|trc|unique|until|update|uppercase|user|' - r'userid|value|verify|w|when|while|work|write|x|xdm|xrst)[ \'.,():]', + (r'(AFTER-BREAK|AFTER-LINE|AFTER-SCREEN|AIM|AND|ATTR|BEFORE|' + r'BEFORE-BREAK|BEFORE-LINE|BEFORE-SCREEN|BUSHU|BY|CALL|CASE|' + r'CHECKPOINT|CHKP|CHKP-STATUS|CLEAR|CLOSE|COL|COLOR|COMMIT|' + r'CONTROL|COPY|CURSOR|D|DECLARE|DEFAULT|DEFINE|DELETE|DENWA|' + r'DISPLAY|DLI|DO|DUPLICATE|E|ELSE|ELSE-IF|END|END-CASE|END-DO|' + r'END-IF|END-PROC|ENDPAGE|ENDTABLE|ENTER|EOF|EQ|ERROR|EXIT|' + r'EXTERNAL|EZLIB|F1|F10|F11|F12|F13|F14|F15|F16|F17|F18|F19|F2|' + r'F20|F21|F22|F23|F24|F25|F26|F27|F28|F29|F3|F30|F31|F32|F33|' + r'F34|F35|F36|F4|F5|F6|F7|F8|F9|FETCH|FILE|FILE-STATUS|FILL|' + r'FINAL|FIRST|FIRST-DUP|FOR|GE|GET|GO|GOTO|GQ|GR|GT|HEADING|' + r'HEX|HIGH-VALUES|IDD|IDMS|IF|IN|INSERT|JOB|JUSTIFY|KANJI-DATE|' + r'KANJI-DATE-LONG|KANJI-TIME|KEY|KEY-PRESSED|KOKUGO|KUN|' + r'LAST-DUP|LE|LEVEL|LIKE|LINE|LINE-COUNT|LINE-NUMBER|LINK|LIST|' + r'LOW-VALUES|LQ|LS|LT|MASK|MATCHED|MEND|MESSAGE|MOVE|MSTART|NE|' + r'NEWPAGE|NOMASK|NOPRINT|NOT|NOTE|NOVERIFY|NQ|NULL|OF|OR|' + r'OTHERWISE|PA1|PA2|PA3|PAGE-COUNT|PAGE-NUMBER|PARM-REGISTER|' + r'PATH-ID|PATTERN|PERFORM|POINT|POS|PRIMARY|PRINT|PROC|' + r'PROCEDURE|PROGRAM|PUT|READ|RECORD|RECORD-COUNT|RECORD-LENGTH|' + r'REFRESH|RELEASE|RENUM|REPEAT|REPORT|REPORT-INPUT|RESHOW|' + r'RESTART|RETRIEVE|RETURN-CODE|ROLLBACK|ROW|S|SCREEN|SEARCH|' + r'SECONDARY|SELECT|SEQUENCE|SIZE|SKIP|SOKAKU|SORT|SQL|STOP|SUM|' + r'SYSDATE|SYSDATE-LONG|SYSIN|SYSIPT|SYSLST|SYSPRINT|SYSSNAP|' + r'SYSTIME|TALLY|TERM-COLUMNS|TERM-NAME|TERM-ROWS|TERMINATION|' + r'TITLE|TO|TRANSFER|TRC|UNIQUE|UNTIL|UPDATE|UPPERCASE|USER|' + r'USERID|VALUE|VERIFY|W|WHEN|WHILE|WORK|WRITE|X|XDM|XRST)[ \'.,():]', Keyword.Reserved), # These are not actually keywords but section separators so # treating them differently from names seems in order. - # TODO: Fix: (r'(param|report)[ \'.,():]', Keyword), + # TODO: Fix: (r'(PARAM|REPORT)[ \'.,():]', Keyword), (r'[\[\](){}<>;,]', Punctuation), (ur'[-+/=&%¬]', Operator), (r'[0-9]+\.[0-9]*', Number.Float), -- cgit v1.2.1 From 93f496e25dc1a60d620a3288e9efe7fb9418dcfc Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sat, 23 Feb 2013 02:17:43 +0100 Subject: Cleaned up punctuation in comments. --- tests/examplefiles/example.ezt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/examplefiles/example.ezt b/tests/examplefiles/example.ezt index 68a849dd..5ea20b99 100644 --- a/tests/examplefiles/example.ezt +++ b/tests/examplefiles/example.ezt @@ -3,14 +3,14 @@ * Environtment section. PARM DEBUG(FLOW FLDCHK) -* Library Section +* Library Section. FILE PERSNL FB(150 1800) NAME 17 8 A EMP# 9 5 N * Note: '#' is a valid character for names. DEPT 98 3 N. GROSS 94 4 P 2 * ^ 2 field definitions in 1 line. -* Activity Section +* Activity Section. JOB INPUT PERSNL NAME FIRST-PROGRAM PRINT PAY-RPT REPORT PAY-RPT LINESIZE 80 -- cgit v1.2.1 From 5cfaf8dfa2fec182f2b2c86f330e97185e8801db Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sat, 23 Feb 2013 02:22:44 +0100 Subject: Fixed Easytrieve lexer. * Fixed keywords following immediately after a new line. * Fixed PARM keyword, which read PARAM. * Fixed keyword tokens so that the delimiter gets an own token instead of being a part of the keyword token. * Changed some keywords from reserved --- pygments/lexers/other.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 0b2a31e6..668e71b3 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3680,13 +3680,18 @@ class EasyTrieveLexer(RegexLexer): aliases = ['easytrieve'] filenames = ['*.ezt'] mimetypes = ['text/x-easytrieve'] + flags = 0 + # TODO: Fix capitalization: Easytrieve instead of EasyTrieve. + # TODO: Add support for MACRO and related calls. # TODO: Treat only the first 72 characters as source code and the rest as comment. # TODO: After some reserved words such as 'define', even keywords are names. # TODO: Consider continuation characters '+' and '-' tokens = { 'root': [ + (r'\*.*\n', Comment.Single), + (r'\n+', Whitespace), # Note: We cannot use r'\b' at the start and end of keywords # because EasyTrieve Plus delimiter characters are: # @@ -3696,6 +3701,8 @@ class EasyTrieveLexer(RegexLexer): # * comma (,) # * paranthesis ( and ) # * colon (:) + (r'(FILE|JOB|PARM|PROC|REPORT)([ \'.,():\n])', + bygroups(Keyword.Declaration, Operator)), (r'(AFTER-BREAK|AFTER-LINE|AFTER-SCREEN|AIM|AND|ATTR|BEFORE|' r'BEFORE-BREAK|BEFORE-LINE|BEFORE-SCREEN|BUSHU|BY|CALL|CASE|' r'CHECKPOINT|CHKP|CHKP-STATUS|CLEAR|CLOSE|COL|COLOR|COMMIT|' @@ -3704,15 +3711,15 @@ class EasyTrieveLexer(RegexLexer): r'END-IF|END-PROC|ENDPAGE|ENDTABLE|ENTER|EOF|EQ|ERROR|EXIT|' r'EXTERNAL|EZLIB|F1|F10|F11|F12|F13|F14|F15|F16|F17|F18|F19|F2|' r'F20|F21|F22|F23|F24|F25|F26|F27|F28|F29|F3|F30|F31|F32|F33|' - r'F34|F35|F36|F4|F5|F6|F7|F8|F9|FETCH|FILE|FILE-STATUS|FILL|' + r'F34|F35|F36|F4|F5|F6|F7|F8|F9|FETCH|FILE-STATUS|FILL|' r'FINAL|FIRST|FIRST-DUP|FOR|GE|GET|GO|GOTO|GQ|GR|GT|HEADING|' - r'HEX|HIGH-VALUES|IDD|IDMS|IF|IN|INSERT|JOB|JUSTIFY|KANJI-DATE|' + r'HEX|HIGH-VALUES|IDD|IDMS|IF|IN|INSERT|JUSTIFY|KANJI-DATE|' r'KANJI-DATE-LONG|KANJI-TIME|KEY|KEY-PRESSED|KOKUGO|KUN|' r'LAST-DUP|LE|LEVEL|LIKE|LINE|LINE-COUNT|LINE-NUMBER|LINK|LIST|' r'LOW-VALUES|LQ|LS|LT|MASK|MATCHED|MEND|MESSAGE|MOVE|MSTART|NE|' r'NEWPAGE|NOMASK|NOPRINT|NOT|NOTE|NOVERIFY|NQ|NULL|OF|OR|' r'OTHERWISE|PA1|PA2|PA3|PAGE-COUNT|PAGE-NUMBER|PARM-REGISTER|' - r'PATH-ID|PATTERN|PERFORM|POINT|POS|PRIMARY|PRINT|PROC|' + r'PATH-ID|PATTERN|PERFORM|POINT|POS|PRIMARY|PRINT|' r'PROCEDURE|PROGRAM|PUT|READ|RECORD|RECORD-COUNT|RECORD-LENGTH|' r'REFRESH|RELEASE|RENUM|REPEAT|REPORT|REPORT-INPUT|RESHOW|' r'RESTART|RETRIEVE|RETURN-CODE|ROLLBACK|ROW|S|SCREEN|SEARCH|' @@ -3720,20 +3727,16 @@ class EasyTrieveLexer(RegexLexer): r'SYSDATE|SYSDATE-LONG|SYSIN|SYSIPT|SYSLST|SYSPRINT|SYSSNAP|' r'SYSTIME|TALLY|TERM-COLUMNS|TERM-NAME|TERM-ROWS|TERMINATION|' r'TITLE|TO|TRANSFER|TRC|UNIQUE|UNTIL|UPDATE|UPPERCASE|USER|' - r'USERID|VALUE|VERIFY|W|WHEN|WHILE|WORK|WRITE|X|XDM|XRST)[ \'.,():]', - Keyword.Reserved), - # These are not actually keywords but section separators so - # treating them differently from names seems in order. - # TODO: Fix: (r'(PARAM|REPORT)[ \'.,():]', Keyword), + r'USERID|VALUE|VERIFY|W|WHEN|WHILE|WORK|WRITE|X|XDM|XRST)([ \'.,():\n])', + bygroups(Keyword.Reserved, Operator)), (r'[\[\](){}<>;,]', Punctuation), (ur'[-+/=&%¬]', Operator), (r'[0-9]+\.[0-9]*', Number.Float), (r'[0-9]+', Number.Integer), (r"'(''|[^'])*'", String), - (r'\*.*\n', Comment.Single), (r'\.', Operator), (r'\s+', Whitespace), - (r'[^ \'.,():]+', Name) # Everything else just belongs to a name + (r'[^ \'.,():\n]+', Name) # Everything else just belongs to a name ] } @@ -3746,7 +3749,7 @@ class EasyTrieveLexer(RegexLexer): hasFile = False hasJob = False hasProc = False - hasParam = False + hasParm = False hasReport = False isBroken = False @@ -3758,9 +3761,9 @@ class EasyTrieveLexer(RegexLexer): if not hasReport: if not hasJob: if not hasFile: - if not hasParam: - if first_word == 'PARAM': - hasParam = True + if not hasParm: + if first_word == 'PARM': + hasParm = True if first_word == 'FILE': hasFile = True if first_word == 'JOB': @@ -3774,9 +3777,9 @@ class EasyTrieveLexer(RegexLexer): # Weight the findings. if not isBroken and hasJob and (hasProc == hasEndProc): - if hasParam: + if hasParm: if hasProc: - # Found PARAM, JOB and PROC/END-PROC: + # Found PARM, JOB and PROC/END-PROC: # pretty sure this is EasyTrieve. result = 0.8 else: @@ -3785,7 +3788,7 @@ class EasyTrieveLexer(RegexLexer): else: # Found JOB and possibly other keywords: might be EasyTrieve result = 0.11 - if hasParam: + if hasParm: # Note: PARAM is not a proper English word, so this is # regarded a much better indicator for EasyTrieve than # the other words. -- cgit v1.2.1 From c26700a25284d7c7e88ecb2bba6a5358a5392d82 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sat, 23 Feb 2013 05:46:46 +0100 Subject: Added Easytrieve macros. --- pygments/lexers/_mapping.py | 2 +- pygments/lexers/other.py | 146 ++++++++++++++++++++++++----------------- tests/examplefiles/example.ezt | 4 ++ tests/examplefiles/example.mac | 6 ++ 4 files changed, 96 insertions(+), 62 deletions(-) create mode 100644 tests/examplefiles/example.mac diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 5c4275d0..f651c8da 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -93,7 +93,7 @@ LEXERS = { 'DylanLidLexer': ('pygments.lexers.compiled', 'DylanLID', ('dylan-lid', 'lid'), ('*.lid', '*.hdp'), ('text/x-dylan-lid',)), 'ECLLexer': ('pygments.lexers.other', 'ECL', ('ecl',), ('*.ecl',), ('application/x-ecl',)), 'ECLexer': ('pygments.lexers.compiled', 'eC', ('ec',), ('*.ec', '*.eh'), ('text/x-echdr', 'text/x-ecsrc')), - 'EasyTrieveLexer': ('pygments.lexers.other', 'EasyTrieve', ('easytrieve',), ('*.ezt',), ('text/x-easytrieve',)), + 'EasyTrieveLexer': ('pygments.lexers.other', 'EasyTrieve', ('easytrieve',), ('*.ezt', '*.mac'), ('text/x-easytrieve',)), 'ElixirConsoleLexer': ('pygments.lexers.functional', 'Elixir iex session', ('iex',), (), ('text/x-elixir-shellsession',)), 'ElixirLexer': ('pygments.lexers.functional', 'Elixir', ('elixir', 'ex', 'exs'), ('*.ex', '*.exs'), ('text/x-elixir',)), 'ErbLexer': ('pygments.lexers.templates', 'ERB', ('erb',), (), ('application/x-ruby-templating',)), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 668e71b3..4428605a 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3671,36 +3671,38 @@ class AutoItLexer(RegexLexer): class EasyTrieveLexer(RegexLexer): """ - EasyTrieve (Classic and Plus) are programming languages tailored to - generating reports and are mainly used in mainframe related environments. + Easytrieve Plus is a programming language for extracting, filtering and + converting sequential data. Furthermore it can layout data for reports. + It is mainly used on mainframe platforms and can access several of the + mainframe's native file formats. It is somewhat comparable to awk. - This lexer is designed for EasyTrieve Plus 6.4. + *New in Pygments 1.x.* """ name = 'EasyTrieve' aliases = ['easytrieve'] - filenames = ['*.ezt'] + filenames = ['*.ezt', '*.mac'] mimetypes = ['text/x-easytrieve'] flags = 0 # TODO: Fix capitalization: Easytrieve instead of EasyTrieve. - # TODO: Add support for MACRO and related calls. - # TODO: Treat only the first 72 characters as source code and the rest as comment. - # TODO: After some reserved words such as 'define', even keywords are names. - # TODO: Consider continuation characters '+' and '-' tokens = { + # Note: We cannot use r'\b' at the start and end of keywords because + # EasyTrieve Plus delimiter characters are: + # + # * space ( ) + # * apostrophe (') + # * period (.) + # * comma (,) + # * paranthesis ( and ) + # * colon (:) 'root': [ (r'\*.*\n', Comment.Single), (r'\n+', Whitespace), - # Note: We cannot use r'\b' at the start and end of keywords - # because EasyTrieve Plus delimiter characters are: - # - # * space ( ) - # * apostrophe (') - # * period (.) - # * comma (,) - # * paranthesis ( and ) - # * colon (:) + # Macro argument + (r'&[^ *\'.,():\n]+\.', Name.Variable, 'after_macro_argument'), + # Macro call + (r'%[^ *\'.,():\n]+', Name.Variable), (r'(FILE|JOB|PARM|PROC|REPORT)([ \'.,():\n])', bygroups(Keyword.Declaration, Operator)), (r'(AFTER-BREAK|AFTER-LINE|AFTER-SCREEN|AIM|AND|ATTR|BEFORE|' @@ -3737,7 +3739,15 @@ class EasyTrieveLexer(RegexLexer): (r'\.', Operator), (r'\s+', Whitespace), (r'[^ \'.,():\n]+', Name) # Everything else just belongs to a name - ] + ], + 'after_macro_argument': [ + (r'\*.*\n', Comment.Single, 'root'), + (r'[\n\s]+', Whitespace, 'root'), + (r'[\[\](){}<>;,]', Punctuation, 'root'), + (ur'[.+/=&%¬]', Operator, 'root'), + (r"'(''|[^'])*'", String, 'root'), + (r'[^ \'.,():\n]+', Name) # Everything else just belongs to a name + ], } def analyse_text(text): @@ -3745,7 +3755,9 @@ class EasyTrieveLexer(RegexLexer): Perform a structural analysis for basic EasyTrieve constructs. """ result = 0.0 + lines = text.split('\n') hasEndProc = False + hasHeaderComment = False hasFile = False hasJob = False hasProc = False @@ -3753,50 +3765,62 @@ class EasyTrieveLexer(RegexLexer): hasReport = False isBroken = False - # Scan the source for lines starting with indicators. - for line in text.split('\n'): - words = line.split() - if (len(words) >= 2): - first_word = words[0] - if not hasReport: - if not hasJob: - if not hasFile: - if not hasParm: - if first_word == 'PARM': - hasParm = True - if first_word == 'FILE': - hasFile = True - if first_word == 'JOB': - hasJob = True - elif first_word == 'PROC': - hasProc = True - elif first_word == 'END-PROC': - hasEndProc = True - elif first_word == 'REPORT': - hasReport = True - - # Weight the findings. - if not isBroken and hasJob and (hasProc == hasEndProc): - if hasParm: - if hasProc: - # Found PARM, JOB and PROC/END-PROC: - # pretty sure this is EasyTrieve. - result = 0.8 - else: - # Found PARAM and JOB: probably this is EasyTrieve - result = 0.5 - else: - # Found JOB and possibly other keywords: might be EasyTrieve - result = 0.11 + # Skip possible header comments. + while len(lines) and lines[0].startswith('*'): + hasHeaderComment = True + del lines[0] + + firstLine = lines[0] + if firstLine[:6] in ('MACRO', 'MACRO '): + # Looks like an Easytrieve macro. + result = 0.4 + if hasHeaderComment: + result += 0.4 + else: + # Scan the source for lines starting with indicators. + for line in lines: + words = line.split() + if (len(words) >= 2): + first_word = words[0] + if not hasReport: + if not hasJob: + if not hasFile: + if not hasParm: + if first_word == 'PARM': + hasParm = True + if first_word == 'FILE': + hasFile = True + if first_word == 'JOB': + hasJob = True + elif first_word == 'PROC': + hasProc = True + elif first_word == 'END-PROC': + hasEndProc = True + elif first_word == 'REPORT': + hasReport = True + + # Weight the findings. + if not isBroken and hasJob and (hasProc == hasEndProc): if hasParm: - # Note: PARAM is not a proper English word, so this is - # regarded a much better indicator for EasyTrieve than - # the other words. - result += 0.2 - if hasFile: - result += 0.01 - if hasReport: - result += 0.01 + if hasProc: + # Found PARM, JOB and PROC/END-PROC: + # pretty sure this is EasyTrieve. + result = 0.8 + else: + # Found PARAM and JOB: probably this is EasyTrieve + result = 0.5 + else: + # Found JOB and possibly other keywords: might be EasyTrieve + result = 0.11 + if hasParm: + # Note: PARAM is not a proper English word, so this is + # regarded a much better indicator for EasyTrieve than + # the other words. + result += 0.2 + if hasFile: + result += 0.01 + if hasReport: + result += 0.01 assert 0.0 <= result <= 1.0 return result diff --git a/tests/examplefiles/example.ezt b/tests/examplefiles/example.ezt index 5ea20b99..5e4dc1ef 100644 --- a/tests/examplefiles/example.ezt +++ b/tests/examplefiles/example.ezt @@ -10,6 +10,10 @@ FILE PERSNL FB(150 1800) DEPT 98 3 N. GROSS 94 4 P 2 * ^ 2 field definitions in 1 line. +FILE EXAMPLE FB(80 200) +%EXAMPLE SOMEFILE SOME + +* Macro declaration (to be valid, this would * Activity Section. JOB INPUT PERSNL NAME FIRST-PROGRAM PRINT PAY-RPT diff --git a/tests/examplefiles/example.mac b/tests/examplefiles/example.mac new file mode 100644 index 00000000..1c3831d1 --- /dev/null +++ b/tests/examplefiles/example.mac @@ -0,0 +1,6 @@ +* Example Easytrieve macro declaration. For an example on calling this +* macro, see example.ezt. +MACRO FILENAME PREFIX +&FILENAME. +&PREFIX.-LINE 1 80 A +&PREFIX.-KEY 1 8 A -- cgit v1.2.1 From 6f26840e0644b004c7d067ae7581a1cca0c62abc Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sat, 23 Feb 2013 07:06:01 +0100 Subject: Cleaned up naming of Easytrieve (instead of EasyTrieve) --- pygments/lexers/_mapping.py | 2 +- pygments/lexers/other.py | 20 +++++++++----------- tests/test_lexers_other.py | 6 +++--- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index f651c8da..47530fee 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -93,7 +93,7 @@ LEXERS = { 'DylanLidLexer': ('pygments.lexers.compiled', 'DylanLID', ('dylan-lid', 'lid'), ('*.lid', '*.hdp'), ('text/x-dylan-lid',)), 'ECLLexer': ('pygments.lexers.other', 'ECL', ('ecl',), ('*.ecl',), ('application/x-ecl',)), 'ECLexer': ('pygments.lexers.compiled', 'eC', ('ec',), ('*.ec', '*.eh'), ('text/x-echdr', 'text/x-ecsrc')), - 'EasyTrieveLexer': ('pygments.lexers.other', 'EasyTrieve', ('easytrieve',), ('*.ezt', '*.mac'), ('text/x-easytrieve',)), + 'EasytrieveLexer': ('pygments.lexers.other', 'Easytrieve', ('easytrieve',), ('*.ezt', '*.mac'), ('text/x-easytrieve',)), 'ElixirConsoleLexer': ('pygments.lexers.functional', 'Elixir iex session', ('iex',), (), ('text/x-elixir-shellsession',)), 'ElixirLexer': ('pygments.lexers.functional', 'Elixir', ('elixir', 'ex', 'exs'), ('*.ex', '*.exs'), ('text/x-elixir',)), 'ErbLexer': ('pygments.lexers.templates', 'ERB', ('erb',), (), ('application/x-ruby-templating',)), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 4428605a..cee39a08 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -36,7 +36,7 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer', 'ECLLexer', 'UrbiscriptLexer', 'OpenEdgeLexer', 'BroLexer', 'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer', 'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer', - 'CbmBasicV2Lexer', 'AutoItLexer', 'EasyTrieveLexer', 'JclLexer', + 'CbmBasicV2Lexer', 'AutoItLexer', 'EasytrieveLexer', 'JclLexer', 'WebFocusLexer'] @@ -3669,7 +3669,7 @@ class AutoItLexer(RegexLexer): } -class EasyTrieveLexer(RegexLexer): +class EasytrieveLexer(RegexLexer): """ Easytrieve Plus is a programming language for extracting, filtering and converting sequential data. Furthermore it can layout data for reports. @@ -3678,17 +3678,15 @@ class EasyTrieveLexer(RegexLexer): *New in Pygments 1.x.* """ - name = 'EasyTrieve' + name = 'Easytrieve' aliases = ['easytrieve'] filenames = ['*.ezt', '*.mac'] mimetypes = ['text/x-easytrieve'] flags = 0 - # TODO: Fix capitalization: Easytrieve instead of EasyTrieve. - tokens = { # Note: We cannot use r'\b' at the start and end of keywords because - # EasyTrieve Plus delimiter characters are: + # Easytrieve Plus delimiter characters are: # # * space ( ) # * apostrophe (') @@ -3752,7 +3750,7 @@ class EasyTrieveLexer(RegexLexer): def analyse_text(text): """ - Perform a structural analysis for basic EasyTrieve constructs. + Perform a structural analysis for basic Easytrieve constructs. """ result = 0.0 lines = text.split('\n') @@ -3804,17 +3802,17 @@ class EasyTrieveLexer(RegexLexer): if hasParm: if hasProc: # Found PARM, JOB and PROC/END-PROC: - # pretty sure this is EasyTrieve. + # pretty sure this is Easytrieve. result = 0.8 else: - # Found PARAM and JOB: probably this is EasyTrieve + # Found PARAM and JOB: probably this is Easytrieve result = 0.5 else: - # Found JOB and possibly other keywords: might be EasyTrieve + # Found JOB and possibly other keywords: might be Easytrieve result = 0.11 if hasParm: # Note: PARAM is not a proper English word, so this is - # regarded a much better indicator for EasyTrieve than + # regarded a much better indicator for Easytrieve than # the other words. result += 0.2 if hasFile: diff --git a/tests/test_lexers_other.py b/tests/test_lexers_other.py index 3c64fd43..2cdb8e5f 100644 --- a/tests/test_lexers_other.py +++ b/tests/test_lexers_other.py @@ -11,7 +11,7 @@ import os import unittest from pygments.lexers import guess_lexer -from pygments.lexers.other import EasyTrieveLexer, JclLexer, WebFocusLexer +from pygments.lexers.other import EasytrieveLexer, JclLexer, WebFocusLexer def _exampleFilePath(filename): @@ -38,9 +38,9 @@ class _AnalyseTextTest(unittest.TestCase): exampleFile.close() -class EasyTrieveLexerTest(_AnalyseTextTest): +class EasytrieveLexerTest(_AnalyseTextTest): def setUp(self): - self.lexer = EasyTrieveLexer() + self.lexer = EasytrieveLexer() class JclLexerTest(_AnalyseTextTest): -- cgit v1.2.1 From 5877fc13f6af82b1ef1dd85c3afc9bf4243b5bfb Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sat, 23 Feb 2013 13:02:31 +0100 Subject: Cleaned up naming of Easytrieve (instead of EasyTrieve). --- tests/examplefiles/example.ezt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/examplefiles/example.ezt b/tests/examplefiles/example.ezt index 5e4dc1ef..b068fca3 100644 --- a/tests/examplefiles/example.ezt +++ b/tests/examplefiles/example.ezt @@ -1,4 +1,4 @@ -* EasyTrieve Plus Test Programm. +* Easytrieve Plus Test Programm. * Environtment section. PARM DEBUG(FLOW FLDCHK) -- cgit v1.2.1 From bb8536fc6083d0d8a288532472e13a03a2bc74c5 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sun, 24 Feb 2013 05:58:24 +0100 Subject: Added lexer for Rexx. --- pygments/lexers/_mapping.py | 1 + pygments/lexers/other.py | 69 ++++++++++++++++++++++++++++++++++++++++- tests/examplefiles/example.rexx | 31 ++++++++++++++++++ tests/test_lexers_other.py | 6 +++- 4 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 tests/examplefiles/example.rexx diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 47530fee..22a8b935 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -245,6 +245,7 @@ LEXERS = { 'RebolLexer': ('pygments.lexers.other', 'REBOL', ('rebol',), ('*.r', '*.r3'), ('text/x-rebol',)), 'RedcodeLexer': ('pygments.lexers.other', 'Redcode', ('redcode',), ('*.cw',), ()), 'RegeditLexer': ('pygments.lexers.text', 'reg', ('registry',), ('*.reg',), ('text/x-windows-registry',)), + 'RexxLexer': ('pygments.lexers.other', 'REXX', ('rexx', 'ARexx', 'arexx'), ('*.rexx', '*.rex', '*.rx', '*.arexx'), ('text/x-rexx',)), 'RhtmlLexer': ('pygments.lexers.templates', 'RHTML', ('rhtml', 'html+erb', 'html+ruby'), ('*.rhtml',), ('text/html+ruby',)), 'RobotFrameworkLexer': ('pygments.lexers.other', 'RobotFramework', ('RobotFramework', 'robotframework'), ('*.txt', '*.robot'), ('text/x-robotframework',)), 'RstLexer': ('pygments.lexers.text', 'reStructuredText', ('rst', 'rest', 'restructuredtext'), ('*.rst', '*.rest'), ('text/x-rst', 'text/prs.fallenstein.rst')), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index cee39a08..744f2337 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -37,7 +37,7 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer', 'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer', 'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer', 'CbmBasicV2Lexer', 'AutoItLexer', 'EasytrieveLexer', 'JclLexer', - 'WebFocusLexer'] + 'RexxLexer', 'WebFocusLexer'] class ECLLexer(RegexLexer): @@ -4081,3 +4081,70 @@ class WebFocusLexer(RegexLexer): result += 0.1 assert 0.0 <= result <= 1.0 return result + + +class RexxLexer(RegexLexer): + """ + `REXX `_ is a scripting language available for + a wide range of different platforms with its roots found on mainframe + systems. It is popular for I/O- and data based tasks and can act as glue + language to bind different applications together. + """ + name = 'REXX' + aliases = ['rexx', 'ARexx', 'arexx'] + filenames = ['*.rexx', '*.rex', '*.rx', '*.arexx'] + mimetypes = ['text/x-rexx'] + flags = re.IGNORECASE + + tokens = { + 'root': [ + (r'[\s\n]', Whitespace), + (r'/\*', Comment.Multiline, 'comment'), + (r'["]', String, 'string_double'), + (r"'", String, 'string_single'), + (r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number), + (r'([a-z_][a-z0-9_]*)(\s*)(:)(\s*)(procedure)', + bygroups(Name.Function, Whitespace, Operator, Whitespace, Keyword.Declaration)), + (r'([a-z_][a-z0-9_]*)(\s*)(:)', + bygroups(Name.Label, Whitespace, Operator)), + include('keyword'), + include('operator'), + (r'[a-z_][a-z0-9_]*', Text), + ], + 'keyword': [ + (r'(address|arg|by|call|do|drop|else|end|exit|for|forever|if|' + r'interpret|iterate|leave|nop|numeric|off|on|options|parse|' + r'pull|push|queue|return|say|select|signal|to|then|trace|until|' + r'while)', Keyword.Reserved), + ], + 'operator': [ + (ur'(-|//|/|\(|\)|\*\*|\*|\\|\\<<|\\<|\\==|\\=|\\>>|\\>|\|\||\||' + ur'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|' + ur'¬>>|¬>|¬|\.)', Operator), + ], + 'string_double': [ + (r'""', String), + (r'"', String, 'root'), + (r'\n', Error, 'root'), + (r'[^"]', String), + ], + 'string_single': [ + (r'\'\'', String), + (r'\'', String, 'root'), + (r'\n', Error, 'root'), + (r'[^\']', String), + ], + 'comment': [ + (r'[^*/]', Comment.Multiline), + (r'\*/', Comment.Multiline, 'root'), + ] + } + + def analyse_text(text): + """ + Check for inital comment. + """ + result = 0.0 + if re.search(r'/\*\**\s*rexx', text, re.IGNORECASE): + result = 1.0 + return result diff --git a/tests/examplefiles/example.rexx b/tests/examplefiles/example.rexx new file mode 100644 index 00000000..dbe260d1 --- /dev/null +++ b/tests/examplefiles/example.rexx @@ -0,0 +1,31 @@ +/* REXX example. */ + +/* Some basic constructs. */ +almost_pi = 0.1415 + 3 +if almost_pi < 3 then + say 'huh?' +else do + say 'ok, almost_pi=' almost_pi || " - done" +end +x = '"' || "'" || '''' || """" /* quotes */ + +/* A comment + spawning multiple + lines. */ + +half: procedure + parse arg some + return some / 2 + +some_label: /* ... ready to go to. */ + +/* Print a text file on MVS. */ +ADDRESS TSO +"ALLOC F(TEXTFILE) DSN('some.text.dsn') SHR REU" +"EXECIO * DISKR TEXTFILE ( FINIS STEM LINES." +"FREE F(TEXTFILE)" +I = 1 +DO WHILE I <= LINES.0 + SAY ' LINE ' I ' : ' LINES.I + I = I + 1 +END diff --git a/tests/test_lexers_other.py b/tests/test_lexers_other.py index 2cdb8e5f..b04a9d0d 100644 --- a/tests/test_lexers_other.py +++ b/tests/test_lexers_other.py @@ -11,7 +11,8 @@ import os import unittest from pygments.lexers import guess_lexer -from pygments.lexers.other import EasytrieveLexer, JclLexer, WebFocusLexer +from pygments.lexers.other import EasytrieveLexer, JclLexer, RexxLexer, \ + WebFocusLexer def _exampleFilePath(filename): @@ -47,6 +48,9 @@ class JclLexerTest(_AnalyseTextTest): def setUp(self): self.lexer = JclLexer() +class RexxLexerTest(_AnalyseTextTest): + def setUp(self): + self.lexer = RexxLexer() class WebFocusLexerTest(_AnalyseTextTest): def setUp(self): -- cgit v1.2.1 From b636e1c671056d9e1aa4201322f5f9b337cdcfb1 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sun, 24 Feb 2013 14:59:41 +0100 Subject: Fixed Rexx lexer. * Fixed comma (,) as operator. * Fixed slash (/) and asterisk (*) in comments. --- pygments/lexers/other.py | 6 +++--- tests/examplefiles/example.rexx | 17 ++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 744f2337..08a9bcd8 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -4115,12 +4115,12 @@ class RexxLexer(RegexLexer): (r'(address|arg|by|call|do|drop|else|end|exit|for|forever|if|' r'interpret|iterate|leave|nop|numeric|off|on|options|parse|' r'pull|push|queue|return|say|select|signal|to|then|trace|until|' - r'while)', Keyword.Reserved), + r'while)\b', Keyword.Reserved), ], 'operator': [ (ur'(-|//|/|\(|\)|\*\*|\*|\\|\\<<|\\<|\\==|\\=|\\>>|\\>|\|\||\||' ur'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|' - ur'¬>>|¬>|¬|\.)', Operator), + ur'¬>>|¬>|¬|\.|,)', Operator), ], 'string_double': [ (r'""', String), @@ -4135,8 +4135,8 @@ class RexxLexer(RegexLexer): (r'[^\']', String), ], 'comment': [ - (r'[^*/]', Comment.Multiline), (r'\*/', Comment.Multiline, 'root'), + (r'(.|\n)', Comment.Multiline), ] } diff --git a/tests/examplefiles/example.rexx b/tests/examplefiles/example.rexx index dbe260d1..648f595b 100644 --- a/tests/examplefiles/example.rexx +++ b/tests/examplefiles/example.rexx @@ -5,19 +5,22 @@ almost_pi = 0.1415 + 3 if almost_pi < 3 then say 'huh?' else do - say 'ok, almost_pi=' almost_pi || " - done" + say 'almost_pi=' almost_pi || " - ok" end x = '"' || "'" || '''' || """" /* quotes */ /* A comment - spawning multiple - lines. */ + * spawning multiple + lines. /* / */ -half: procedure - parse arg some - return some / 2 +/* Labels and procedures. */ +some_label : -some_label: /* ... ready to go to. */ +divide: procedure + parse arg some other + return some / other + +call divide(5, 2) /* Print a text file on MVS. */ ADDRESS TSO -- cgit v1.2.1 From fa0364e432b55d6ef783950b48f05057d87d43e5 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Mon, 25 Feb 2013 02:33:01 +0100 Subject: Improved heuristic for guessing Rexx from text. If the text starts with "/*" but without the "Rexx" tag as first word in the comment, the lexer now analyzes the whole text for common Rexx constructs. --- pygments/lexers/other.py | 66 +++++++++++++++++++++++++++++++++++++++++++--- tests/test_lexers_other.py | 29 +++++++++++++++++++- 2 files changed, 90 insertions(+), 5 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 08a9bcd8..55dcf66c 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3626,7 +3626,7 @@ class AutoItLexer(RegexLexer): (r'[a-zA-Z_#@$][a-zA-Z0-9_#@$]*', Name), (r'\\|\'', Text), (r'\`([\,\%\`abfnrtv\-\+;])', String.Escape), - (r'_\n', Text), # Line continuation + (r'_\n', Text), # Line continuation include('garbage'), ], 'commands': [ @@ -3674,7 +3674,7 @@ class EasytrieveLexer(RegexLexer): Easytrieve Plus is a programming language for extracting, filtering and converting sequential data. Furthermore it can layout data for reports. It is mainly used on mainframe platforms and can access several of the - mainframe's native file formats. It is somewhat comparable to awk. + mainframe's native file formats. It is somewhat comparable to awk. *New in Pygments 1.x.* """ @@ -3796,7 +3796,7 @@ class EasytrieveLexer(RegexLexer): hasEndProc = True elif first_word == 'REPORT': hasReport = True - + # Weight the findings. if not isBroken and hasJob and (hasProc == hasEndProc): if hasParm: @@ -4103,7 +4103,7 @@ class RexxLexer(RegexLexer): (r'["]', String, 'string_double'), (r"'", String, 'string_single'), (r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number), - (r'([a-z_][a-z0-9_]*)(\s*)(:)(\s*)(procedure)', + (r'([a-z_][a-z0-9_]*)(\s*)(:)(\s*)(procedure)\b', bygroups(Name.Function, Whitespace, Operator, Whitespace, Keyword.Declaration)), (r'([a-z_][a-z0-9_]*)(\s*)(:)', bygroups(Name.Label, Whitespace, Operator)), @@ -4140,11 +4140,69 @@ class RexxLexer(RegexLexer): ] } + _ADDRESS_COMMAND_REGEX = re.compile(r'\s*address\s+command\b', re.IGNORECASE) + _ADDRESS_REGEX = re.compile(r'\s*address\s+', re.IGNORECASE) + _DO_WHILE_REGEX = re.compile(r'\s*do\s+while\b', re.IGNORECASE) + _IF_THEN_DO_REGEX = re.compile(r'\s*if\b.+\bthen\s+do\s*$', re.IGNORECASE) + _PROCEDURE_REGEX = re.compile(r'([a-z_][a-z0-9_]*)(\s*)(:)(\s*)(procedure)\b', re.IGNORECASE) + _ELSE_DO_REGEX = re.compile(r'\s*else\s+do\s*$', re.IGNORECASE) + _PARSE_ARG_REGEX = re.compile(r'\s*parse\s+(upper\s+)?(arg|value)\b', re.IGNORECASE) + _REGEXS = [ + _ADDRESS_COMMAND_REGEX, + _ADDRESS_REGEX, + _DO_WHILE_REGEX, + _ELSE_DO_REGEX, + _IF_THEN_DO_REGEX, + _PROCEDURE_REGEX, + _PARSE_ARG_REGEX, + ] + def analyse_text(text): """ Check for inital comment. """ result = 0.0 if re.search(r'/\*\**\s*rexx', text, re.IGNORECASE): + # Header matches MVS Rexx requirements, this is certainly a Rexx + # script. result = 1.0 + elif text.startswith('/*'): + # Header matches general Rexx requirements; the source code might + # still be any language using C comments such as C++, C# or Java. + result = 0.01 + + # Check if lines match certain regular expressions and + # collect the respective counts in a dictionary. + regexCount = len(RexxLexer._REGEXS) + regexToCountMap = {} + for regex in RexxLexer._REGEXS: + regexToCountMap[regex] = 0 + for line in (text.split('\n'))[1:]: + regexIndex = 0 + lineHasAnyRegex = False + while not lineHasAnyRegex and (regexIndex < regexCount): + regexToCheck = RexxLexer._REGEXS[regexIndex] + if regexToCheck.match(line) is not None: + regexToCountMap[regexToCheck] = \ + regexToCountMap[regexToCheck] + 1 + lineHasAnyRegex = True + else: + regexIndex += 1 + # Evaluate the findings. + if regexToCountMap[RexxLexer._PROCEDURE_REGEX] > 0: + result += 0.5 + elif regexToCountMap[RexxLexer._ADDRESS_COMMAND_REGEX] > 0: + result += 0.2 + elif regexToCountMap[RexxLexer._ADDRESS_REGEX] > 0: + result += 0.05 + if regexToCountMap[RexxLexer._DO_WHILE_REGEX] > 0: + result += 0.1 + if regexToCountMap[RexxLexer._ELSE_DO_REGEX] > 0: + result += 0.1 + if regexToCountMap[RexxLexer._PARSE_ARG_REGEX] > 0: + result += 0.2 + if regexToCountMap[RexxLexer._IF_THEN_DO_REGEX] > 0: + result += 0.1 + result = min(result, 1.0) + assert 0.0 <= result <= result return result diff --git a/tests/test_lexers_other.py b/tests/test_lexers_other.py index b04a9d0d..feb62a1b 100644 --- a/tests/test_lexers_other.py +++ b/tests/test_lexers_other.py @@ -32,7 +32,8 @@ class _AnalyseTextTest(unittest.TestCase): text = exampleFile.read() probability = self.lexer.analyse_text(text) self.assertTrue(probability > 0, - '%s must recognize %r' % (self.lexer.name, exampleFilePath)) + '%s must recognize %r' % ( + self.lexer.name, exampleFilePath)) guessedLexer = guess_lexer(text) self.assertEqual(guessedLexer.name, self.lexer.name) finally: @@ -48,10 +49,36 @@ class JclLexerTest(_AnalyseTextTest): def setUp(self): self.lexer = JclLexer() + class RexxLexerTest(_AnalyseTextTest): def setUp(self): self.lexer = RexxLexer() + def testCanGuessFromText(self): + self.assertAlmostEqual(0.01, + self.lexer.analyse_text('/* */')) + self.assertAlmostEqual(1.0, + self.lexer.analyse_text('''/* Rexx */ + say "hello world"''')) + self.assertLess(0.5, + self.lexer.analyse_text('/* */\n' \ + + 'hello:pRoceduRe\n' \ + + ' say "hello world"')) + self.assertLess(0.2, + self.lexer.analyse_text('''/* */ + if 1 > 0 then do + say "ok" + end + else do + say "huh?" + end''')) + self.assertLess(0.2, + self.lexer.analyse_text('''/* */ + greeting = "hello world!" + parse value greeting "hello" name "!" + say name''')) + + class WebFocusLexerTest(_AnalyseTextTest): def setUp(self): self.lexer = WebFocusLexer() -- cgit v1.2.1 From 6afe2b06558c18fb886042720fefb172e21474ad Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Mon, 25 Feb 2013 02:49:29 +0100 Subject: Improved description of mainframe related languages. --- pygments/lexers/other.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 55dcf66c..e4b7cd41 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3825,12 +3825,12 @@ class EasytrieveLexer(RegexLexer): class JclLexer(RegexLexer): """ - Job Control Language (JCL) is a scripting language used on IBM mainframe - operating systems to instruct the system on how to run a batch job or - start a subsystem. + `Job Control Language (JCL) `_ + is a scripting language used on mainframe platforms to instruct the system + on how to run a batch job or start a subsystem. It is somewhat + comparable to MS DOS batch and Unix shell scripts. - For more information, refer to the - `MVS Job Control Language Reference `_ + *New in Pygments 1.x.* """ name = 'JCL' aliases = ['jcl'] @@ -3907,11 +3907,12 @@ class JclLexer(RegexLexer): class WebFocusLexer(RegexLexer): """ - WebFOCUS und FOCUS are business intelligence tools mainly used in - mainframe related environments. + `(Web)FOCUS `_ is + a language for business intelligence applications. It enables to + describe, query and modify data from various sources including mainframe + platforms. It also includes FIDEL, a language to describe input forms. - For more information, refer to the - `Information Builders product page `_. + *New in Pygments 1.x.* """ name = 'WebFOCUS' aliases = ['webfocus', 'FOCUS', 'focus'] @@ -4085,10 +4086,12 @@ class WebFocusLexer(RegexLexer): class RexxLexer(RegexLexer): """ - `REXX `_ is a scripting language available for + `Rexx `_ is a scripting language available for a wide range of different platforms with its roots found on mainframe systems. It is popular for I/O- and data based tasks and can act as glue language to bind different applications together. + + *New in Pygments 1.x.* """ name = 'REXX' aliases = ['rexx', 'ARexx', 'arexx'] -- cgit v1.2.1 From 232c28383763473a44e2c5c2bbe139845efd5def Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Tue, 19 Mar 2013 23:47:06 +0100 Subject: #1: Add lexer for FOCUS master and access files. --- pygments/lexers/_mapping.py | 2 + pygments/lexers/other.py | 95 +++++++++++++++++++++++++++++++++++++++++- tests/examplefiles/example.acx | 3 ++ tests/examplefiles/example.mas | 21 ++++++++++ 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 tests/examplefiles/example.acx create mode 100644 tests/examplefiles/example.mas diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 22a8b935..13a8b696 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -107,6 +107,8 @@ LEXERS = { 'FancyLexer': ('pygments.lexers.agile', 'Fancy', ('fancy', 'fy'), ('*.fy', '*.fancypack'), ('text/x-fancysrc',)), 'FantomLexer': ('pygments.lexers.compiled', 'Fantom', ('fan',), ('*.fan',), ('application/x-fantom',)), 'FelixLexer': ('pygments.lexers.compiled', 'Felix', ('felix', 'flx'), ('*.flx', '*.flxh'), ('text/x-felix',)), + 'FocusAccessLexer': ('pygments.lexers.other', 'FOCUS access', (), ('*.acx',), ('text/x-focus-access',)), + 'FocusMasterLexer': ('pygments.lexers.other', 'FOCUS master', ('master',), ('*.mas',), ('text/x-focus-master',)), 'FortranLexer': ('pygments.lexers.compiled', 'Fortran', ('fortran',), ('*.f', '*.f90', '*.F', '*.F90'), ('text/x-fortran',)), 'FoxProLexer': ('pygments.lexers.foxpro', 'FoxPro', ('Clipper', 'XBase'), ('*.PRG', '*.prg'), ()), 'GLShaderLexer': ('pygments.lexers.compiled', 'GLSL', ('glsl',), ('*.vert', '*.frag', '*.geo'), ('text/x-glslsrc',)), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index e4b7cd41..b1cadc87 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -37,7 +37,8 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer', 'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer', 'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer', 'CbmBasicV2Lexer', 'AutoItLexer', 'EasytrieveLexer', 'JclLexer', - 'RexxLexer', 'WebFocusLexer'] + 'RexxLexer', 'WebFocusLexer', 'FocusAccessLexer', + 'FocusMasterLexer'] class ECLLexer(RegexLexer): @@ -4084,6 +4085,98 @@ class WebFocusLexer(RegexLexer): return result +class FocusMasterLexer(RegexLexer): + """ + FOCUS master files describes files and tables to be queried by FOCUS + programs. The are somewhat comparable to SQL ``create table`` statements. + + *New in Pygments 1.x.* + """ + name = 'FOCUS master' + aliases = ['master'] + filenames = ['*.mas'] + mimetypes = ['text/x-focus-master'] + flags = re.IGNORECASE + + tokens = { + 'root': [ + (r'\$.*\n', Comment.Single), + (r'\s+', Whitespace), + (r'[a-z_][a-z0-9_]*', Name), + (r'=', Punctuation, 'value'), + (r'\.', Punctuation), + ], + 'value': [ + (r'\$.*\n', Comment.Single, 'root'), + (r'\n', Text), + (r',', Punctuation, 'root'), + (r'\.!', Punctuation), + (r'["]', String, 'string_double'), + (r'\'', String, 'string_single'), + (r'[a-z_][a-z0-9_]*', Text), + (r'[0-9]+(\.[0-9]+)?', Number), + (r'.', Text), + ], + 'string_double': [ + (r'\'["]["]', String), + (r'["]', String, 'value'), + (r'[^"]', String), + ], + 'string_single': [ + (r'\'\'', String), + (r'\'', String, 'value'), + (r'[^\']', String), + ], + } + + _HEADER_PATTERN = re.compile( + r'^((\s*\$.*)\n)*file(name)?\s*=\s*[a-z_][a-z0-9_]+\s*,(\s*(\$.*)\n)*\s*suffix\s*=\s*.+', + re.IGNORECASE + ) + + def analyse_text(text): + """ + Check for ``FILE=..., SUFFIX=...`` while ignoring comments starting with ``$``. + """ + result = 0.0 + + if FocusMasterLexer._HEADER_PATTERN.match(text): + result = 0.8 + + assert 0.0 <= result <= 1.0 + return result + + +class FocusAccessLexer(FocusMasterLexer): + """ + FOCUS access files associate segments in FOCUS master files with actual + tables containing data. + + *New in Pygments 1.x.* + """ + name = 'FOCUS access' + aliases = [] + filenames = ['*.acx'] + mimetypes = ['text/x-focus-access'] + + _HEADER_PATTERN = re.compile( + r'^((\s*\$.*)\n)*segment\s*=\s*[a-z_][a-z0-9_]+\s*,(\s*(\$.*)\n)*\s*tablename\s*=\s*.+', + re.IGNORECASE + ) + + def analyse_text(text): + """ + Check for ``SEGMENT=..., TABLENAME=...`` while ignoring comments starting with ``$``. + """ + result = 0.0 + + if FocusAccessLexer._HEADER_PATTERN.match(text): + result = 0.8 + + assert 0.0 <= result <= 1.0 + return result + + class RexxLexer(RegexLexer): """ `Rexx `_ is a scripting language available for diff --git a/tests/examplefiles/example.acx b/tests/examplefiles/example.acx new file mode 100644 index 00000000..ec80b9a2 --- /dev/null +++ b/tests/examplefiles/example.acx @@ -0,0 +1,3 @@ +$ Example FOCUS access file. +SEGNAME=CUSTOMERS, TABLENAME = "SOME"."CUSTOMERS", KEYS =1, + WRITE= NO, DBSPACE = SOME.WHERE0,$ diff --git a/tests/examplefiles/example.mas b/tests/examplefiles/example.mas new file mode 100644 index 00000000..fe653f07 --- /dev/null +++ b/tests/examplefiles/example.mas @@ -0,0 +1,21 @@ +$ Example FOCUS master file. +FILE=CENTGL, SUFFIX=FOC +SEGNAME=ACCOUNTS,SEGTYPE = S01 +FIELDNAME=GL_ACCOUNT, ALIAS=GLACCT, FORMAT=A7, + TITLE='Ledger,Account', FIELDTYPE=I, $ +FIELDNAME=GL_ACCOUNT_PARENT, ALIAS=GLPAR, FORMAT=A7, + TITLE=Parent, + PROPERTY=PARENT_OF, REFERENCE=GL_ACCOUNT, $ +FIELDNAME=GL_ACCOUNT_TYPE, ALIAS=GLTYPE, FORMAT=A1, + TITLE=Type,$ + +FIELDNAME=GL_ROLLUP_OP, ALIAS=GLROLL, FORMAT=A1, + TITLE=Op, $ Some comment. +FIELDNAME=GL_ACCOUNT_LEVEL, ALIAS=GLLEVEL, FORMAT=I3, + TITLE=Lev, $ + $ Another comment. +FIELDNAME=GL_ACCOUNT_CAPTION, ALIAS=GLCAP, FORMAT=A30, + TITLE=Caption, + PROPERTY=CAPTION, REFERENCE=GL_ACCOUNT, $ +FIELDNAME=SYS_ACCOUNT, ALIAS=ALINE, FORMAT=A6, + TITLE='System,Account,Line', MISSING=ON, $ -- cgit v1.2.1 From 7d2221b1aba7faa131b6ac660696fe543d388ca3 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sat, 30 Mar 2013 14:15:43 +0100 Subject: #6: Add highlightning of Rexx built in functions. --- pygments/lexers/other.py | 12 ++++++++++++ tests/examplefiles/example.rexx | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index b1cadc87..a4cd2f95 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -4203,10 +4203,22 @@ class RexxLexer(RegexLexer): bygroups(Name.Function, Whitespace, Operator, Whitespace, Keyword.Declaration)), (r'([a-z_][a-z0-9_]*)(\s*)(:)', bygroups(Name.Label, Whitespace, Operator)), + include('function'), include('keyword'), include('operator'), (r'[a-z_][a-z0-9_]*', Text), ], + 'function': [ + (r'(abbrev|abs|address|arg|b2x|bitand|bitor|bitxor|c2d|c2x|' + r'center|charin|charout|chars|compare|condition|copies|d2c|' + r'd2x|datatype|date|delstr|delword|digits|errortext|form|' + r'format|fuzz|insert|lastpos|left|length|linein|lineout|lines|' + r'max|min|overlay|pos|queued|random|reverse|right|sign|' + r'sourceline|space|stream|strip|substr|subword|symbol|time|' + r'trace|translate|trunc|value|verify|word|wordindex|' + r'wordlength|wordpos|words|x2b|x2c|x2d|xrange)(\s*)([(])', + bygroups(Name.Builtin, Whitespace, Operator)), + ], 'keyword': [ (r'(address|arg|by|call|do|drop|else|end|exit|for|forever|if|' r'interpret|iterate|leave|nop|numeric|off|on|options|parse|' diff --git a/tests/examplefiles/example.rexx b/tests/examplefiles/example.rexx index 648f595b..07b7bacf 100644 --- a/tests/examplefiles/example.rexx +++ b/tests/examplefiles/example.rexx @@ -13,6 +13,11 @@ x = '"' || "'" || '''' || """" /* quotes */ * spawning multiple lines. /* / */ +/* Built-in functions. */ +line = 'line containing some short text' +say WordPos(line, 'some') +say Word(line, 4) + /* Labels and procedures. */ some_label : -- cgit v1.2.1 From 19b60945c582853056da25946a090fd049f43fd1 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sat, 30 Mar 2013 17:09:09 +0100 Subject: * #7: Add lexer for WebFOCUS style sheets. * Added aliases for FOCUS access and master files. * Added support for FOCUS comments (starting with -*) in access and master files. * Changed names in FOCUS access and master files to be highlighted as built-in names. * Changed lexers for FOCUS access and master files to be more picky about NAME=VALUE syntax. --- pygments/lexers/_mapping.py | 5 ++-- pygments/lexers/other.py | 65 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 13a8b696..7498404c 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -107,8 +107,9 @@ LEXERS = { 'FancyLexer': ('pygments.lexers.agile', 'Fancy', ('fancy', 'fy'), ('*.fy', '*.fancypack'), ('text/x-fancysrc',)), 'FantomLexer': ('pygments.lexers.compiled', 'Fantom', ('fan',), ('*.fan',), ('application/x-fantom',)), 'FelixLexer': ('pygments.lexers.compiled', 'Felix', ('felix', 'flx'), ('*.flx', '*.flxh'), ('text/x-felix',)), - 'FocusAccessLexer': ('pygments.lexers.other', 'FOCUS access', (), ('*.acx',), ('text/x-focus-access',)), - 'FocusMasterLexer': ('pygments.lexers.other', 'FOCUS master', ('master',), ('*.mas',), ('text/x-focus-master',)), + 'FocusAccessLexer': ('pygments.lexers.other', 'FOCUS access', ('focus-access',), ('*.acx',), ('text/x-focus-access',)), + 'FocusMasterLexer': ('pygments.lexers.other', 'FOCUS master', ('focus-master',), ('*.mas',), ('text/x-focus-master',)), + 'FocusStyleSheetLexer': ('pygments.lexers.other', 'FOCUS style sheet', ('focus-style',), ('*.sty',), ('text/x-focus-style',)), 'FortranLexer': ('pygments.lexers.compiled', 'Fortran', ('fortran',), ('*.f', '*.f90', '*.F', '*.F90'), ('text/x-fortran',)), 'FoxProLexer': ('pygments.lexers.foxpro', 'FoxPro', ('Clipper', 'XBase'), ('*.PRG', '*.prg'), ()), 'GLShaderLexer': ('pygments.lexers.compiled', 'GLSL', ('glsl',), ('*.vert', '*.frag', '*.geo'), ('text/x-glslsrc',)), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index a4cd2f95..efa51b72 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -38,7 +38,7 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer', 'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer', 'CbmBasicV2Lexer', 'AutoItLexer', 'EasytrieveLexer', 'JclLexer', 'RexxLexer', 'WebFocusLexer', 'FocusAccessLexer', - 'FocusMasterLexer'] + 'FocusMasterLexer', 'FocusStyleSheetLexer'] class ECLLexer(RegexLexer): @@ -4093,23 +4093,31 @@ class FocusMasterLexer(RegexLexer): *New in Pygments 1.x.* """ name = 'FOCUS master' - aliases = ['master'] + aliases = ['focus-master'] filenames = ['*.mas'] mimetypes = ['text/x-focus-master'] flags = re.IGNORECASE tokens = { 'root': [ + (r'-\*.*\n', Comment.Single), + include('name'), + ], + 'name': [ (r'\$.*\n', Comment.Single), (r'\s+', Whitespace), - (r'[a-z_][a-z0-9_]*', Name), + (r'[a-z_][a-z0-9_]*', Name.Builtin, 'before_value'), + (r'(\\)(\n)', bygroups(Operator, Text)), + ], + 'before_value': [ (r'=', Punctuation, 'value'), - (r'\.', Punctuation), - ], + (r'\s+', Whitespace), + (r'.', Error, 'name') + ], 'value': [ (r'\$.*\n', Comment.Single, 'root'), (r'\n', Text), - (r',', Punctuation, 'root'), + (r',', Punctuation, 'name'), (r'\.!', Punctuation), (r'["]', String, 'string_double'), (r'\'', String, 'string_single'), @@ -4155,7 +4163,7 @@ class FocusAccessLexer(FocusMasterLexer): *New in Pygments 1.x.* """ name = 'FOCUS access' - aliases = [] + aliases = ['focus-access'] filenames = ['*.acx'] mimetypes = ['text/x-focus-access'] @@ -4166,7 +4174,8 @@ class FocusAccessLexer(FocusMasterLexer): def analyse_text(text): """ - Check for ``SEGMENT=..., TABLENAME=...`` while ignoring comments starting with ``$``. + Check for ``SEGMENT=..., TABLENAME=...`` while ignoring comments + starting with ``$``. """ result = 0.0 @@ -4177,6 +4186,46 @@ class FocusAccessLexer(FocusMasterLexer): return result +class FocusStyleSheetLexer(FocusMasterLexer): + """ + Style sheet to format reports written in FOCUS. + + *New in Pygments 1.x.* + """ + name = 'FOCUS style sheet' + aliases = ['focus-style'] + filenames = ['*.sty'] + mimetypes = ['text/x-focus-style'] + + _HEADER_TYPE_PATTERN = re.compile( + r'^(((\s*\$)|(-\*)).*\n)*type\s*=\s*[a-z]+\s*,.+', + re.IGNORECASE + ) + _HEADER_PAGE_DECLARATION_PATTERN = re.compile( + r'^(((\s*\$)|(-\*)).*\n)*(orientation|pagecolor|pagesize)\s*=\s*.+\s*,.+', + re.IGNORECASE + ) + + def analyse_text(text): + """ + Check for ``TYPE=...,...`` or page layout declaration while + ignoring comments starting with ``$`` or ``-*``. + """ + result = 0.0 + + if FocusStyleSheetLexer._HEADER_TYPE_PATTERN.match(text): + result = 0.7 + elif FocusStyleSheetLexer._HEADER_PAGE_DECLARATION_PATTERN.match(text): + result = 0.5 + if result > 0: + textStartsWithComment = text.startswith('-*') or text.lstrip().startswith('$') + if textStartsWithComment: + result += 0.2 + + assert 0.0 <= result <= 1.0 + return result + + class RexxLexer(RegexLexer): """ `Rexx `_ is a scripting language available for -- cgit v1.2.1 From 02051996e26d1f6cf80836073c9fd57ec44a0f80 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Mon, 1 Apr 2013 16:02:20 +0200 Subject: #7: Add lexer for WebFOCUS style sheets. Added example WebFOCUS style sheet. --- tests/examplefiles/example.sty | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/examplefiles/example.sty diff --git a/tests/examplefiles/example.sty b/tests/examplefiles/example.sty new file mode 100644 index 00000000..0c113d0f --- /dev/null +++ b/tests/examplefiles/example.sty @@ -0,0 +1,10 @@ +$ Example WebFOCUS style sheet. +-* A FOCUS comment. +TYPE=REPORT, PAGESIZE=A4, Orientation = LANDSCAPE, $ +TYPE=HEADING, FONT='Helvetica', + SIZE=14, STYLE=BOLD, $ another comment + +PAGECOLOR=blue, $ + +TYPE=HEADING, OBJECT=TEXT, ITEM=2, COLOR=BLUE, SIZE=12, + STYLE=BOLD+UNDERLINE, $ -- cgit v1.2.1 From 09f6b72ec3c24d1b4955f39f0b1923d2f06fa052 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Thu, 18 Apr 2013 22:20:32 +0200 Subject: Cleaned up Easytrieve lexer: delimiters are no collected in constants to make the regular expressions easier to read. --- pygments/lexers/other.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 84c30bf9..3d5d5118 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3685,24 +3685,31 @@ class EasytrieveLexer(RegexLexer): mimetypes = ['text/x-easytrieve'] flags = 0 + # Note: We cannot use r'\b' at the start and end of keywords because + # Easytrieve Plus delimiter characters are: + # + # * space ( ) + # * apostrophe (') + # * period (.) + # * comma (,) + # * paranthesis ( and ) + # * colon (:) + # + # Additionally words end once a '*' appears, indicatins a comment. + _DELIMITERS = r' \'.,():\n' + _DELIMITERS_OR_COMENT = _DELIMITERS + '*' + _DELIMITER_PATTERN = '[' + _DELIMITERS + ']' + _NON_DELIMITER_OR_COMMENT_PATTERN = '[^' + _DELIMITERS_OR_COMENT + ']' + tokens = { - # Note: We cannot use r'\b' at the start and end of keywords because - # Easytrieve Plus delimiter characters are: - # - # * space ( ) - # * apostrophe (') - # * period (.) - # * comma (,) - # * paranthesis ( and ) - # * colon (:) 'root': [ (r'\*.*\n', Comment.Single), (r'\n+', Whitespace), # Macro argument - (r'&[^ *\'.,():\n]+\.', Name.Variable, 'after_macro_argument'), + (r'&' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+\.', Name.Variable, 'after_macro_argument'), # Macro call - (r'%[^ *\'.,():\n]+', Name.Variable), - (r'(FILE|JOB|PARM|PROC|REPORT)([ \'.,():\n])', + (r'%' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Variable), + (r'(FILE|JOB|PARM|PROC|REPORT)(' + _DELIMITER_PATTERN + r')', bygroups(Keyword.Declaration, Operator)), (r'(AFTER-BREAK|AFTER-LINE|AFTER-SCREEN|AIM|AND|ATTR|BEFORE|' r'BEFORE-BREAK|BEFORE-LINE|BEFORE-SCREEN|BUSHU|BY|CALL|CASE|' @@ -3728,7 +3735,8 @@ class EasytrieveLexer(RegexLexer): r'SYSDATE|SYSDATE-LONG|SYSIN|SYSIPT|SYSLST|SYSPRINT|SYSSNAP|' r'SYSTIME|TALLY|TERM-COLUMNS|TERM-NAME|TERM-ROWS|TERMINATION|' r'TITLE|TO|TRANSFER|TRC|UNIQUE|UNTIL|UPDATE|UPPERCASE|USER|' - r'USERID|VALUE|VERIFY|W|WHEN|WHILE|WORK|WRITE|X|XDM|XRST)([ \'.,():\n])', + r'USERID|VALUE|VERIFY|W|WHEN|WHILE|WORK|WRITE|X|XDM|XRST)' + r'(' + _DELIMITER_PATTERN + r')', bygroups(Keyword.Reserved, Operator)), (r'[\[\](){}<>;,]', Punctuation), (ur'[-+/=&%¬]', Operator), @@ -3737,7 +3745,7 @@ class EasytrieveLexer(RegexLexer): (r"'(''|[^'])*'", String), (r'\.', Operator), (r'\s+', Whitespace), - (r'[^ \'.,():\n]+', Name) # Everything else just belongs to a name + (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name) # Everything else just belongs to a name ], 'after_macro_argument': [ (r'\*.*\n', Comment.Single, 'root'), @@ -3745,7 +3753,7 @@ class EasytrieveLexer(RegexLexer): (r'[\[\](){}<>;,]', Punctuation, 'root'), (ur'[.+/=&%¬]', Operator, 'root'), (r"'(''|[^'])*'", String, 'root'), - (r'[^ \'.,():\n]+', Name) # Everything else just belongs to a name + (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name) # Everything else just belongs to a name ], } -- cgit v1.2.1 From a8c185e9ed83cc757582085a58c443c7f1ed31fa Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Thu, 18 Apr 2013 22:34:50 +0200 Subject: Added version and author information for Easytrieve, FOCUS, JCL and Rexx lexers. Also cleaned up sort order of authors. --- AUTHORS | 3 ++- pygments/lexers/other.py | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index 34b40db4..dc4485f3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,8 +6,9 @@ Major developers are Tim Hatch and Armin Ronacher Other contributors, listed alphabetically, are: * Sam Aaron -- Ioke lexer -* Kumar Appaiah -- Debian control lexer * Ali Afshar -- image formatter +* Thomas Aglassinger -- Easytrieve, FOCUS, JCL and Rexx lexers +* Kumar Appaiah -- Debian control lexer * Andreas Amann -- AppleScript lexer * Timothy Armstrong -- Dart lexer fixes * Jeffrey Arnold -- R/S, Rd, BUGS, Jags, and Stan lexers diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 3d5d5118..88ccf35e 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3677,7 +3677,7 @@ class EasytrieveLexer(RegexLexer): It is mainly used on mainframe platforms and can access several of the mainframe's native file formats. It is somewhat comparable to awk. - *New in Pygments 1.x.* + *New in Pygments 1.7.* """ name = 'Easytrieve' aliases = ['easytrieve'] @@ -3839,7 +3839,7 @@ class JclLexer(RegexLexer): on how to run a batch job or start a subsystem. It is somewhat comparable to MS DOS batch and Unix shell scripts. - *New in Pygments 1.x.* + *New in Pygments 1.7.* """ name = 'JCL' aliases = ['jcl'] @@ -3921,7 +3921,7 @@ class WebFocusLexer(RegexLexer): describe, query and modify data from various sources including mainframe platforms. It also includes FIDEL, a language to describe input forms. - *New in Pygments 1.x.* + *New in Pygments 1.7.* """ name = 'WebFOCUS' aliases = ['webfocus', 'FOCUS', 'focus'] @@ -4098,7 +4098,7 @@ class FocusMasterLexer(RegexLexer): FOCUS master files describes files and tables to be queried by FOCUS programs. The are somewhat comparable to SQL ``create table`` statements. - *New in Pygments 1.x.* + *New in Pygments 1.7.* """ name = 'FOCUS master' aliases = ['focus-master'] @@ -4168,7 +4168,7 @@ class FocusAccessLexer(FocusMasterLexer): FOCUS access files associate segments in FOCUS master files with actual tables containing data. - *New in Pygments 1.x.* + *New in Pygments 1.7.* """ name = 'FOCUS access' aliases = ['focus-access'] @@ -4198,7 +4198,7 @@ class FocusStyleSheetLexer(FocusMasterLexer): """ Style sheet to format reports written in FOCUS. - *New in Pygments 1.x.* + *New in Pygments 1.7.* """ name = 'FOCUS style sheet' aliases = ['focus-style'] @@ -4241,7 +4241,7 @@ class RexxLexer(RegexLexer): systems. It is popular for I/O- and data based tasks and can act as glue language to bind different applications together. - *New in Pygments 1.x.* + *New in Pygments 1.7.* """ name = 'REXX' aliases = ['rexx', 'ARexx', 'arexx'] -- cgit v1.2.1 From ecd658f2c7e5cdcf2da94c2b8bb059b87a32a2d3 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Thu, 18 Apr 2013 22:57:08 +0200 Subject: Fixed spurious assertion. --- pygments/lexers/other.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 88ccf35e..c5ac6f16 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -4369,5 +4369,5 @@ class RexxLexer(RegexLexer): if regexToCountMap[RexxLexer._IF_THEN_DO_REGEX] > 0: result += 0.1 result = min(result, 1.0) - assert 0.0 <= result <= result + assert 0.0 <= result <= 1.0 return result -- cgit v1.2.1 From 18fd89a8bdc45000988aaec7717c3b5a0c88a32f Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Mon, 6 May 2013 22:47:02 +0200 Subject: * Fixed potential endless loops like '.*' by changing them to '.+'. * Fixed sort order with common prefixes like '(not|not-in)' to '(not-in|not)'. * Fixed quotes in double quoted strings in FOCUS master. * Changed FOCUS prefix functions to require '.' after function name. * Cleaned up redundant '[a-zA-Z]' in case insensitive expressions. * Cleaned up redundant keywords. * Cleaned up expressions like '[<]' to a simple '<'. --- pygments/lexers/other.py | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index c4371cb6..f6e97ea2 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3749,7 +3749,7 @@ class EasytrieveLexer(RegexLexer): ], 'after_macro_argument': [ (r'\*.*\n', Comment.Single, 'root'), - (r'[\n\s]+', Whitespace, 'root'), + (r'\s+', Whitespace, 'root'), (r'[\[\](){}<>;,]', Punctuation, 'root'), (ur'[.+/=&%¬]', Operator, 'root'), (r"'(''|[^'])*'", String, 'root'), @@ -3879,7 +3879,7 @@ class JclLexer(RegexLexer): (r'\*', Name.Builtin), (r'[\[\](){}<>;,]', Punctuation), (r'[-+*/=&%]', Operator), - (r'[a-zA-Z_][a-zA-Z_0-9]*', Name), + (r'[a-z_][a-z_0-9]*', Name), (r'[0-9]+\.[0-9]*', Number.Float), (r'\.[0-9]+', Number.Float), (r'[0-9]+', Number.Integer), @@ -3895,7 +3895,7 @@ class JclLexer(RegexLexer): ], 'option_comment': [ (r'\n', Text, 'root'), - (r'.*', Comment.Single), + (r'.+', Comment.Single), ] } @@ -3954,20 +3954,20 @@ class WebFocusLexer(RegexLexer): r'update|when|where|with|within)\b', Keyword.Reserved), (r'"', String, 'focus_fidel'), (r'\b(missing)\b', Name.Constant), - (r'\b(asq|ave|cnt|cnt|ct|dst|fst|lst|max|min|pct|rcpt|st|sum|' - r'tot)\.', Operator), + (r'\b(asq|ave|cnt|ct|dst|fst|lst|max|min|pct|rcpt|st|sum|tot)\.', + Operator), # FOCUS field declaration including display options. (r'([a-z][a-z_0-9]*)([/])([adfip]*[0-9]+(\.[0-9]+)[-%bcdelmnrsty]*)', bygroups(Name.Variable, Operator, Keyword.Type)), # Rules common to 'focus' and 'dialog_manager'. (r'\b(and|contains|div|eq|exceeds|excludes|from|ge|gt|in|' - r'includes|is|is-from|is-from|is-less-than|is-more-than|' - r'is-not-missing|le|like|lt|mod|ne|not|not-from|omits|or|to)\b', + r'includes|is-from|is-less-than|is-more-than|' + r'is-not-missing|is|le|like|lt|mod|ne|not-from|not|omits|or|to)\b', Operator), (r'[-+*/=|!]', Operator), (r'[(){}<>;,]', Punctuation), (r'[a-z_][a-z_0-9]*', Literal), - (r'[&]+[a-z_][a-z_0-9]*', Literal), + (r'&+[a-z_][a-z_0-9]*', Literal), (r'[0-9]+\.[0-9]*', Number.Float), (r'\.[0-9]+', Number.Float), (r'[0-9]+', Number.Integer), @@ -3977,13 +3977,13 @@ class WebFocusLexer(RegexLexer): 'dialog_manager': [ # Detect possible labels in first word of dialog manager line. (r'\s*type\b', Keyword.Reserved, 'dialog_manager_type'), - (r'[:][a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), + (r':[a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), (r'"', String, 'dialog_manager_fidel'), # TODO: Get rid of redundant dialog manager keyword rule which # already could be handled by the included # 'dialog_manager_others'. However, we currently need it to not # recognize classic labels without ':' too soon. - (r'\b([?]|close|cms|crtclear|crtform|default|defaults|else|exit|' + (r'\b(\?|close|cms|crtclear|crtform|default|defaults|else|exit|' r'goto|htmlform|if|include|mvs|pass|prompt|quit|read|repeat|' r'run|set|then|tso|type|window|write)\b', Keyword.Reserved, 'dialog_manager_others'), @@ -3993,8 +3993,8 @@ class WebFocusLexer(RegexLexer): 'dialog_manager_others': [ (r'\n', Text, 'root'), (r'\s*type\b', Keyword.Reserved, 'dialog_manager_type'), - (r'[:][a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), - (r'\b([?]|close|cms|crtclear|crtform|default|defaults|else|exit|' + (r':[a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), + (r'\b(\?|close|cms|crtclear|crtform|default|defaults|else|exit|' r'goto|htmlform|if|include|mvs|pass|prompt|quit|read|repeat|' r'run|set|then|tso|type|window|write)\b', Keyword.Reserved), # Rules common to 'focus' and 'dialog_manager'. @@ -4005,7 +4005,7 @@ class WebFocusLexer(RegexLexer): (r'[-+*/=|!]', Operator), (r'[(){}<>;,]', Punctuation), (r'[a-z_][a-z_0-9]*', Literal), - (r'[&]+[a-z_][a-z_0-9]*', Name.Variable), + (r'&+[a-z_][a-z_0-9]*', Name.Variable), (r'[0-9]+\.[0-9]*', Number.Float), (r'\.[0-9]+', Number.Float), (r'[0-9]+', Number.Integer), @@ -4015,12 +4015,12 @@ class WebFocusLexer(RegexLexer): 'dialog_manager_type': [ # For -TYPE, render everything as ``String`` except variables. (r'\n', Text, 'root'), - (r'[&]+[a-z_][a-z_0-9]*\.*', Name.Variable), - (r'[^&\n]*', String) + (r'&+[a-z_][a-z_0-9]*\.*', Name.Variable), + (r'[^&\n]+', String) ], 'dialog_manager_fidel': [ (r'"', String, 'dialog_manager_fidel_end'), - (r'([<])([&][a-z][a-z_0-9]*)([/])([0-9]+)', + (r'(<)(&[a-z][a-z_0-9]*)([/])([0-9]+)', bygroups(Keyword.Reserved, Name.Variable, Operator, Number.Integer)), (r'.', String) ], @@ -4030,13 +4030,13 @@ class WebFocusLexer(RegexLexer): ], 'focus_fidel': [ (r'"', String, 'focus_fidel_end'), - (r'[&]+[a-z][a-z_0-9]*', Name.Variable), + (r'&+[a-z][a-z_0-9]*', Name.Variable), (r'\>', Keyword.Reserved), # Line continuation. (r'\<0x\s*\n', Keyword.Reserved), - (r'([<])([a-z][a-z_0-9]*)', + (r'(<)([a-z][a-z_0-9]*)', bygroups(Keyword.Reserved, Name.Variable)), - (r'([<])([+-/]?)([0-9]+)', + (r'(<)(\+|-|/)?([0-9]+)', bygroups(Keyword.Reserved, Operator, Number.Integer)), (r'.', String) ], @@ -4127,15 +4127,15 @@ class FocusMasterLexer(RegexLexer): (r'\n', Text), (r',', Punctuation, 'name'), (r'\.!', Punctuation), - (r'["]', String, 'string_double'), + (r'"', String, 'string_double'), (r'\'', String, 'string_single'), (r'[a-z_][a-z0-9_]*', Text), (r'[0-9]+(\.[0-9]+)?', Number), (r'.', Text), ], 'string_double': [ - (r'\'["]["]', String), - (r'["]', String, 'value'), + (r'""', String), + (r'"', String, 'value'), (r'[^"]', String), ], 'string_single': [ @@ -4251,9 +4251,9 @@ class RexxLexer(RegexLexer): tokens = { 'root': [ - (r'[\s\n]', Whitespace), + (r'\s', Whitespace), (r'/\*', Comment.Multiline, 'comment'), - (r'["]', String, 'string_double'), + (r'"', String, 'string_double'), (r"'", String, 'string_single'), (r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number), (r'([a-z_][a-z0-9_]*)(\s*)(:)(\s*)(procedure)\b', @@ -4283,7 +4283,7 @@ class RexxLexer(RegexLexer): r'while)\b', Keyword.Reserved), ], 'operator': [ - (ur'(-|//|/|\(|\)|\*\*|\*|\\|\\<<|\\<|\\==|\\=|\\>>|\\>|\|\||\||' + (ur'(-|//|/|\(|\)|\*\*|\*|\\<<|\\<|\\==|\\=|\\>>|\\>|\\|\|\||\||' ur'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|' ur'¬>>|¬>|¬|\.|,)', Operator), ], -- cgit v1.2.1 From 7208e79565fa2ad56d135f2144a776fece5ef61b Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Fri, 10 May 2013 00:17:55 +0200 Subject: Improved stack handling in Rexx lexer. --- pygments/lexers/other.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index f6e97ea2..ce70e3e5 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -4288,19 +4288,19 @@ class RexxLexer(RegexLexer): ur'¬>>|¬>|¬|\.|,)', Operator), ], 'string_double': [ + (r'[^"\n]', String), (r'""', String), - (r'"', String, 'root'), - (r'\n', Error, 'root'), - (r'[^"]', String), + (r'"', String, '#pop'), + (r'', Text, '#pop'), # Linefeed also terminates strings. ], 'string_single': [ + (r'[^\'\n]', String), (r'\'\'', String), - (r'\'', String, 'root'), - (r'\n', Error, 'root'), - (r'[^\']', String), + (r'\'', String, '#pop'), + (r'', Text, '#pop'), # Linefeed also terminates strings. ], 'comment': [ - (r'\*/', Comment.Multiline, 'root'), + (r'\*/', Comment.Multiline, '#pop'), (r'(.|\n)', Comment.Multiline), ] } -- cgit v1.2.1 From 677b3e86e68240d8964dd2ab818963dd8b25f8ef Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Fri, 10 May 2013 00:25:28 +0200 Subject: Added missing FOCUS keyword. --- pygments/lexers/other.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index ce70e3e5..2834b27e 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3950,8 +3950,8 @@ class WebFocusLexer(RegexLexer): r'multilines|newpage|nomatch|noprint|nototal|on|over|' r'page-break|print|printonly|ranked|recap|recompute|redefines|' r'reject|row-total|rows|savb|save|set|sub-total|subfoot|' - r'subhead|subtotal|sum|summarize|table|the|then|tiles|total|' - r'update|when|where|with|within)\b', Keyword.Reserved), + r'subhead|subtotal|sum|summarize|tablef|table|the|then|tiles|' + r'total|update|when|where|with|within)\b', Keyword.Reserved), (r'"', String, 'focus_fidel'), (r'\b(missing)\b', Name.Constant), (r'\b(asq|ave|cnt|ct|dst|fst|lst|max|min|pct|rcpt|st|sum|tot)\.', -- cgit v1.2.1 From 0dcac07fbf5b2c4e4aad0fe43f74b97677b0a3df Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sun, 19 May 2013 22:59:56 +0200 Subject: Cleaned up Easytrieve lexer. * Changed stacking 'root' to '#pop'. * Added constants for operators and punctuations. --- pygments/lexers/other.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 2834b27e..7837ebe1 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3700,6 +3700,9 @@ class EasytrieveLexer(RegexLexer): _DELIMITERS_OR_COMENT = _DELIMITERS + '*' _DELIMITER_PATTERN = '[' + _DELIMITERS + ']' _NON_DELIMITER_OR_COMMENT_PATTERN = '[^' + _DELIMITERS_OR_COMENT + ']' + _PUNCTUATIONS = r'[\[\](){}<>;,]' + _OPERATORS = ur'[+\-/=&%¬]' + tokens = { 'root': [ @@ -3738,21 +3741,20 @@ class EasytrieveLexer(RegexLexer): r'USERID|VALUE|VERIFY|W|WHEN|WHILE|WORK|WRITE|X|XDM|XRST)' r'(' + _DELIMITER_PATTERN + r')', bygroups(Keyword.Reserved, Operator)), - (r'[\[\](){}<>;,]', Punctuation), - (ur'[-+/=&%¬]', Operator), + (_PUNCTUATIONS, Punctuation), + (_OPERATORS, Operator), (r'[0-9]+\.[0-9]*', Number.Float), (r'[0-9]+', Number.Integer), (r"'(''|[^'])*'", String), - (r'\.', Operator), (r'\s+', Whitespace), (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name) # Everything else just belongs to a name ], 'after_macro_argument': [ - (r'\*.*\n', Comment.Single, 'root'), - (r'\s+', Whitespace, 'root'), - (r'[\[\](){}<>;,]', Punctuation, 'root'), - (ur'[.+/=&%¬]', Operator, 'root'), - (r"'(''|[^'])*'", String, 'root'), + (r'\*.*\n', Comment.Single, '#pop'), + (r'\s+', Whitespace, '#pop'), + (_PUNCTUATIONS, Punctuation, '#pop'), + (_OPERATORS, Operator, '#pop'), + (r"'(''|[^'])*'", String, '#pop'), (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name) # Everything else just belongs to a name ], } -- cgit v1.2.1 From a33b098546e31585b6ce854d3099683172e96c47 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Mon, 20 May 2013 00:41:25 +0200 Subject: Fixed unresolved conflict during previous merge. --- pygments/lexers/other.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 211f662c..3a9e5e59 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -14,11 +14,7 @@ import re from pygments.lexer import RegexLexer, include, bygroups, using, \ this, combined, ExtendedRegexLexer from pygments.token import Error, Punctuation, Literal, Token, \ -<<<<<<< local Text, Comment, Operator, Keyword, Name, String, Number, Generic, Other, \ -======= - Text, Comment, Operator, Keyword, Name, String, Number, Generic, \ ->>>>>>> other Whitespace from pygments.util import get_bool_opt from pygments.lexers.web import HtmlLexer -- cgit v1.2.1 From 9bc0a50e2563809f0347f379921a512e88b53770 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Thu, 30 May 2013 22:18:11 +0200 Subject: Cleaned up pattern for Easytrieve keywords. --- pygments/lexers/other.py | 73 ++++++++++++++++++++++++++---------------------- pygments/util.py | 15 ++++++++++ 2 files changed, 54 insertions(+), 34 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 3a9e5e59..c39e474c 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -26,6 +26,7 @@ from pygments.lexers._robotframeworklexer import RobotFrameworkLexer from pygments.lexers.sql import SqlLexer, MySqlLexer, SqliteConsoleLexer from pygments.lexers.shell import BashLexer, BashSessionLexer, BatchLexer, \ TcshLexer +from pygments.util import sorted_keywords_pattern __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer', 'SmalltalkLexer', 'LogtalkLexer', 'GnuplotLexer', 'PovrayLexer', @@ -3700,10 +3701,41 @@ class EasytrieveLexer(RegexLexer): _DELIMITERS_OR_COMENT = _DELIMITERS + '*' _DELIMITER_PATTERN = '[' + _DELIMITERS + ']' _NON_DELIMITER_OR_COMMENT_PATTERN = '[^' + _DELIMITERS_OR_COMENT + ']' - _PUNCTUATIONS = r'[\[\](){}<>;,]' - _OPERATORS = ur'[+\-/=&%¬]' - - + _OPERATORS_PATTERN = ur'[.+\-/=\[\](){}<>;,&%¬]' + _KEYWORDS_PATTERN = sorted_keywords_pattern([ + 'AFTER-BREAK', 'AFTER-LINE', 'AFTER-SCREEN', 'AIM', 'AND', 'ATTR', + 'BEFORE', 'BEFORE-BREAK', 'BEFORE-LINE', 'BEFORE-SCREEN', 'BUSHU', + 'BY', 'CALL', 'CASE', 'CHECKPOINT', 'CHKP', 'CHKP-STATUS', 'CLEAR', + 'CLOSE', 'COL', 'COLOR', 'COMMIT', 'CONTROL', 'COPY', 'CURSOR', 'D', + 'DECLARE', 'DEFAULT', 'DEFINE', 'DELETE', 'DENWA', 'DISPLAY', 'DLI', + 'DO', 'DUPLICATE', 'E', 'ELSE', 'ELSE-IF', 'END', 'END-CASE', + 'END-DO', 'END-IF', 'END-PROC', 'ENDPAGE', 'ENDTABLE', 'ENTER', 'EOF', + 'EQ', 'ERROR', 'EXIT', 'EXTERNAL', 'EZLIB', 'F1', 'F10', 'F11', 'F12', + 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F2', 'F20', 'F21', + 'F22', 'F23', 'F24', 'F25', 'F26', 'F27', 'F28', 'F29', 'F3', 'F30', + 'F31', 'F32', 'F33', 'F34', 'F35', 'F36', 'F4', 'F5', 'F6', 'F7', + 'F8', 'F9', 'FETCH', 'FILE-STATUS', 'FILL', 'FINAL', 'FIRST', + 'FIRST-DUP', 'FOR', 'GE', 'GET', 'GO', 'GOTO', 'GQ', 'GR', 'GT', + 'HEADING', 'HEX', 'HIGH-VALUES', 'IDD', 'IDMS', 'IF', 'IN', 'INSERT', + 'JUSTIFY', 'KANJI-DATE', 'KANJI-DATE-LONG', 'KANJI-TIME', 'KEY', + 'KEY-PRESSED', 'KOKUGO', 'KUN', 'LAST-DUP', 'LE', 'LEVEL', 'LIKE', + 'LINE', 'LINE-COUNT', 'LINE-NUMBER', 'LINK', 'LIST', 'LOW-VALUES', + 'LQ', 'LS', 'LT', 'MASK', 'MATCHED', 'MEND', 'MESSAGE', 'MOVE', + 'MSTART', 'NE', 'NEWPAGE', 'NOMASK', 'NOPRINT', 'NOT', 'NOTE', + 'NOVERIFY', 'NQ', 'NULL', 'OF', 'OR', 'OTHERWISE', 'PA1', 'PA2', + 'PA3', 'PAGE-COUNT', 'PAGE-NUMBER', 'PARM-REGISTER', 'PATH-ID', + 'PATTERN', 'PERFORM', 'POINT', 'POS', 'PRIMARY', 'PRINT', 'PROCEDURE', + 'PROGRAM', 'PUT', 'READ', 'RECORD', 'RECORD-COUNT', 'RECORD-LENGTH', + 'REFRESH', 'RELEASE', 'RENUM', 'REPEAT', 'REPORT', 'REPORT-INPUT', + 'RESHOW', 'RESTART', 'RETRIEVE', 'RETURN-CODE', 'ROLLBACK', 'ROW', + 'S', 'SCREEN', 'SEARCH', 'SECONDARY', 'SELECT', 'SEQUENCE', 'SIZE', + 'SKIP', 'SOKAKU', 'SORT', 'SQL', 'STOP', 'SUM', 'SYSDATE', + 'SYSDATE-LONG', 'SYSIN', 'SYSIPT', 'SYSLST', 'SYSPRINT', 'SYSSNAP', + 'SYSTIME', 'TALLY', 'TERM-COLUMNS', 'TERM-NAME', 'TERM-ROWS', + 'TERMINATION', 'TITLE', 'TO', 'TRANSFER', 'TRC', 'UNIQUE', 'UNTIL', + 'UPDATE', 'UPPERCASE', 'USER', 'USERID', 'VALUE', 'VERIFY', 'W', + 'WHEN', 'WHILE', 'WORK', 'WRITE', 'X', 'XDM', 'XRST' + ]) tokens = { 'root': [ (r'\*.*\n', Comment.Single), @@ -3714,35 +3746,9 @@ class EasytrieveLexer(RegexLexer): (r'%' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Variable), (r'(FILE|JOB|PARM|PROC|REPORT)(' + _DELIMITER_PATTERN + r')', bygroups(Keyword.Declaration, Operator)), - (r'(AFTER-BREAK|AFTER-LINE|AFTER-SCREEN|AIM|AND|ATTR|BEFORE|' - r'BEFORE-BREAK|BEFORE-LINE|BEFORE-SCREEN|BUSHU|BY|CALL|CASE|' - r'CHECKPOINT|CHKP|CHKP-STATUS|CLEAR|CLOSE|COL|COLOR|COMMIT|' - r'CONTROL|COPY|CURSOR|D|DECLARE|DEFAULT|DEFINE|DELETE|DENWA|' - r'DISPLAY|DLI|DO|DUPLICATE|E|ELSE|ELSE-IF|END|END-CASE|END-DO|' - r'END-IF|END-PROC|ENDPAGE|ENDTABLE|ENTER|EOF|EQ|ERROR|EXIT|' - r'EXTERNAL|EZLIB|F1|F10|F11|F12|F13|F14|F15|F16|F17|F18|F19|F2|' - r'F20|F21|F22|F23|F24|F25|F26|F27|F28|F29|F3|F30|F31|F32|F33|' - r'F34|F35|F36|F4|F5|F6|F7|F8|F9|FETCH|FILE-STATUS|FILL|' - r'FINAL|FIRST|FIRST-DUP|FOR|GE|GET|GO|GOTO|GQ|GR|GT|HEADING|' - r'HEX|HIGH-VALUES|IDD|IDMS|IF|IN|INSERT|JUSTIFY|KANJI-DATE|' - r'KANJI-DATE-LONG|KANJI-TIME|KEY|KEY-PRESSED|KOKUGO|KUN|' - r'LAST-DUP|LE|LEVEL|LIKE|LINE|LINE-COUNT|LINE-NUMBER|LINK|LIST|' - r'LOW-VALUES|LQ|LS|LT|MASK|MATCHED|MEND|MESSAGE|MOVE|MSTART|NE|' - r'NEWPAGE|NOMASK|NOPRINT|NOT|NOTE|NOVERIFY|NQ|NULL|OF|OR|' - r'OTHERWISE|PA1|PA2|PA3|PAGE-COUNT|PAGE-NUMBER|PARM-REGISTER|' - r'PATH-ID|PATTERN|PERFORM|POINT|POS|PRIMARY|PRINT|' - r'PROCEDURE|PROGRAM|PUT|READ|RECORD|RECORD-COUNT|RECORD-LENGTH|' - r'REFRESH|RELEASE|RENUM|REPEAT|REPORT|REPORT-INPUT|RESHOW|' - r'RESTART|RETRIEVE|RETURN-CODE|ROLLBACK|ROW|S|SCREEN|SEARCH|' - r'SECONDARY|SELECT|SEQUENCE|SIZE|SKIP|SOKAKU|SORT|SQL|STOP|SUM|' - r'SYSDATE|SYSDATE-LONG|SYSIN|SYSIPT|SYSLST|SYSPRINT|SYSSNAP|' - r'SYSTIME|TALLY|TERM-COLUMNS|TERM-NAME|TERM-ROWS|TERMINATION|' - r'TITLE|TO|TRANSFER|TRC|UNIQUE|UNTIL|UPDATE|UPPERCASE|USER|' - r'USERID|VALUE|VERIFY|W|WHEN|WHILE|WORK|WRITE|X|XDM|XRST)' - r'(' + _DELIMITER_PATTERN + r')', + (_KEYWORDS_PATTERN + r'(' + _DELIMITER_PATTERN + r')', bygroups(Keyword.Reserved, Operator)), - (_PUNCTUATIONS, Punctuation), - (_OPERATORS, Operator), + (_OPERATORS_PATTERN, Operator), (r'[0-9]+\.[0-9]*', Number.Float), (r'[0-9]+', Number.Integer), (r"'(''|[^'])*'", String), @@ -3752,8 +3758,7 @@ class EasytrieveLexer(RegexLexer): 'after_macro_argument': [ (r'\*.*\n', Comment.Single, '#pop'), (r'\s+', Whitespace, '#pop'), - (_PUNCTUATIONS, Punctuation, '#pop'), - (_OPERATORS, Operator, '#pop'), + (_OPERATORS_PATTERN, Operator, '#pop'), (r"'(''|[^'])*'", String, '#pop'), (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name) # Everything else just belongs to a name ], diff --git a/pygments/util.py b/pygments/util.py index caac1144..9a6c525c 100644 --- a/pygments/util.py +++ b/pygments/util.py @@ -251,6 +251,21 @@ def unirange(a, b): return u'(?:' + u'|'.join(buf) + u')' +def sorted_keywords_pattern(keywords): + ''' + Pattern for a regular expression that matches any word in ``keywords`` even if + some of them are prefixes of others. This is particular useful if '\b' cannot be + use as delimiter after a keyword. + + >>> sorted_keywords_pattern(['a', 'aa', 'aaa', 'b', 'cc']) + u'(aaa|aa|cc|a|b)' + ''' + assert keywords is not None + escaped_keywords = [re.escape(keyword) for keyword in keywords] + sort_key = lambda keyword: (-len(keyword), keyword) + sorted_keywords = sorted(escaped_keywords, key=sort_key) + return u'(' + '|'.join(sorted_keywords) + u')' + # Python 2/3 compatibility if sys.version_info < (3,0): -- cgit v1.2.1 From 26e8af5761aab8daeb85f287d7abf2fa42cb43e1 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Fri, 31 May 2013 01:26:37 +0200 Subject: Cleaned up handling of Rexx functions, keywords and operators. --- pygments/lexers/other.py | 51 ++++++++++++++++++++++++------------------------ pygments/util.py | 4 ++-- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index c39e474c..72c6bc43 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -4256,6 +4256,28 @@ class RexxLexer(RegexLexer): mimetypes = ['text/x-rexx'] flags = re.IGNORECASE + _FUNCTIONS_PATTERN = sorted_keywords_pattern([ + 'abbrev', 'abs', 'address', 'arg', 'b2x', 'bitand', 'bitor', 'bitxor', + 'c2d', 'c2x', 'center', 'charin', 'charout', 'chars', 'compare', + 'condition', 'copies', 'd2c', 'd2x', 'datatype', 'date', 'delstr', + 'delword', 'digits', 'errortext', 'form', 'format', 'fuzz', 'insert', + 'lastpos', 'left', 'length', 'linein', 'lineout', 'lines', 'max', + 'min', 'overlay', 'pos', 'queued', 'random', 'reverse', 'right', + 'sign', 'sourceline', 'space', 'stream', 'strip', 'substr', 'subword', + 'symbol', 'time', 'trace', 'translate', 'trunc', 'value', 'verify', + 'word', 'wordindex', 'wordlength', 'wordpos', 'words', 'x2b', 'x2c', + 'x2d', 'xrange']) + _KEYWORDS_PATTERN = sorted_keywords_pattern([ + 'address', 'arg', 'by', 'call', 'do', 'drop', 'else', 'end', 'exit', + 'for', 'forever', 'if', 'interpret', 'iterate', 'leave', 'nop', + 'numeric', 'off', 'on', 'options', 'parse', 'pull', 'push', 'queue', + 'return', 'say', 'select', 'signal', 'then', 'to', 'trace', 'until', + 'while']) + _OPERATORS_PATTERN = sorted_keywords_pattern([ + '%', '&', '&&', '(', ')', '*', '**', '+', ',', '-', '.', '/', '//', + '<', '<<', '<<=', '<=', '<>', '=', '==', '>', '><', '>=', '>>', '>>=', + '\\', '\\<', '\\<<', '\\=', '\\==', '\\>', '\\>>', '|', '||', u'¬', + u'¬<', u'¬<<', u'¬=', u'¬==', u'¬>', u'¬>>']) tokens = { 'root': [ (r'\s', Whitespace), @@ -4268,32 +4290,11 @@ class RexxLexer(RegexLexer): Keyword.Declaration)), (r'([a-z_][a-z0-9_]*)(\s*)(:)', bygroups(Name.Label, Whitespace, Operator)), - include('function'), - include('keyword'), - include('operator'), - (r'[a-z_][a-z0-9_]*', Text), - ], - 'function': [ - (r'(abbrev|abs|address|arg|b2x|bitand|bitor|bitxor|c2d|c2x|' - r'center|charin|charout|chars|compare|condition|copies|d2c|' - r'd2x|datatype|date|delstr|delword|digits|errortext|form|' - r'format|fuzz|insert|lastpos|left|length|linein|lineout|lines|' - r'max|min|overlay|pos|queued|random|reverse|right|sign|' - r'sourceline|space|stream|strip|substr|subword|symbol|time|' - r'trace|translate|trunc|value|verify|word|wordindex|' - r'wordlength|wordpos|words|x2b|x2c|x2d|xrange)(\s*)(\()', + (_FUNCTIONS_PATTERN + r'(\s*)(\()', bygroups(Name.Builtin, Whitespace, Operator)), - ], - 'keyword': [ - (r'(address|arg|by|call|do|drop|else|end|exit|for|forever|if|' - r'interpret|iterate|leave|nop|numeric|off|on|options|parse|' - r'pull|push|queue|return|say|select|signal|to|then|trace|until|' - r'while)\b', Keyword.Reserved), - ], - 'operator': [ - (ur'(-|//|/|\(|\)|\*\*|\*|\\<<|\\<|\\==|\\=|\\>>|\\>|\\|\|\||\||' - ur'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|' - ur'¬>>|¬>|¬|\.|,)', Operator), + (_KEYWORDS_PATTERN + r'\b', Keyword.Reserved), + (_OPERATORS_PATTERN, Operator), + (r'[a-z_][a-z0-9_]*', Text), ], 'string_double': [ (r'[^"\n]+', String), diff --git a/pygments/util.py b/pygments/util.py index 9a6c525c..67689ce4 100644 --- a/pygments/util.py +++ b/pygments/util.py @@ -255,7 +255,7 @@ def sorted_keywords_pattern(keywords): ''' Pattern for a regular expression that matches any word in ``keywords`` even if some of them are prefixes of others. This is particular useful if '\b' cannot be - use as delimiter after a keyword. + used as delimiter after a keyword. >>> sorted_keywords_pattern(['a', 'aa', 'aaa', 'b', 'cc']) u'(aaa|aa|cc|a|b)' @@ -264,7 +264,7 @@ def sorted_keywords_pattern(keywords): escaped_keywords = [re.escape(keyword) for keyword in keywords] sort_key = lambda keyword: (-len(keyword), keyword) sorted_keywords = sorted(escaped_keywords, key=sort_key) - return u'(' + '|'.join(sorted_keywords) + u')' + return u'(' + u'|'.join(sorted_keywords) + u')' # Python 2/3 compatibility -- cgit v1.2.1 From b3cbb1e20b74269deeb146513b6de353e5583a67 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sun, 2 Jun 2013 14:37:59 +0200 Subject: Improved lexers for Easytrieve and JCL * Added highlighting names of Easytrive file, macro, procedure and report declarations. * Added missing Easytrive keyword "MACRO". * Cleaned up JCL lexer stack by changing a few named target states to '#pop'. There are still several named states left though. --- pygments/lexers/other.py | 94 +++++++++++++++++++++++++----------------- tests/examplefiles/example.ezt | 16 +++++-- tests/test_lexers_other.py | 22 ++++++++-- 3 files changed, 87 insertions(+), 45 deletions(-) diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 72c6bc43..6c094c7e 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -3720,21 +3720,21 @@ class EasytrieveLexer(RegexLexer): 'JUSTIFY', 'KANJI-DATE', 'KANJI-DATE-LONG', 'KANJI-TIME', 'KEY', 'KEY-PRESSED', 'KOKUGO', 'KUN', 'LAST-DUP', 'LE', 'LEVEL', 'LIKE', 'LINE', 'LINE-COUNT', 'LINE-NUMBER', 'LINK', 'LIST', 'LOW-VALUES', - 'LQ', 'LS', 'LT', 'MASK', 'MATCHED', 'MEND', 'MESSAGE', 'MOVE', - 'MSTART', 'NE', 'NEWPAGE', 'NOMASK', 'NOPRINT', 'NOT', 'NOTE', - 'NOVERIFY', 'NQ', 'NULL', 'OF', 'OR', 'OTHERWISE', 'PA1', 'PA2', - 'PA3', 'PAGE-COUNT', 'PAGE-NUMBER', 'PARM-REGISTER', 'PATH-ID', - 'PATTERN', 'PERFORM', 'POINT', 'POS', 'PRIMARY', 'PRINT', 'PROCEDURE', - 'PROGRAM', 'PUT', 'READ', 'RECORD', 'RECORD-COUNT', 'RECORD-LENGTH', - 'REFRESH', 'RELEASE', 'RENUM', 'REPEAT', 'REPORT', 'REPORT-INPUT', - 'RESHOW', 'RESTART', 'RETRIEVE', 'RETURN-CODE', 'ROLLBACK', 'ROW', - 'S', 'SCREEN', 'SEARCH', 'SECONDARY', 'SELECT', 'SEQUENCE', 'SIZE', - 'SKIP', 'SOKAKU', 'SORT', 'SQL', 'STOP', 'SUM', 'SYSDATE', - 'SYSDATE-LONG', 'SYSIN', 'SYSIPT', 'SYSLST', 'SYSPRINT', 'SYSSNAP', - 'SYSTIME', 'TALLY', 'TERM-COLUMNS', 'TERM-NAME', 'TERM-ROWS', - 'TERMINATION', 'TITLE', 'TO', 'TRANSFER', 'TRC', 'UNIQUE', 'UNTIL', - 'UPDATE', 'UPPERCASE', 'USER', 'USERID', 'VALUE', 'VERIFY', 'W', - 'WHEN', 'WHILE', 'WORK', 'WRITE', 'X', 'XDM', 'XRST' + 'LQ', 'LS', 'LT', 'MACRO', 'MASK', 'MATCHED', 'MEND', 'MESSAGE', + 'MOVE', 'MSTART', 'NE', 'NEWPAGE', 'NOMASK', 'NOPRINT', 'NOT', + 'NOTE', 'NOVERIFY', 'NQ', 'NULL', 'OF', 'OR', 'OTHERWISE', 'PA1', + 'PA2', 'PA3', 'PAGE-COUNT', 'PAGE-NUMBER', 'PARM-REGISTER', + 'PATH-ID', 'PATTERN', 'PERFORM', 'POINT', 'POS', 'PRIMARY', 'PRINT', + 'PROCEDURE', 'PROGRAM', 'PUT', 'READ', 'RECORD', 'RECORD-COUNT', + 'RECORD-LENGTH', 'REFRESH', 'RELEASE', 'RENUM', 'REPEAT', 'REPORT', + 'REPORT-INPUT', 'RESHOW', 'RESTART', 'RETRIEVE', 'RETURN-CODE', + 'ROLLBACK', 'ROW', 'S', 'SCREEN', 'SEARCH', 'SECONDARY', 'SELECT', + 'SEQUENCE', 'SIZE', 'SKIP', 'SOKAKU', 'SORT', 'SQL', 'STOP', 'SUM', + 'SYSDATE', 'SYSDATE-LONG', 'SYSIN', 'SYSIPT', 'SYSLST', 'SYSPRINT', + 'SYSSNAP', 'SYSTIME', 'TALLY', 'TERM-COLUMNS', 'TERM-NAME', + 'TERM-ROWS', 'TERMINATION', 'TITLE', 'TO', 'TRANSFER', 'TRC', + 'UNIQUE', 'UNTIL', 'UPDATE', 'UPPERCASE', 'USER', 'USERID', 'VALUE', + 'VERIFY', 'W', 'WHEN', 'WHILE', 'WORK', 'WRITE', 'X', 'XDM', 'XRST' ]) tokens = { 'root': [ @@ -3744,17 +3744,26 @@ class EasytrieveLexer(RegexLexer): (r'&' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+\.', Name.Variable, 'after_macro_argument'), # Macro call (r'%' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Variable), - (r'(FILE|JOB|PARM|PROC|REPORT)(' + _DELIMITER_PATTERN + r')', + (r'(FILE|MACRO|REPORT)(\s+)', + bygroups(Keyword.Declaration, Whitespace), 'after_declaration'), + (r'(JOB|PARM)' + r'(' + _DELIMITER_PATTERN + r')', bygroups(Keyword.Declaration, Operator)), (_KEYWORDS_PATTERN + r'(' + _DELIMITER_PATTERN + r')', bygroups(Keyword.Reserved, Operator)), (_OPERATORS_PATTERN, Operator), + # Procedure declaration + (r'(' + _NON_DELIMITER_OR_COMMENT_PATTERN + r'+)(\s*)(\.?)(\s*)(PROC)(\s*\n)', + bygroups(Name.Function, Whitespace, Operator, Whitespace, Keyword.Declaration, Whitespace)), (r'[0-9]+\.[0-9]*', Number.Float), (r'[0-9]+', Number.Integer), (r"'(''|[^'])*'", String), (r'\s+', Whitespace), (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name) # Everything else just belongs to a name ], + 'after_declaration': [ + (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name.Function), + ('', Whitespace, '#pop') + ], 'after_macro_argument': [ (r'\*.*\n', Comment.Single, '#pop'), (r'\s+', Whitespace, '#pop'), @@ -3763,6 +3772,8 @@ class EasytrieveLexer(RegexLexer): (_NON_DELIMITER_OR_COMMENT_PATTERN + r'+', Name) # Everything else just belongs to a name ], } + _COMMENT_LINE_REGEX = re.compile(r'^\s*\*') + _MACRO_HEADER_REGEX = re.compile(r'^\s*MACRO') def analyse_text(text): """ @@ -3777,15 +3788,20 @@ class EasytrieveLexer(RegexLexer): hasProc = False hasParm = False hasReport = False - isBroken = False - # Skip possible header comments. - while len(lines) and lines[0].startswith('*'): - hasHeaderComment = True + def isCommentLine(line): + return EasytrieveLexer._COMMENT_LINE_REGEX.match(lines[0]) is not None + + def isEmptyLine(line): + return not bool(line.strip()) + + # Remove possible empty lines and header comments. + while lines and (isEmptyLine(lines[0]) or isCommentLine(lines[0])): + if not isEmptyLine(lines[0]): + hasHeaderComment = True del lines[0] - firstLine = lines[0] - if firstLine[:6] in ('MACRO', 'MACRO '): + if EasytrieveLexer._MACRO_HEADER_REGEX.match(lines[0]): # Looks like an Easytrieve macro. result = 0.4 if hasHeaderComment: @@ -3795,37 +3811,39 @@ class EasytrieveLexer(RegexLexer): for line in lines: words = line.split() if (len(words) >= 2): - first_word = words[0] + firstWord = words[0] if not hasReport: if not hasJob: if not hasFile: if not hasParm: - if first_word == 'PARM': + if firstWord == 'PARM': hasParm = True - if first_word == 'FILE': + if firstWord == 'FILE': hasFile = True - if first_word == 'JOB': + if firstWord == 'JOB': hasJob = True - elif first_word == 'PROC': + elif firstWord == 'PROC': hasProc = True - elif first_word == 'END-PROC': + elif firstWord == 'END-PROC': hasEndProc = True - elif first_word == 'REPORT': + elif firstWord == 'REPORT': hasReport = True # Weight the findings. - if not isBroken and hasJob and (hasProc == hasEndProc): + if hasJob and (hasProc == hasEndProc): + if hasHeaderComment: + result += 0.1 if hasParm: if hasProc: # Found PARM, JOB and PROC/END-PROC: # pretty sure this is Easytrieve. - result = 0.8 + result += 0.8 else: # Found PARAM and JOB: probably this is Easytrieve - result = 0.5 + result += 0.5 else: # Found JOB and possibly other keywords: might be Easytrieve - result = 0.11 + result += 0.11 if hasParm: # Note: PARAM is not a proper English word, so this is # regarded a much better indicator for Easytrieve than @@ -3843,7 +3861,7 @@ class JclLexer(RegexLexer): """ `Job Control Language (JCL) `_ is a scripting language used on mainframe platforms to instruct the system - on how to run a batch job or start a subsystem. It is somewhat + on how to run a batch job or start a subsystem. It is somewhat comparable to MS DOS batch and Unix shell scripts. *New in Pygments 1.7.* @@ -3863,7 +3881,7 @@ class JclLexer(RegexLexer): (r'.*\n', Other) # Input text or inline code in any language. ], 'statement': [ - (r'\s*\n', Whitespace, 'root'), + (r'\s*\n', Whitespace, '#pop'), (r'([a-z][a-z_0-9]*)(\s+)(exec|job)(\s*)', bygroups(Name.Label, Whitespace, Keyword.Reserved, Whitespace), 'option'), @@ -3872,11 +3890,11 @@ class JclLexer(RegexLexer): ], 'statement_command': [ (r'\s+(command|cntl|dd|endctl|endif|else|include|jcllib|' - r'output|pend|proc|set|then|xmit)\s*', Keyword.Reserved, 'option'), + r'output|pend|proc|set|then|xmit)\s+', Keyword.Reserved, 'option'), include('option') ], 'jes2_statement': [ - (r'\s*\n', Whitespace, 'root'), + (r'\s*\n', Whitespace, '#pop'), (r'\$', Keyword, 'option'), (r'\b(jobparam|message|netacct|notify|output|priority|route|' r'setup|signoff|xeq|xmit)\b', Keyword, 'option'), @@ -3898,7 +3916,7 @@ class JclLexer(RegexLexer): (r"(\n)(//)", bygroups(Text, Keyword.Pseudo)), (r"''", String), (r"[^']", String), - (r"'", String, 'option'), + (r"'", String, '#pop'), ], 'option_comment': [ (r'\n', Text, 'root'), diff --git a/tests/examplefiles/example.ezt b/tests/examplefiles/example.ezt index b068fca3..fec2aa4c 100644 --- a/tests/examplefiles/example.ezt +++ b/tests/examplefiles/example.ezt @@ -1,4 +1,4 @@ -* Easytrieve Plus Test Programm. +* Easytrieve Plus example programm. * Environtment section. PARM DEBUG(FLOW FLDCHK) @@ -10,13 +10,23 @@ FILE PERSNL FB(150 1800) DEPT 98 3 N. GROSS 94 4 P 2 * ^ 2 field definitions in 1 line. +* Call macro in example.mac. FILE EXAMPLE FB(80 200) %EXAMPLE SOMEFILE SOME -* Macro declaration (to be valid, this would * Activity Section. -JOB INPUT PERSNL NAME FIRST-PROGRAM +JOB INPUT PERSNL NAME FIRST-PROGRAM START AT-START FINISH AT_FINISH PRINT PAY-RPT REPORT PAY-RPT LINESIZE 80 TITLE 01 'PERSONNEL REPORT EXAMPLE-1' LINE 01 DEPT NAME EMP# GROSS + +* Procedure declarations. +AT-START. PROC + DISPLAY 'PROCESSING...' +END-PROC + +AT-FINISH +PROC + DISPLAY 'DONE.' +END-PROC diff --git a/tests/test_lexers_other.py b/tests/test_lexers_other.py index 7936fe38..83330c90 100644 --- a/tests/test_lexers_other.py +++ b/tests/test_lexers_other.py @@ -39,10 +39,24 @@ class AnalyseTextTest(unittest.TestCase): exampleFile.close() def testCanRecognizeAndGuessExampleFiles(self): - self._testCanRecognizeAndGuessExampleFiles(EasytrieveLexer) - self._testCanRecognizeAndGuessExampleFiles(JclLexer) - self._testCanRecognizeAndGuessExampleFiles(RexxLexer) - self._testCanRecognizeAndGuessExampleFiles(WebFocusLexer) + LEXERS_TO_TEST = [ + EasytrieveLexer, + JclLexer, + RexxLexer, + ] + for lexerToTest in LEXERS_TO_TEST: + self._testCanRecognizeAndGuessExampleFiles(lexerToTest) + + +class EasyTrieveLexerTest(unittest.TestCase): + def testCanGuessFromText(self): + self.assertLess(0, EasytrieveLexer.analyse_text('MACRO')) + self.assertLess(0, EasytrieveLexer.analyse_text('\nMACRO')) + self.assertLess(0, EasytrieveLexer.analyse_text(' \nMACRO')) + self.assertLess(0, EasytrieveLexer.analyse_text(' \n MACRO')) + self.assertLess(0, EasytrieveLexer.analyse_text('*\nMACRO')) + self.assertLess(0, EasytrieveLexer.analyse_text( + '*\n *\n\n \n*\n MACRO')) class RexxLexerTest(unittest.TestCase): -- cgit v1.2.1 From bfe247e6d60733111dacdba25fd85b16c894b36b Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sun, 2 Jun 2013 14:43:21 +0200 Subject: Fixed example for JCL line continuation in comments. The continuation character now is properly placed in column 72. --- tests/examplefiles/example.jcl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/examplefiles/example.jcl b/tests/examplefiles/example.jcl index fb006369..18d4ae37 100644 --- a/tests/examplefiles/example.jcl +++ b/tests/examplefiles/example.jcl @@ -22,9 +22,10 @@ ham /* //SORTOUT DD SYSOUT=* /* -//* Test line continuation with comment at the end of a line +//* Test line continuation with comment at end of line continued by a +//* character at column 72 (in this case 'X'). //STP4 EXEC PROC=BILLING,COND.PAID=((20,LT),EVEN), // COND.LATE=(60,GT,FIND), -// COND.BILL=((20,GE),(30,LT,CHGE)) THIS STATEMENT CALLS X -// THE BILLING PROCEDURE AND SPECIFIES RETURN CODE TESTS X -// FOR THREE PROCEDURE STEPS. +// COND.BILL=((20,GE),(30,LT,CHGE)) THIS STATEMENT CALLS THE X +// BILLING PROCEDURE AND SPECIFIES RETURN CODE TESTS FOR THREEX +// PROCEDURE STEPS. -- cgit v1.2.1 From c3e40e23a69ca3f3e48ae48b0f95123261aa79df Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sun, 2 Jun 2013 20:00:51 +0200 Subject: Moved FOCUS related lexers to separate branch in order to simplify pyments.main pull request #169. --- pygments/lexers/_mapping.py | 4 - pygments/lexers/other.py | 323 +---------------------------------------- tests/examplefiles/example.acx | 3 - tests/examplefiles/example.fex | 225 ---------------------------- tests/examplefiles/example.mas | 21 --- tests/examplefiles/example.sty | 10 -- tests/test_basic_api.py | 5 +- tests/test_lexers_other.py | 4 +- 8 files changed, 6 insertions(+), 589 deletions(-) delete mode 100644 tests/examplefiles/example.acx delete mode 100644 tests/examplefiles/example.fex delete mode 100644 tests/examplefiles/example.mas delete mode 100644 tests/examplefiles/example.sty diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 4a94c5d9..f59a6955 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -111,9 +111,6 @@ LEXERS = { 'FancyLexer': ('pygments.lexers.agile', 'Fancy', ('fancy', 'fy'), ('*.fy', '*.fancypack'), ('text/x-fancysrc',)), 'FantomLexer': ('pygments.lexers.compiled', 'Fantom', ('fan',), ('*.fan',), ('application/x-fantom',)), 'FelixLexer': ('pygments.lexers.compiled', 'Felix', ('felix', 'flx'), ('*.flx', '*.flxh'), ('text/x-felix',)), - 'FocusAccessLexer': ('pygments.lexers.other', 'FOCUS access', ('focus-access',), ('*.acx',), ('text/x-focus-access',)), - 'FocusMasterLexer': ('pygments.lexers.other', 'FOCUS master', ('focus-master',), ('*.mas',), ('text/x-focus-master',)), - 'FocusStyleSheetLexer': ('pygments.lexers.other', 'FOCUS style sheet', ('focus-style',), ('*.sty',), ('text/x-focus-style',)), 'FortranLexer': ('pygments.lexers.compiled', 'Fortran', ('fortran',), ('*.f', '*.f90', '*.F', '*.F90'), ('text/x-fortran',)), 'FoxProLexer': ('pygments.lexers.foxpro', 'FoxPro', ('Clipper', 'XBase'), ('*.PRG', '*.prg'), ()), 'GLShaderLexer': ('pygments.lexers.compiled', 'GLSL', ('glsl',), ('*.vert', '*.frag', '*.geo'), ('text/x-glslsrc',)), @@ -303,7 +300,6 @@ LEXERS = { 'VerilogLexer': ('pygments.lexers.hdl', 'verilog', ('verilog', 'v'), ('*.v',), ('text/x-verilog',)), 'VhdlLexer': ('pygments.lexers.hdl', 'vhdl', ('vhdl',), ('*.vhdl', '*.vhd'), ('text/x-vhdl',)), 'VimLexer': ('pygments.lexers.text', 'VimL', ('vim',), ('*.vim', '.vimrc', '.exrc', '.gvimrc', '_vimrc', '_exrc', '_gvimrc', 'vimrc', 'gvimrc'), ('text/x-vim',)), - 'WebFocusLexer': ('pygments.lexers.other', 'WebFOCUS', ('webfocus', 'FOCUS', 'focus'), ('*.fex',), ('text/x-webfocus', 'text/x-focus')), 'XQueryLexer': ('pygments.lexers.web', 'XQuery', ('xquery', 'xqy', 'xq', 'xql', 'xqm'), ('*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm'), ('text/xquery', 'application/xquery')), 'XmlDjangoLexer': ('pygments.lexers.templates', 'XML+Django/Jinja', ('xml+django', 'xml+jinja'), (), ('application/xml+django', 'application/xml+jinja')), 'XmlErbLexer': ('pygments.lexers.templates', 'XML+Ruby', ('xml+erb', 'xml+ruby'), (), ('application/xml+ruby',)), diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py index 6c094c7e..6b181a64 100644 --- a/pygments/lexers/other.py +++ b/pygments/lexers/other.py @@ -38,8 +38,7 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer', 'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer', 'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer', 'CbmBasicV2Lexer', 'AutoItLexer', 'EasytrieveLexer', 'JclLexer', - 'RexxLexer', 'WebFocusLexer', 'FocusAccessLexer', - 'FocusMasterLexer', 'FocusStyleSheetLexer'] + 'RexxLexer'] class ECLLexer(RegexLexer): @@ -3939,326 +3938,6 @@ class JclLexer(RegexLexer): return result -class WebFocusLexer(RegexLexer): - """ - `(Web)FOCUS `_ is - a language for business intelligence applications. It enables to - describe, query and modify data from various sources including mainframe - platforms. It also includes FIDEL, a language to describe input forms. - - *New in Pygments 1.7.* - """ - name = 'WebFOCUS' - aliases = ['webfocus', 'FOCUS', 'focus'] - filenames = ['*.fex'] - mimetypes = ['text/x-webfocus', 'text/x-focus'] - flags = re.IGNORECASE - - # TODO: Consolidate rules common to 'focus' and 'dialog_manager' with 'include' or something. - # TODO: Find out if FIDEL supports "" to escape " and if so implement it. - # TODO: Add support for backslash escapes in single quote strings (and maybe double quote too?). - # TODO: Support dialog manager FIDEL input modifiers such as '.nodisplay'. - # TODO: Highlight function name after DEFINE FUNCTION. - # TODO: Highlight field name for all field types, not only numeric ones. - tokens = { - 'root': [ - (r'-\*.*\n', Comment.Single), - (r'-', Punctuation, 'dialog_manager'), - include('focus') - ], - 'focus': [ - (r'\n', Text, 'root'), - (r'\s*(across|add|alloc|as|by|clear|column-total|compute|count|' - r'crtform|decode|define|dynam|else|end|ex|exceeds|exec|file|' - r'filter|footing|for|format|free|heading|highest|hold|if|' - r'in-groups-of|in-ranges-of|join|list|lowest|match|modify|' - r'multilines|newpage|nomatch|noprint|nototal|on|over|' - r'page-break|print|printonly|ranked|recap|recompute|redefines|' - r'reject|row-total|rows|savb|save|set|sub-total|subfoot|' - r'subhead|subtotal|sum|summarize|tablef|table|the|then|tiles|' - r'total|update|when|where|with|within)\b', Keyword.Reserved), - (r'"', String, 'focus_fidel'), - (r'\b(missing)\b', Name.Constant), - (r'\b(asq|ave|cnt|ct|dst|fst|lst|max|min|pct|rcpt|st|sum|tot)\.', - Operator), - # FOCUS field declaration including display options. - (r'([a-z][a-z_0-9]*)([/])([adfip]*[0-9]+(\.[0-9]+)[-%bcdelmnrsty]*)', - bygroups(Name.Variable, Operator, Keyword.Type)), - # Rules common to 'focus' and 'dialog_manager'. - (r'\b(and|contains|div|eq|exceeds|excludes|from|ge|gt|in|' - r'includes|is-from|is-less-than|is-more-than|' - r'is-not-missing|is|le|like|lt|mod|ne|not-from|not|omits|or|to)\b', - Operator), - (r'[-+*/=|!]', Operator), - (r'[(){}<>;,]', Punctuation), - (r'[a-z_][a-z_0-9]*', Literal), - (r'&+[a-z_][a-z_0-9]*', Literal), - (r'[0-9]+\.[0-9]*', Number.Float), - (r'\.[0-9]+', Number.Float), - (r'[0-9]+', Number.Integer), - (r"'(''|[^'])*'", String), - (r'\s+', Whitespace) - ], - 'dialog_manager': [ - # Detect possible labels in first word of dialog manager line. - (r'\s*type\b', Keyword.Reserved, 'dialog_manager_type'), - (r':[a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), - (r'"', String, 'dialog_manager_fidel'), - # TODO: Get rid of redundant dialog manager keyword rule which - # already could be handled by the included - # 'dialog_manager_others'. However, we currently need it to not - # recognize classic labels without ':' too soon. - (r'\b(\?|close|cms|crtclear|crtform|default|defaults|else|exit|' - r'goto|htmlform|if|include|mvs|pass|prompt|quit|read|repeat|' - r'run|set|then|tso|type|window|write)\b', Keyword.Reserved, - 'dialog_manager_others'), - (r'[a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), - include('dialog_manager_others'), - ], - 'dialog_manager_others': [ - (r'\n', Text, 'root'), - (r'\s*type\b', Keyword.Reserved, 'dialog_manager_type'), - (r':[a-z_][a-z_0-9]*\s*\n', Name.Label, 'root'), - (r'\b(\?|close|cms|crtclear|crtform|default|defaults|else|exit|' - r'goto|htmlform|if|include|mvs|pass|prompt|quit|read|repeat|' - r'run|set|then|tso|type|window|write)\b', Keyword.Reserved), - # Rules common to 'focus' and 'dialog_manager'. - (r'\b(and|contains|div|eq|exceeds|excludes|from|ge|gt|in|' - r'includes|is|is-from|is-from|is-less-than|is-more-than|' - r'is-not-missing|le|like|lt|mod|ne|not|not-from|omits|or|to)\b', - Operator), - (r'[-+*/=|!]', Operator), - (r'[(){}<>;,]', Punctuation), - (r'[a-z_][a-z_0-9]*', Literal), - (r'&+[a-z_][a-z_0-9]*', Name.Variable), - (r'[0-9]+\.[0-9]*', Number.Float), - (r'\.[0-9]+', Number.Float), - (r'[0-9]+', Number.Integer), - (r"'(''|[^'])*'", String), - (r'\s+', Whitespace) - ], - 'dialog_manager_type': [ - # For -TYPE, render everything as ``String`` except variables. - (r'\n', Text, 'root'), - (r'&+[a-z_][a-z_0-9]*\.*', Name.Variable), - (r'[^&\n]+', String) - ], - 'dialog_manager_fidel': [ - (r'"', String, 'dialog_manager_fidel_end'), - (r'(<)(&[a-z][a-z_0-9]*)([/])([0-9]+)', - bygroups(Keyword.Reserved, Name.Variable, Operator, Number.Integer)), - (r'.', String) - ], - 'dialog_manager_fidel_end': [ - (r'\n', Text, 'root'), - (r'\s+', Whitespace) - ], - 'focus_fidel': [ - (r'"', String, 'focus_fidel_end'), - (r'&+[a-z][a-z_0-9]*', Name.Variable), - (r'\>', Keyword.Reserved), - # Line continuation. - (r'\<0x\s*\n', Keyword.Reserved), - (r'(<)([a-z][a-z_0-9]*)', - bygroups(Keyword.Reserved, Name.Variable)), - (r'(<)(\+|-|/)?([0-9]+)', - bygroups(Keyword.Reserved, Operator, Number.Integer)), - (r'.', String) - ], - 'focus_fidel_end': [ - (r'\n', Text, 'root'), - (r'\s+', Whitespace) - ] - } - - def analyse_text(text): - """ - Perform a heuristic analysis for certain very common WebFOCUS - constructs. - """ - result = 0.0 - hasComment = False - hasExec = False - hasInclude = False - hasSet = False - hasTableFile = False - - # Scan the source lines for indicators. - for line in text.lower().split('\n'): - if line.startswith('-'): - words = line[1:].split() - wordCount = len(words) - if wordCount > 0: - firstWord = words[0] - if firstWord.startswith('*'): - hasComment = True - elif wordCount > 1: - if firstWord == 'include': - hasInclude = True - elif (firstWord == 'set') and words[1].startswith('&'): - hasSet = True - else: - words = line.split() - wordCount = len(words) - if wordCount > 1: - if words[0] in ('ex', 'exec'): - hasExec = True - elif (words[0] in ('table', 'tablef')) \ - and (words[1] == 'file'): - hasTableFile = True - if hasComment: - result += 0.2 - if hasExec or hasInclude: - result += 0.1 - if hasTableFile: - result += 0.2 - if hasSet: - result += 0.1 - assert 0.0 <= result <= 1.0 - return result - - -class FocusMasterLexer(RegexLexer): - """ - FOCUS master files describes files and tables to be queried by FOCUS - programs. The are somewhat comparable to SQL ``create table`` statements. - - *New in Pygments 1.7.* - """ - name = 'FOCUS master' - aliases = ['focus-master'] - filenames = ['*.mas'] - mimetypes = ['text/x-focus-master'] - flags = re.IGNORECASE - - tokens = { - 'root': [ - (r'-\*.*\n', Comment.Single), - include('name'), - ], - 'name': [ - (r'\$.*\n', Comment.Single), - (r'\s+', Whitespace), - (r'[a-z_][a-z0-9_]*', Name.Builtin, 'before_value'), - (r'(\\)(\n)', bygroups(Operator, Text)), - ], - 'before_value': [ - (r'=', Punctuation, 'value'), - (r'\s+', Whitespace), - (r'.', Error, 'name') - ], - 'value': [ - (r'\$.*\n', Comment.Single, 'root'), - (r'\n', Text), - (r',', Punctuation, 'name'), - (r'\.!', Punctuation), - (r'"', String, 'string_double'), - (r'\'', String, 'string_single'), - (r'[a-z_][a-z0-9_]*', Text), - (r'[0-9]+(\.[0-9]+)?', Number), - (r'.', Text), - ], - 'string_double': [ - (r'""', String), - (r'"', String, 'value'), - (r'[^"]', String), - ], - 'string_single': [ - (r'\'\'', String), - (r'\'', String, 'value'), - (r'[^\']', String), - ], - } - - _HEADER_PATTERN = re.compile( - r'^((\s*\$.*)\n)*file(name)?\s*=\s*[a-z_][a-z0-9_]+\s*,(\s*(\$.*)\n)*\s*suffix\s*=\s*.+', - re.IGNORECASE - ) - - def analyse_text(text): - """ - Check for ``FILE=..., SUFFIX=...`` while ignoring comments starting with ``$``. - """ - result = 0.0 - - if FocusMasterLexer._HEADER_PATTERN.match(text): - result = 0.8 - - assert 0.0 <= result <= 1.0 - return result - - -class FocusAccessLexer(FocusMasterLexer): - """ - FOCUS access files associate segments in FOCUS master files with actual - tables containing data. - - *New in Pygments 1.7.* - """ - name = 'FOCUS access' - aliases = ['focus-access'] - filenames = ['*.acx'] - mimetypes = ['text/x-focus-access'] - - _HEADER_PATTERN = re.compile( - r'^((\s*\$.*)\n)*segment\s*=\s*[a-z_][a-z0-9_]+\s*,(\s*(\$.*)\n)*\s*tablename\s*=\s*.+', - re.IGNORECASE - ) - - def analyse_text(text): - """ - Check for ``SEGMENT=..., TABLENAME=...`` while ignoring comments - starting with ``$``. - """ - result = 0.0 - - if FocusAccessLexer._HEADER_PATTERN.match(text): - result = 0.8 - - assert 0.0 <= result <= 1.0 - return result - - -class FocusStyleSheetLexer(FocusMasterLexer): - """ - Style sheet to format reports written in FOCUS. - - *New in Pygments 1.7.* - """ - name = 'FOCUS style sheet' - aliases = ['focus-style'] - filenames = ['*.sty'] - mimetypes = ['text/x-focus-style'] - - _HEADER_TYPE_PATTERN = re.compile( - r'^(((\s*\$)|(-\*)).*\n)*type\s*=\s*[a-z]+\s*,.+', - re.IGNORECASE - ) - _HEADER_PAGE_DECLARATION_PATTERN = re.compile( - r'^(((\s*\$)|(-\*)).*\n)*(orientation|pagecolor|pagesize)\s*=\s*.+\s*,.+', - re.IGNORECASE - ) - - def analyse_text(text): - """ - Check for ``TYPE=...,...`` or page layout declaration while - ignoring comments starting with ``$`` or ``-*``. - """ - result = 0.0 - - if FocusStyleSheetLexer._HEADER_TYPE_PATTERN.match(text): - result = 0.7 - elif FocusStyleSheetLexer._HEADER_PAGE_DECLARATION_PATTERN.match(text): - result = 0.5 - if result > 0: - textStartsWithComment = text.startswith('-*') or text.lstrip().startswith('$') - if textStartsWithComment: - result += 0.2 - - assert 0.0 <= result <= 1.0 - return result - - class RexxLexer(RegexLexer): """ `Rexx `_ is a scripting language available for diff --git a/tests/examplefiles/example.acx b/tests/examplefiles/example.acx deleted file mode 100644 index ec80b9a2..00000000 --- a/tests/examplefiles/example.acx +++ /dev/null @@ -1,3 +0,0 @@ -$ Example FOCUS access file. -SEGNAME=CUSTOMERS, TABLENAME = "SOME"."CUSTOMERS", KEYS =1, - WRITE= NO, DBSPACE = SOME.WHERE0,$ diff --git a/tests/examplefiles/example.fex b/tests/examplefiles/example.fex deleted file mode 100644 index 92d0b0f6..00000000 --- a/tests/examplefiles/example.fex +++ /dev/null @@ -1,225 +0,0 @@ --* WebFOCUS test source file for pygments. - --* Some basic commands --TYPE hello world! --SET &NAME='John'; --TYPE hello &NAME ! --SET &DATETMP = DATECVT((DATEADD((DATECVT(&DATEIN, 'I8YYMD', 'YYMD')),'M', -6)),'YYMD','I8YYMD'); - --GOTO LABEL1; --TYPE Skip me - --* Label using classic syntax. --LABEL1 - --* Label using modern syntax. --:LABEL2 - --* Use FIDEL with MODIFY. -MODIFY FILE EMPLOYEE -CRTFORM - "EMPLOYEE UPDATE" - "EMPLOYEE ID #: : BANK, EMPLOYEES AND SALARIES " - "<10 . --HTMLFORM CSTERM --SET &ECHO = ALL; --* --* Replaces IDCAMS SYSIN --* -DYNAM ALLOC FILE CATCTL NEW RECFM FB - - LRECL 80 BLKSIZE 3120 SPACE 1,1 TRK REUSE --* --* Replaces IDCAMS SYSPRINT --* -DYNAM ALLOC FILE CATLST NEW RECFM VBA - - LRECL 125 BLKSIZE 27998 SPACE 2,1 TRK REUSE --* --* PRINT80 is a MFD used to read an 80 byte field named CONTENTS --* -DYNAM ALLOC FILE PRNT80 NEW RECFM FB - - LRECL 80 BLKSIZE 3120 SPACE 1,1 TRK REUSE --* --RUN --* --* Create the tape dataset name mask (first five nodes) --* --SET &CAT1 = ' LISTC LVL(' || '''' || -- 'PN0100.A143200.P87.P87800.STERM' || '''' || ') VOL'; --* --WRITE CATCTL &CAT1 --* --RUN --* --* Call the user written subroutine (i.e., GETCAT) to retrieve a list of tape datasets --* --SET &X = ' '; --SET &X = GETCAT(&X,'A1'); --* --* TABLE the catalog listing of tape datasets to a HOLD file --* -DEFINE FILE PRNT80 - DSNAME/A44 = SUBSTR (80,CONTENTS,1,44,44,'A44'); -END --* -TABLE FILE PRNT80 - PRINT DSNAME - ON TABLE HOLD -END --* -DYNAM FREE FILE CATCTL -DYNAM FREE FILE CATLST -DYNAM FREE FILE PRNT80 --* --RUN --* --*----------------------------------------------------------------------- --* --* Create the HTML drop down list --* -DEFINE FILE HOLD - NODE_POS/I3 = POSIT (DSNAME,44,'.SEM',4,'I3'); - WHATSEM/A4 = SUBSTR (44,DSNAME,NODE_POS+4,44,4,'A4'); - SEMWK/A2 = EDIT (WHATSEM,'$$99'); - SEMYR/A2 = EDIT (WHATSEM,'99$$'); - SEMESTERY2K/A6 = IF SEMYR LT '50' THEN ('20' | WHATSEM) - ELSE ('19' | WHATSEM); - D_SEM/A8 = DECODE SEMWK (03 'Spring' - 20 'Summer 1' - 26 'Summer 2' - 36 'Fall' - ELSE 'ERROR'); - SEMTXT/A16 = D_SEM | ' - ' | WHATSEM; --* Create the dynamic html for the drop down list - SEMESTER/A50 = ''; -END --* -TABLE FILE HOLD - SUM SEMESTER --* Want the most recent semester first - BY HIGHEST SEMESTERY2K NOPRINT - ON TABLE SET HOLDLIST PRINTONLY - ON TABLE HOLD AS HOLDSEMS -END --* --RUN --* --*----------------------------------------------------------------------- --* --SET &SPACE = '&' || 'nbsp;'; --* --* Display the HTML form to allow users to select semester/cycle --* --HTMLFORM CSTERM diff --git a/tests/examplefiles/example.mas b/tests/examplefiles/example.mas deleted file mode 100644 index fe653f07..00000000 --- a/tests/examplefiles/example.mas +++ /dev/null @@ -1,21 +0,0 @@ -$ Example FOCUS master file. -FILE=CENTGL, SUFFIX=FOC -SEGNAME=ACCOUNTS,SEGTYPE = S01 -FIELDNAME=GL_ACCOUNT, ALIAS=GLACCT, FORMAT=A7, - TITLE='Ledger,Account', FIELDTYPE=I, $ -FIELDNAME=GL_ACCOUNT_PARENT, ALIAS=GLPAR, FORMAT=A7, - TITLE=Parent, - PROPERTY=PARENT_OF, REFERENCE=GL_ACCOUNT, $ -FIELDNAME=GL_ACCOUNT_TYPE, ALIAS=GLTYPE, FORMAT=A1, - TITLE=Type,$ - -FIELDNAME=GL_ROLLUP_OP, ALIAS=GLROLL, FORMAT=A1, - TITLE=Op, $ Some comment. -FIELDNAME=GL_ACCOUNT_LEVEL, ALIAS=GLLEVEL, FORMAT=I3, - TITLE=Lev, $ - $ Another comment. -FIELDNAME=GL_ACCOUNT_CAPTION, ALIAS=GLCAP, FORMAT=A30, - TITLE=Caption, - PROPERTY=CAPTION, REFERENCE=GL_ACCOUNT, $ -FIELDNAME=SYS_ACCOUNT, ALIAS=ALINE, FORMAT=A6, - TITLE='System,Account,Line', MISSING=ON, $ diff --git a/tests/examplefiles/example.sty b/tests/examplefiles/example.sty deleted file mode 100644 index 0c113d0f..00000000 --- a/tests/examplefiles/example.sty +++ /dev/null @@ -1,10 +0,0 @@ -$ Example WebFOCUS style sheet. --* A FOCUS comment. -TYPE=REPORT, PAGESIZE=A4, Orientation = LANDSCAPE, $ -TYPE=HEADING, FONT='Helvetica', - SIZE=14, STYLE=BOLD, $ another comment - -PAGECOLOR=blue, $ - -TYPE=HEADING, OBJECT=TEXT, ITEM=2, COLOR=BLUE, SIZE=12, - STYLE=BOLD+UNDERLINE, $ diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py index 18ed8d64..19e1988b 100644 --- a/tests/test_basic_api.py +++ b/tests/test_basic_api.py @@ -60,7 +60,10 @@ def test_lexer_classes(): if cls.name in ['XQuery', 'Opa']: # XXX temporary return - tokens = list(inst.get_tokens(test_content)) + try: + tokens = list(inst.get_tokens(test_content)) + except KeyboardInterrupt: + raise KeyboardInterrupt('interrupted %s.get_tokens(): test_content=%r' % (cls.__name__, test_content)) txt = "" for token in tokens: assert isinstance(token, tuple) diff --git a/tests/test_lexers_other.py b/tests/test_lexers_other.py index 83330c90..1c8604bb 100644 --- a/tests/test_lexers_other.py +++ b/tests/test_lexers_other.py @@ -11,9 +11,7 @@ import os import unittest from pygments.lexers import guess_lexer -from pygments.lexers.other import EasytrieveLexer, JclLexer, RexxLexer, \ - WebFocusLexer - +from pygments.lexers.other import EasytrieveLexer, JclLexer, RexxLexer def _exampleFilePath(filename): return os.path.join(os.path.dirname(__file__), 'examplefiles', filename) -- cgit v1.2.1 From ab4ebd8a63601dac49d7172bc2576a411c975524 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sun, 2 Jun 2013 20:33:57 +0200 Subject: Reverted code already submitted in pull request #207. --- tests/test_basic_api.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py index 19e1988b..18ed8d64 100644 --- a/tests/test_basic_api.py +++ b/tests/test_basic_api.py @@ -60,10 +60,7 @@ def test_lexer_classes(): if cls.name in ['XQuery', 'Opa']: # XXX temporary return - try: - tokens = list(inst.get_tokens(test_content)) - except KeyboardInterrupt: - raise KeyboardInterrupt('interrupted %s.get_tokens(): test_content=%r' % (cls.__name__, test_content)) + tokens = list(inst.get_tokens(test_content)) txt = "" for token in tokens: assert isinstance(token, tuple) -- cgit v1.2.1 From ca8974329cc95a0d2eedc9948ed7030704557118 Mon Sep 17 00:00:00 2001 From: Thomas Aglassinger Date: Sun, 2 Jun 2013 20:35:58 +0200 Subject: Removed mention of FOCUS as it submitted in a separate pull request. --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index f4ac499b..045eb9a6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -7,7 +7,7 @@ Other contributors, listed alphabetically, are: * Sam Aaron -- Ioke lexer * Ali Afshar -- image formatter -* Thomas Aglassinger -- Easytrieve, FOCUS, JCL and Rexx lexers +* Thomas Aglassinger -- Easytrieve, JCL and Rexx lexers * Kumar Appaiah -- Debian control lexer * Andreas Amann -- AppleScript lexer * Timothy Armstrong -- Dart lexer fixes -- cgit v1.2.1 From 62ed942986ae720e1df237c7d96700e93a2aaa11 Mon Sep 17 00:00:00 2001 From: Elias Rabel Date: Sun, 23 Jun 2013 17:22:02 +0200 Subject: Added Fortran fixed format lexer. --- AUTHORS | 1 + pygments/lexers/_mapping.py | 3 +- pygments/lexers/compiled.py | 46 +++++- tests/examplefiles/ahcon.f | 340 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 387 insertions(+), 3 deletions(-) create mode 100644 tests/examplefiles/ahcon.f diff --git a/AUTHORS b/AUTHORS index 1c4a9992..a6d9e986 100644 --- a/AUTHORS +++ b/AUTHORS @@ -112,6 +112,7 @@ Other contributors, listed alphabetically, are: * Benjamin Peterson -- Test suite refactoring * Dominik Picheta -- Nimrod lexer * Clément Prévost -- UrbiScript lexer +* Elias Rabel -- Fortran fixed form lexer * Kashif Rasul -- CUDA lexer * Justin Reidy -- MXML lexer * Norman Richards -- JSON lexer diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 969bdba5..aeefb444 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -110,7 +110,8 @@ LEXERS = { 'FancyLexer': ('pygments.lexers.agile', 'Fancy', ('fancy', 'fy'), ('*.fy', '*.fancypack'), ('text/x-fancysrc',)), 'FantomLexer': ('pygments.lexers.compiled', 'Fantom', ('fan',), ('*.fan',), ('application/x-fantom',)), 'FelixLexer': ('pygments.lexers.compiled', 'Felix', ('felix', 'flx'), ('*.flx', '*.flxh'), ('text/x-felix',)), - 'FortranLexer': ('pygments.lexers.compiled', 'Fortran', ('fortran',), ('*.f', '*.f90', '*.F', '*.F90'), ('text/x-fortran',)), + 'FortranFixedLexer': ('pygments.lexers.compiled', 'FortranFixed', ('fortranfixed',), ('*.f', '*.F'), ()), + 'FortranLexer': ('pygments.lexers.compiled', 'Fortran', ('fortran',), ('*.f90', '*.F90', '*.f03', '*.F03'), ('text/x-fortran',)), 'FoxProLexer': ('pygments.lexers.foxpro', 'FoxPro', ('Clipper', 'XBase'), ('*.PRG', '*.prg'), ()), 'GLShaderLexer': ('pygments.lexers.compiled', 'GLSL', ('glsl',), ('*.vert', '*.frag', '*.geo'), ('text/x-glslsrc',)), 'GasLexer': ('pygments.lexers.asm', 'GAS', ('gas', 'asm'), ('*.s', '*.S'), ('text/x-gas',)), diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index 75ace35e..7c0a551a 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -25,7 +25,8 @@ from pygments.lexers.jvm import JavaLexer, ScalaLexer __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer', 'NesCLexer', 'DylanLexer', 'ObjectiveCLexer', 'ObjectiveCppLexer', - 'FortranLexer', 'GLShaderLexer', 'PrologLexer', 'CythonLexer', + 'FortranLexer', 'FortranFixedLexer', 'GLShaderLexer', + 'PrologLexer', 'CythonLexer', 'ValaLexer', 'OocLexer', 'GoLexer', 'FelixLexer', 'AdaLexer', 'Modula2Lexer', 'BlitzMaxLexer', 'BlitzBasicLexer', 'NimrodLexer', 'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer', 'SwigLexer', @@ -1440,7 +1441,7 @@ class FortranLexer(RegexLexer): """ name = 'Fortran' aliases = ['fortran'] - filenames = ['*.f', '*.f90', '*.F', '*.F90'] + filenames = ['*.f90', '*.F90', '*.f03', '*.F03'] mimetypes = ['text/x-fortran'] flags = re.IGNORECASE @@ -1546,6 +1547,47 @@ class FortranLexer(RegexLexer): ], } +class FortranFixedLexer(RegexLexer): + """ + Lexer for fixed format Fortran. + """ + name = 'FortranFixed' + aliases = ['fortranfixed'] + filenames = ['*.f', '*.F'] + + flags = re.IGNORECASE + + def _lex_fortran(self, match, ctx=None): + """Lex a line just as free form fortran without line break.""" + lexer = FortranLexer() + text = match.group(0) + "\n" + for index, token, value in lexer.get_tokens_unprocessed(text): + value = value.replace('\n','') + if value != '': + yield index, token, value + + tokens = { + 'root': [ + (r'[C*].*\n', Comment), + (r'#.*\n', Comment.Preproc), + (r' {0,4}!.*\n', Comment), + (r'(.{5})', Name.Label, 'cont-char'), + (r'.*\n', using(FortranLexer)), + ], + + 'cont-char': [ + (' ', Text, 'code'), + ('0', Comment, 'code'), + ('.', Generic.Strong, 'code') + ], + + 'code' : [ + (r'(.{66})(.*)(\n)', + bygroups(_lex_fortran, Comment, Text), 'root'), + (r'(.*)(\n)', bygroups(_lex_fortran, Text), 'root'), + (r'', Text, 'root')] + } + class GLShaderLexer(RegexLexer): """ diff --git a/tests/examplefiles/ahcon.f b/tests/examplefiles/ahcon.f new file mode 100644 index 00000000..48ae920b --- /dev/null +++ b/tests/examplefiles/ahcon.f @@ -0,0 +1,340 @@ + SUBROUTINE AHCON (SIZE,N,M,A,B,OLEVR,OLEVI,CLEVR,CLEVI, TRUNCATED + & SCR1,SCR2,IPVT,JPVT,CON,WORK,ISEED,IERR) !Test inline comment +C +C FUNCTION: +CF +CF Determines whether the pair (A,B) is controllable and flags +CF the eigenvalues corresponding to uncontrollable modes. +CF this ad-hoc controllability calculation uses a random matrix F +CF and computes whether eigenvalues move from A to the controlled +CF system A+B*F. +CF +C USAGE: +CU +CU CALL AHCON (SIZE,N,M,A,B,OLEVR,OLEVI,CLEVR,CLEVI,SCR1,SCR2,IPVT, +CU JPVT,CON,WORK,ISEED,IERR) +CU +CU since AHCON generates different random F matrices for each +CU call, as long as iseed is not re-initialized by the main +CU program, and since this code has the potential to be fooled +CU by extremely ill-conditioned problems, the cautious user +CU may wish to call it multiple times and rely, perhaps, on +CU a 2-of-3 vote. We believe, but have not proved, that any +CU errors this routine may produce are conservative--i.e., that +CU it may flag a controllable mode as uncontrollable, but +CU not vice-versa. +CU +C INPUTS: +CI +CI SIZE integer - first dimension of all 2-d arrays. +CI +CI N integer - number of states. +CI +CI M integer - number of inputs. +CI +CI A double precision - SIZE by N array containing the +CI N by N system dynamics matrix A. +CI +CI B double precision - SIZE by M array containing the +CI N by M system input matrix B. +CI +CI ISEED initial seed for random number generator; if ISEED=0, +CI then AHCON will set ISEED to a legal value. +CI +C OUTPUTS: +CO +CO OLEVR double precision - N dimensional vector containing the +CO real parts of the eigenvalues of A. +CO +CO OLEVI double precision - N dimensional vector containing the +CO imaginary parts of the eigenvalues of A. +CO +CO CLEVR double precision - N dimensional vector work space +CO containing the real parts of the eigenvalues of A+B*F, +CO where F is the random matrix. +CO +CO CLEVI double precision - N dimensional vector work space +CO containing the imaginary parts of the eigenvalues of +CO A+B*F, where F is the random matrix. +CO +CO SCR1 double precision - N dimensional vector containing the +CO magnitudes of the corresponding eigenvalues of A. +CO +CO SCR2 double precision - N dimensional vector containing the +CO damping factors of the corresponding eigenvalues of A. +CO +CO IPVT integer - N dimensional vector; contains the row pivots +CO used in finding the nearest neighbor eigenvalues between +CO those of A and of A+B*F. The IPVT(1)th eigenvalue of +CO A and the JPVT(1)th eigenvalue of A+B*F are the closest +CO pair. +CO +CO JPVT integer - N dimensional vector; contains the column +CO pivots used in finding the nearest neighbor eigenvalues; +CO see IPVT. +CO +CO CON logical - N dimensional vector; flagging the uncontrollable +CO modes of the system. CON(I)=.TRUE. implies the +CO eigenvalue of A given by DCMPLX(OLEVR(IPVT(I)),OLEVI(IPVT(i))) +CO corresponds to a controllable mode; CON(I)=.FALSE. +CO implies an uncontrollable mode for that eigenvalue. +CO +CO WORK double precision - SIZE by N dimensional array containing +CO an N by N matrix. WORK(I,J) is the distance between +CO the open loop eigenvalue given by DCMPLX(OLEVR(I),OLEVI(I)) +CO and the closed loop eigenvalue of A+B*F given by +CO DCMPLX(CLEVR(J),CLEVI(J)). +CO +CO IERR integer - IERR=0 indicates normal return; a non-zero +CO value indicates trouble in the eigenvalue calculation. +CO see the EISPACK and EIGEN documentation for details. +CO +C ALGORITHM: +CA +CA Calculate eigenvalues of A and of A+B*F for a randomly +CA generated F, and see which ones change. Use a full pivot +CA search through a matrix of euclidean distance measures +CA between each pair of eigenvalues from (A,A+BF) to +CA determine the closest pairs. +CA +C MACHINE DEPENDENCIES: +CM +CM NONE +CM +C HISTORY: +CH +CH written by: Birdwell & Laub +CH date: May 18, 1985 +CH current version: 1.0 +CH modifications: made machine independent and modified for +CH f77:bb:8-86. +CH changed cmplx -> dcmplx: 7/27/88 jdb +CH +C ROUTINES CALLED: +CC +CC EIGEN,RAND +CC +C COMMON MEMORY USED: +CM +CM none +CM +C---------------------------------------------------------------------- +C written for: The CASCADE Project +C Oak Ridge National Laboratory +C U.S. Department of Energy +C contract number DE-AC05-840R21400 +C subcontract number 37B-7685 S13 +C organization: The University of Tennessee +C---------------------------------------------------------------------- +C THIS SOFTWARE IS IN THE PUBLIC DOMAIN +C NO RESTRICTIONS ON ITS USE ARE IMPLIED +C---------------------------------------------------------------------- +C +C--global variables: +C + INTEGER SIZE + INTEGER N + INTEGER M + INTEGER IPVT(1) + INTEGER JPVT(1) + INTEGER IERR +C + DOUBLE PRECISION A(SIZE,N) + DOUBLE PRECISION B(SIZE,M) + DOUBLE PRECISION WORK(SIZE,N) + DOUBLE PRECISION CLEVR(N) + DOUBLE PRECISION CLEVI(N) + DOUBLE PRECISION OLEVR(N) + DOUBLE PRECISION OLEVI(N) + DOUBLE PRECISION SCR1(N) + DOUBLE PRECISION SCR2(N) +C + LOGICAL CON(N) +C +C--local variables: +C + INTEGER ISEED + INTEGER ITEMP + INTEGER K1 + INTEGER K2 + INTEGER I + INTEGER J + INTEGER K + INTEGER IMAX + INTEGER JMAX +C + DOUBLE PRECISION VALUE + DOUBLE PRECISION EPS + DOUBLE PRECISION EPS1 + DOUBLE PRECISION TEMP + DOUBLE PRECISION CURR + DOUBLE PRECISION ANORM + DOUBLE PRECISION BNORM + DOUBLE PRECISION COLNRM + DOUBLE PRECISION RNDMNO +C + DOUBLE COMPLEX DCMPLX +C +C--compute machine epsilon +C + EPS = 1.D0 +100 CONTINUE + EPS = EPS / 2.D0 + EPS1 = 1.D0 + EPS + IF (EPS1 .NE. 1.D0) GO TO 100 + EPS = EPS * 2.D0 +C +C--compute the l-1 norm of a +C + ANORM = 0.0D0 + DO 120 J = 1, N + COLNRM = 0.D0 + DO 110 I = 1, N + COLNRM = COLNRM + ABS(A(I,J)) +110 CONTINUE + IF (COLNRM .GT. ANORM) ANORM = COLNRM +120 CONTINUE +C +C--compute the l-1 norm of b +C + BNORM = 0.0D0 + DO 140 J = 1, M + COLNRM = 0.D0 + DO 130 I = 1, N + COLNRM = COLNRM + ABS(B(I,J)) +130 CONTINUE + IF (COLNRM .GT. BNORM) BNORM = COLNRM +140 CONTINUE +C +C--compute a + b * f +C + DO 160 J = 1, N + DO 150 I = 1, N + WORK(I,J) = A(I,J) +150 CONTINUE +160 CONTINUE +C +C--the elements of f are random with uniform distribution +C--from -anorm/bnorm to +anorm/bnorm +C--note that f is not explicitly stored as a matrix +C--pathalogical floating point notes: the if (bnorm .gt. 0.d0) +C--test should actually be if (bnorm .gt. dsmall), where dsmall +C--is the smallest representable number whose reciprocal does +C--not generate an overflow or loss of precision. +C + IF (ISEED .EQ. 0) ISEED = 86345823 + IF (ANORM .EQ. 0.D0) ANORM = 1.D0 + IF (BNORM .GT. 0.D0) THEN + TEMP = 2.D0 * ANORM / BNORM + ELSE + TEMP = 2.D0 + END IF + DO 190 K = 1, M + DO 180 J = 1, N + CALL RAND(ISEED,ISEED,RNDMNO) + VALUE = (RNDMNO - 0.5D0) * TEMP + DO 170 I = 1, N + WORK(I,J) = WORK(I,J) + B(I,K)*VALUE +170 CONTINUE +180 CONTINUE +190 CONTINUE +C +C--compute the eigenvalues of a + b*f, and several other things +C + CALL EIGEN (0,SIZE,N,WORK,CLEVR,CLEVI,WORK,SCR1,SCR2,IERR) + IF (IERR .NE. 0) RETURN +C +C--copy a so it is not destroyed +C + DO 210 J = 1, N + DO 200 I = 1, N + WORK(I,J) = A(I,J) +200 CONTINUE +210 CONTINUE +C +C--compute the eigenvalues of a, and several other things +C + CALL EIGEN (0,SIZE,N,WORK,OLEVR,OLEVI,WORK,SCR1,SCR2,IERR) + IF (IERR .NE. 0) RETURN +C +C--form the matrix of distances between eigenvalues of a and +C--EIGENVALUES OF A+B*F +C + DO 230 J = 1, N + DO 220 I = 1, N + WORK(I,J) = + & ABS(DCMPLX(OLEVR(I),OLEVI(I))-DCMPLX(CLEVR(J),CLEVI(J))) +220 CONTINUE +230 CONTINUE +C +C--initialize row and column pivots +C + DO 240 I = 1, N + IPVT(I) = I + JPVT(I) = I +240 CONTINUE +C +C--a little bit messy to avoid swapping columns and +C--rows of work +C + DO 270 I = 1, N-1 +C +C--find the minimum element of each lower right square +C--submatrix of work, for submatrices of size n x n +C--through 2 x 2 +C + CURR = WORK(IPVT(I),JPVT(I)) + IMAX = I + JMAX = I + TEMP = CURR +C +C--find the minimum element +C + DO 260 K1 = I, N + DO 250 K2 = I, N + IF (WORK(IPVT(K1),JPVT(K2)) .LT. TEMP) THEN + TEMP = WORK(IPVT(K1),JPVT(K2)) + IMAX = K1 + JMAX = K2 + END IF +250 CONTINUE +260 CONTINUE +C +C--update row and column pivots for indirect addressing of work +C + ITEMP = IPVT(I) + IPVT(I) = IPVT(IMAX) + IPVT(IMAX) = ITEMP +C + ITEMP = JPVT(I) + JPVT(I) = JPVT(JMAX) + JPVT(JMAX) = ITEMP +C +C--do next submatrix +C +270 CONTINUE +C +C--this threshold for determining when an eigenvalue has +C--not moved, and is therefore uncontrollable, is critical, +C--and may require future changes with more experience. +C + EPS1 = SQRT(EPS) +C +C--for each eigenvalue pair, decide if it is controllable +C + DO 280 I = 1, N +C +C--note that we are working with the "pivoted" work matrix +C--and are looking at its diagonal elements +C + IF (WORK(IPVT(I),JPVT(I))/ANORM .LE. EPS1) THEN + CON(I) = .FALSE. + ELSE + CON(I) = .TRUE. + END IF +280 CONTINUE +C +C--finally! +C + RETURN + END -- cgit v1.2.1 From 38b6a0a59123cee5db94adcf961331ad8b24c840 Mon Sep 17 00:00:00 2001 From: Justin Hendrick Date: Mon, 7 Jul 2014 14:02:01 -0400 Subject: Added very basic ParaSail lexer --- pygments/lexers/_mapping.py | 1 + pygments/lexers/compiled.py | 58 +++++++++++++++-- tests/examplefiles/test.psl | 151 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 6 deletions(-) create mode 100644 tests/examplefiles/test.psl diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index f8454357..9953ae71 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -251,6 +251,7 @@ LEXERS = { 'OpaLexer': ('pygments.lexers.functional', 'Opa', ('opa',), ('*.opa',), ('text/x-opa',)), 'OpenEdgeLexer': ('pygments.lexers.other', 'OpenEdge ABL', ('openedge', 'abl', 'progress'), ('*.p', '*.cls'), ('text/x-openedge', 'application/x-openedge')), 'PanLexer': ('pygments.lexers.other', 'Pan', ('pan',), ('*.pan',), ()), + 'ParaSailLexer': ('pygments.lexers.compiled', 'ParaSail', ('parasail',), ('*.psi', '*.psl'), ('text/x-parasail',)), 'PawnLexer': ('pygments.lexers.other', 'Pawn', ('pawn',), ('*.p', '*.pwn', '*.inc'), ('text/x-pawn',)), 'Perl6Lexer': ('pygments.lexers.agile', 'Perl6', ('perl6', 'pl6'), ('*.pl', '*.pm', '*.nqp', '*.p6', '*.6pl', '*.p6l', '*.pl6', '*.6pm', '*.p6m', '*.pm6', '*.t'), ('text/x-perl6', 'application/x-perl6')), 'PerlLexer': ('pygments.lexers.agile', 'Perl', ('perl', 'pl'), ('*.pl', '*.pm', '*.t'), ('text/x-perl', 'application/x-perl')), diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index 25c7a4d8..dc9b7d50 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -27,12 +27,12 @@ __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer', 'NesCLexer', 'DylanLexer', 'ObjectiveCLexer', 'ObjectiveCppLexer', 'FortranLexer', 'GLShaderLexer', 'PrologLexer', 'CythonLexer', 'ValaLexer', 'OocLexer', 'GoLexer', 'FelixLexer', 'AdaLexer', - 'Modula2Lexer', 'BlitzMaxLexer', 'BlitzBasicLexer', 'NimrodLexer', - 'FantomLexer', 'RustLexer', 'CudaLexer', 'MonkeyLexer', 'SwigLexer', - 'DylanLidLexer', 'DylanConsoleLexer', 'CobolLexer', - 'CobolFreeformatLexer', 'LogosLexer', 'ClayLexer', 'PikeLexer', - 'ChapelLexer', 'EiffelLexer', 'Inform6Lexer', 'Inform7Lexer', - 'Inform6TemplateLexer', 'MqlLexer', 'SwiftLexer'] + 'ParaSailLexer', 'Modula2Lexer', 'BlitzMaxLexer', 'BlitzBasicLexer', + 'NimrodLexer', 'FantomLexer', 'RustLexer', 'CudaLexer', + 'MonkeyLexer', 'SwigLexer', 'DylanLidLexer', 'DylanConsoleLexer', + 'CobolLexer', 'CobolFreeformatLexer', 'LogosLexer', 'ClayLexer', + 'PikeLexer', 'ChapelLexer', 'EiffelLexer', 'Inform6Lexer', + 'Inform7Lexer', 'Inform6TemplateLexer', 'MqlLexer', 'SwiftLexer'] class CFamilyLexer(RegexLexer): @@ -2560,6 +2560,52 @@ class AdaLexer(RegexLexer): ], } +class ParaSailLexer(RegexLexer): + """ + For ParaSail source code. + + .. versionadded:: TODO + """ + + name = 'ParaSail' + aliases = ['parasail'] + filenames = ['*.psi', '*.psl'] + mimetypes = ['text/x-parasail'] + + flags = re.MULTILINE + + tokens = { + 'root': [ + (r'[^\S\n]+', Text), + (r'//.*?\n', Comment.Single), + (r'[^\S\n]+', Text), + (r'abstract', Keyword.Declaration), + (r'(interface|class)', Keyword.Declaration), + (r'\b(abs|abstract|all|and|block|concurrent|const|continue|each|' + r'end|exit|extends|exports|forward|func|global|implements|in|' + r'interface|import|class|is|and=|or=|xor=' + r'lambda|locked|mod|new|not|null|of|optional|op|or|private|queued|' + r'ref|rem|return|reverse|seperate|some|type|until|var|with|xor|if|' + r'then|else|elsif|case|for|while|loop)\b', + Keyword.Reserved), + (r'"[^"]*"', String), + include('numbers'), + (r'#[a-zA-Z][_a-zA-Z]*', Keyword.Constant), + (r"'[^']'", String.Character), + (r'([a-zA-Z0-9_]+)', Name), + (r'(<|>|:=|\[|\]|\(|\)|\||:|;|,|.|\{|\})' + , Punctuation), + (r'(<==|==>|<=>|\*\*=|<\|=|<<=|>>=|==|!=|=\?|<=|>=|' + r'\*\*|<<|>>|=>|:=|\+=|-=|\*=|\||\|=|/=|->|\+|-|\*|/)', Operator), + (r'\n+', Text), + ], + 'numbers' : [ + (r'[0-9_]+#[0-9a-fA-F]+#', Number.Hex), + (r'0x[0-9a-fA-F]+', Number.Hex), + (r'[0-9_]+\.[0-9_]*', Number.Float), + (r'[0-9_]+', Number.Integer), + ], + } class Modula2Lexer(RegexLexer): """ diff --git a/tests/examplefiles/test.psl b/tests/examplefiles/test.psl new file mode 100644 index 00000000..ee427843 --- /dev/null +++ b/tests/examplefiles/test.psl @@ -0,0 +1,151 @@ +// This is a comment + +// 1. Basics + +// Functions +func Add(X : Univ_Integer; Y : Univ_Integer) -> Univ_Integer is + // End of line semi-colons are optional + return X + Y; +end func Add; + +// If you find Univ_Integer to be too verbose you can import Short_Names +// which defines aliases like Int for Univ_Integer and String for Univ_String +import PSL::Short_Names::*, * + +func Greetings() is + // All declarations are 'const', 'var', or 'ref' + const S : String := "Hello, World!" + Println(S) +end func Greetings + +func Fib(N : Int) {N >= 0} -> Int is + // '{N >= 0}' is a precondition to this function + // Preconditions are built in to the language and checked by the compiler + if N <= 1 then + return N + else + // Left and right side of '+' are computed in Parallel here + return Fib(N - 1) + Fib(N - 2) + end if +end func Fib + +// ParaSail does not have mutable global variables +// Instead, use 'var' parameters +func Increment_All(var Nums : Vector) is + // This function takes a 'var' parameter. + // The modifications made here will be seen by caller + for each Elem of Nums concurrent loop + // The 'concurrent' keyword tells the compiler that + // iterations of the loop can happen in any order. + // It will choose the most optimal number of picothreads to use. + // Other options are 'forward' and 'reverse'. + Elem += 1 + end loop +end func Increment_All + +func Sum_Of_Squares(N : Int) -> Int is + // Built-in and inherently parallel map-reduce + // Initial value is enclosed with angle brackets + return (for I in 1 .. N => <0> + I ** 2) +end func Sum_Of_Squares + +func Sum_Of(N : Int; F : func (Int) -> Int) -> Int is + // It has functional aspects as well + // Here, we're taking an (Int) -> Int function as a parameter + return (for I in 1 .. N => <0> + F(I)) +end func Sum_Of + +func main(Args : Basic_Array) is + Greetings() + Println(Fib(5)); + var Vec : Vector := [0, 1, 2] + Increment_All(Vec) + // '|' is an overloaded operator. Here used for building strings + Println(Vec[1] | ", " | Vec[2] | ", " | Vec[3]) + Println(Sum_Of_Squares(3)) + + // Sum of fibs! + Println(Sum_Of(10, Fib)) +end func main + +// Preceding a type with 'optional' allows it to take the value 'null' +func Divide(A, B : Int) -> optional Int is + if B == 0 then + return null; + else + return A / B; + end if; +end func Divide; + +// 2. Modules +// Modules are composed of an interface and a class +// ParaSail has object orientation + +concurrent interface Locked_Box> is + // Create a box with the given content + func Create(C : optional Content_Type) -> Locked_Box; + + // Put something into the box + func Put(locked var B : Locked_Box; C : Content_Type); + + // Get a copy of current content + func Content(locked B : Locked_Box) -> optional Content_Type; + + // Remove current content, leaving it null + func Remove(locked var B : Locked_Box) -> optional Content_Type; + + // Wait until content is non-null, then return it, leaving it null. + func Get(queued var B : Locked_Box) -> Content_Type; +end interface Locked_Box; + +concurrent class Locked_Box is + var Content : optional Content_Type; + exports + func Create(C : optional Content_Type) -> Locked_Box is + return (Content => C); + end func Create; + + func Put(locked var B : Locked_Box; C : Content_Type) is + B.Content := C; + end func Put; + + func Content(locked B : Locked_Box) -> optional Content_Type is + return B.Content; + end func Content; + + func Remove(locked var B : Locked_Box) -> Result : optional Content_Type is + // '<==' is the move operator + // It moves the right operand into the left operand, + // leaving the right null. + Result <== B.Content; + end func Remove; + + func Get(queued var B : Locked_Box) -> Result : Content_Type is + queued until B.Content not null then + Result <== B.Content; + end func Get; +end class Locked_Box; + +func Use_Box(Seed : Univ_Integer) is + var U_Box : Locked_Box := Create(null); + // Type Inference. The type of 'Ran' can be left out because + // it is inferred from the return type of Random::Start + var Ran := Random::Start(Seed); + + Println("Starting 100 pico-threads trying to put something in the box"); + Println(" or take something out."); + for I in 1..100 concurrent loop + if I < 30 then + Println("Getting out " | Get(U_Box)); + else + Println("Putting in " | I); + U_Box.Put(I); + + // The first parameter can be moved to the front with a dot + // X.Foo(Y) is equivalent to Foo(X, Y) + end if; + end loop; + + Println("And the winner is: " | Remove(U_Box)); + Println("And the box is now " | Content(U_Box)); +end func Use_Box; -- cgit v1.2.1 From ce0b8f96d87f0d20401a76733d15d415b973c0ce Mon Sep 17 00:00:00 2001 From: Justin Hendrick Date: Tue, 8 Jul 2014 11:19:42 -0400 Subject: ParaSail Lexer: Fix operators and numbers. Reorganize keywords. Link to website --- pygments/lexers/compiled.py | 50 ++++++++----- tests/examplefiles/test.psl | 175 +++++++++++++++++++++++++------------------- 2 files changed, 131 insertions(+), 94 deletions(-) diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index dc9b7d50..55b12109 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -2562,7 +2562,7 @@ class AdaLexer(RegexLexer): class ParaSailLexer(RegexLexer): """ - For ParaSail source code. + For `ParaSail `_ source code. .. versionadded:: TODO """ @@ -2578,32 +2578,42 @@ class ParaSailLexer(RegexLexer): 'root': [ (r'[^\S\n]+', Text), (r'//.*?\n', Comment.Single), - (r'[^\S\n]+', Text), - (r'abstract', Keyword.Declaration), - (r'(interface|class)', Keyword.Declaration), - (r'\b(abs|abstract|all|and|block|concurrent|const|continue|each|' - r'end|exit|extends|exports|forward|func|global|implements|in|' - r'interface|import|class|is|and=|or=|xor=' - r'lambda|locked|mod|new|not|null|of|optional|op|or|private|queued|' - r'ref|rem|return|reverse|seperate|some|type|until|var|with|xor|if|' - r'then|else|elsif|case|for|while|loop)\b', + # matching and=, or=, and xor= doesn't work yet + (r'\b(and(=|\sthen)?|or(=|\selse)?|xor=?|rem|mod|' + r'(is|not)\snull)\b', + Operator.Word), + # Keywords + (r'\b(abs|abstract|all|block|class|concurrent|const|continue|' + r'each|end|exit|extends|exports|forward|func|global|implements|' + r'import|in|interface|is|lambda|locked|new|not|null|of|op|' + r'optional|private|queued|ref|return|reverse|separate|some|' + r'type|until|var|with|' + # Control flow + r'if|then|else|elsif|case|for|while|loop)\b', Keyword.Reserved), + (r'[abstract]?(interface|class|op|func|type)', Keyword.Declaration), (r'"[^"]*"', String), + (r'\\[\'ntrf"0]', String.Escape), + (r'#[a-zA-Z]\w*', Literal), include('numbers'), - (r'#[a-zA-Z][_a-zA-Z]*', Keyword.Constant), - (r"'[^']'", String.Character), - (r'([a-zA-Z0-9_]+)', Name), - (r'(<|>|:=|\[|\]|\(|\)|\||:|;|,|.|\{|\})' - , Punctuation), + (r"'[^']'", String.Char), + (r'[a-zA-Z]\w*', Name), (r'(<==|==>|<=>|\*\*=|<\|=|<<=|>>=|==|!=|=\?|<=|>=|' - r'\*\*|<<|>>|=>|:=|\+=|-=|\*=|\||\|=|/=|->|\+|-|\*|/)', Operator), + r'\*\*|<<|>>|=>|:=|\+=|-=|\*=|\||\|=|/=|\+|-|\*|/|' + r'\.\.|<\.\.|\.\.<|<\.\.<)', + Operator), + (r'(<|>|\[|\]|\(|\)|\||:|;|,|.|\{|\}|->)', + Punctuation), (r'\n+', Text), ], 'numbers' : [ - (r'[0-9_]+#[0-9a-fA-F]+#', Number.Hex), - (r'0x[0-9a-fA-F]+', Number.Hex), - (r'[0-9_]+\.[0-9_]*', Number.Float), - (r'[0-9_]+', Number.Integer), + (r'\d[0-9_]*#[0-9a-fA-F][0-9a-fA-F_]*#', Number.Hex), # any base + (r'0[xX][0-9a-fA-F][0-9a-fA-F_]*', Number.Hex), # C-like hex + (r'0[bB][01][01_]*', Number.Bin), # C-like bin + (r'\d[0-9_]*\.\d[0-9_]*[eE][+-]\d[0-9_]*', # float exp + Number.Float), + (r'\d[0-9_]*\.\d[0-9_]*', Number.Float), # float + (r'\d[0-9_]*', Number.Integer), # integer ], } diff --git a/tests/examplefiles/test.psl b/tests/examplefiles/test.psl index ee427843..422cbcc7 100644 --- a/tests/examplefiles/test.psl +++ b/tests/examplefiles/test.psl @@ -4,23 +4,34 @@ // Functions func Add(X : Univ_Integer; Y : Univ_Integer) -> Univ_Integer is - // End of line semi-colons are optional return X + Y; end func Add; +// End of line semi-colons are optional +// +, +=, -, -=, *, *=, /, /= +// all do what you'd expect (/ is integer division) // If you find Univ_Integer to be too verbose you can import Short_Names // which defines aliases like Int for Univ_Integer and String for Univ_String import PSL::Short_Names::*, * func Greetings() is - // All declarations are 'const', 'var', or 'ref' const S : String := "Hello, World!" Println(S) end func Greetings +// All declarations are 'const', 'var', or 'ref' +// Assignment is :=, equality checks are ==, and != is not equals + +func Boolean_Examples(B : Bool) is + const And := B and #true // Parallel execution of operands + const And_Then := B and then #true // Short-Circuit + const Or := B or #false // Parallel execution of operands + const Or_Else := B or else #false // Short-Cirtuit + const Xor := B xor #true +end func Boolean_Examples +// Booleans are a special type of enumeration +// All enumerations are preceded by a sharp '#' func Fib(N : Int) {N >= 0} -> Int is - // '{N >= 0}' is a precondition to this function - // Preconditions are built in to the language and checked by the compiler if N <= 1 then return N else @@ -28,40 +39,50 @@ func Fib(N : Int) {N >= 0} -> Int is return Fib(N - 1) + Fib(N - 2) end if end func Fib +// '{N >= 0}' is a precondition to this function +// Preconditions are built in to the language and checked by the compiler // ParaSail does not have mutable global variables // Instead, use 'var' parameters func Increment_All(var Nums : Vector) is - // This function takes a 'var' parameter. - // The modifications made here will be seen by caller for each Elem of Nums concurrent loop - // The 'concurrent' keyword tells the compiler that - // iterations of the loop can happen in any order. - // It will choose the most optimal number of picothreads to use. - // Other options are 'forward' and 'reverse'. Elem += 1 end loop end func Increment_All +// The 'concurrent' keyword in the loop header tells the compiler that +// iterations of the loop can happen in any order. +// It will choose the most optimal number of threads to use. +// Other options are 'forward' and 'reverse'. func Sum_Of_Squares(N : Int) -> Int is - // Built-in and inherently parallel map-reduce - // Initial value is enclosed with angle brackets - return (for I in 1 .. N => <0> + I ** 2) + // The type of Sum is inferred + var Sum := 0 + for I in 1 .. N forward loop + Sum += I ** 2 // ** is exponentiation + end loop end func Sum_Of_Squares -func Sum_Of(N : Int; F : func (Int) -> Int) -> Int is - // It has functional aspects as well - // Here, we're taking an (Int) -> Int function as a parameter - return (for I in 1 .. N => <0> + F(I)) +func Sum_Of(N : Int; Map : func (Int) -> Int) -> Int is + return (for I in 1 .. N => <0> + Map(I)) end func Sum_Of +// It has functional aspects as well +// Here, we're taking an (Int) -> Int function as a parameter +// and using the inherently parallel map-reduce. +// Initial value is enclosed with angle brackets func main(Args : Basic_Array) is - Greetings() - Println(Fib(5)); - var Vec : Vector := [0, 1, 2] + Greetings() // Hello World + Println(Fib(5)) // 5 + // Container Comprehension + var Vec : Vector := [for I in 0 .. 10 {I mod 2 == 0} => I ** 2] + // Vec = [0, 4, 16, 36, 64, 100] Increment_All(Vec) - // '|' is an overloaded operator. Here used for building strings - Println(Vec[1] | ", " | Vec[2] | ", " | Vec[3]) + // Vec = [1, 5, 17, 37, 65, 101] + // '|' is an overloaded operator. + // It's usually used for concatenation or adding to a container + Println("First: " | Vec[1] | ", Last: " | Vec[Length(Vec)]); + // Vectors are 1 indexed, 0 indexed ZVectors are also available + Println(Sum_Of_Squares(3)) // Sum of fibs! @@ -69,18 +90,24 @@ func main(Args : Basic_Array) is end func main // Preceding a type with 'optional' allows it to take the value 'null' -func Divide(A, B : Int) -> optional Int is - if B == 0 then - return null; +func Divide(A, B, C : Real) -> optional Real is + // Real is the floating point type + const Epsilon := 1.0e-6; + if B in -Epsilon .. Epsilon then + return null + elsif C in -Epsilon .. Epsilon then + return null else - return A / B; - end if; -end func Divide; + return A / B + A / C + end if +end func Divide // 2. Modules // Modules are composed of an interface and a class -// ParaSail has object orientation +// ParaSail has object orientation features +// modules can be defined as 'concurrent' +// which allows 'locked' and 'queued' parameters concurrent interface Locked_Box> is // Create a box with the given content func Create(C : optional Content_Type) -> Locked_Box; @@ -99,53 +126,53 @@ concurrent interface Locked_Box> is end interface Locked_Box; concurrent class Locked_Box is - var Content : optional Content_Type; - exports - func Create(C : optional Content_Type) -> Locked_Box is - return (Content => C); - end func Create; - - func Put(locked var B : Locked_Box; C : Content_Type) is - B.Content := C; - end func Put; - - func Content(locked B : Locked_Box) -> optional Content_Type is - return B.Content; - end func Content; - - func Remove(locked var B : Locked_Box) -> Result : optional Content_Type is - // '<==' is the move operator - // It moves the right operand into the left operand, - // leaving the right null. - Result <== B.Content; - end func Remove; - - func Get(queued var B : Locked_Box) -> Result : Content_Type is + var Content : optional Content_Type; +exports + func Create(C : optional Content_Type) -> Locked_Box is + return (Content => C); + end func Create; + + func Put(locked var B : Locked_Box; C : Content_Type) is + B.Content := C; + end func Put; + + func Content(locked B : Locked_Box) -> optional Content_Type is + return B.Content; + end func Content; + + func Remove(locked var B : Locked_Box) -> Result : optional Content_Type is + // '<==' is the move operator + // It moves the right operand into the left operand, + // leaving the right null. + Result <== B.Content; + end func Remove; + + func Get(queued var B : Locked_Box) -> Result : Content_Type is queued until B.Content not null then - Result <== B.Content; - end func Get; + Result <== B.Content; + end func Get; end class Locked_Box; func Use_Box(Seed : Univ_Integer) is - var U_Box : Locked_Box := Create(null); - // Type Inference. The type of 'Ran' can be left out because - // it is inferred from the return type of Random::Start - var Ran := Random::Start(Seed); - - Println("Starting 100 pico-threads trying to put something in the box"); - Println(" or take something out."); - for I in 1..100 concurrent loop - if I < 30 then - Println("Getting out " | Get(U_Box)); - else - Println("Putting in " | I); - U_Box.Put(I); - - // The first parameter can be moved to the front with a dot - // X.Foo(Y) is equivalent to Foo(X, Y) - end if; - end loop; - - Println("And the winner is: " | Remove(U_Box)); - Println("And the box is now " | Content(U_Box)); + var U_Box : Locked_Box := Create(null); + // The type of 'Ran' can be left out because + // it is inferred from the return type of Random::Start + var Ran := Random::Start(Seed); + + Println("Starting 100 pico-threads trying to put something in the box"); + Println(" or take something out."); + for I in 1..100 concurrent loop + if I < 30 then + Println("Getting out " | Get(U_Box)); + else + Println("Putting in " | I); + U_Box.Put(I); + + // The first parameter can be moved to the front with a dot + // X.Foo(Y) is equivalent to Foo(X, Y) + end if; + end loop; + + Println("And the winner is: " | Remove(U_Box)); + Println("And the box is now " | Content(U_Box)); end func Use_Box; -- cgit v1.2.1 From 1f2829086f0640b36149f87b7de5c122f9905c9e Mon Sep 17 00:00:00 2001 From: Justin Hendrick Date: Tue, 8 Jul 2014 12:41:23 -0400 Subject: ParaSailLexer: match abstract declarations correctly --- pygments/lexers/compiled.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index 55b12109..d96f884c 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -2581,7 +2581,7 @@ class ParaSailLexer(RegexLexer): # matching and=, or=, and xor= doesn't work yet (r'\b(and(=|\sthen)?|or(=|\selse)?|xor=?|rem|mod|' r'(is|not)\snull)\b', - Operator.Word), + Operator.Word), # Keywords (r'\b(abs|abstract|all|block|class|concurrent|const|continue|' r'each|end|exit|extends|exports|forward|func|global|implements|' @@ -2590,8 +2590,9 @@ class ParaSailLexer(RegexLexer): r'type|until|var|with|' # Control flow r'if|then|else|elsif|case|for|while|loop)\b', - Keyword.Reserved), - (r'[abstract]?(interface|class|op|func|type)', Keyword.Declaration), + Keyword.Reserved), + (r'(abstract\s+)?(interface|class|op|func|type)', + Keyword.Declaration), (r'"[^"]*"', String), (r'\\[\'ntrf"0]', String.Escape), (r'#[a-zA-Z]\w*', Literal), -- cgit v1.2.1 From 0d4f84c72fb5a008aaf0f76aed8e0de6f0cc73ee Mon Sep 17 00:00:00 2001 From: Justin Hendrick Date: Tue, 8 Jul 2014 13:40:05 -0400 Subject: ParaSailLexer: and=, or=, and xor= work. A few more comments --- pygments/lexers/compiled.py | 10 ++++++---- tests/examplefiles/test.psl | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index d96f884c..d8354ec6 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -2578,9 +2578,9 @@ class ParaSailLexer(RegexLexer): 'root': [ (r'[^\S\n]+', Text), (r'//.*?\n', Comment.Single), - # matching and=, or=, and xor= doesn't work yet - (r'\b(and(=|\sthen)?|or(=|\selse)?|xor=?|rem|mod|' - r'(is|not)\snull)\b', + (r'\b(and|or|xor)=', Operator.Word), + (r'\b(and(\s+then)?|or(\s+else)?|xor|rem|mod|' + r'(is|not)\s+null)\b', Operator.Word), # Keywords (r'\b(abs|abstract|all|block|class|concurrent|const|continue|' @@ -2593,12 +2593,14 @@ class ParaSailLexer(RegexLexer): Keyword.Reserved), (r'(abstract\s+)?(interface|class|op|func|type)', Keyword.Declaration), + # Literals (r'"[^"]*"', String), (r'\\[\'ntrf"0]', String.Escape), - (r'#[a-zA-Z]\w*', Literal), + (r'#[a-zA-Z]\w*', Literal), #Enumeration include('numbers'), (r"'[^']'", String.Char), (r'[a-zA-Z]\w*', Name), + # Operators and Punctuation (r'(<==|==>|<=>|\*\*=|<\|=|<<=|>>=|==|!=|=\?|<=|>=|' r'\*\*|<<|>>|=>|:=|\+=|-=|\*=|\||\|=|/=|\+|-|\*|/|' r'\.\.|<\.\.|\.\.<|<\.\.<)', diff --git a/tests/examplefiles/test.psl b/tests/examplefiles/test.psl index 422cbcc7..3ac99498 100644 --- a/tests/examplefiles/test.psl +++ b/tests/examplefiles/test.psl @@ -27,6 +27,10 @@ func Boolean_Examples(B : Bool) is const Or := B or #false // Parallel execution of operands const Or_Else := B or else #false // Short-Cirtuit const Xor := B xor #true + var Result : Bool := #true; + Result and= #false; + Result or= #true; + Result xor= #false; end func Boolean_Examples // Booleans are a special type of enumeration // All enumerations are preceded by a sharp '#' -- cgit v1.2.1 From f2d003fb108fad618f116a0a01747d3d9324c360 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 25 Nov 2014 20:51:37 +0100 Subject: Add lexer for Boogie --- pygments/formatters/_mapping.py | 1 - pygments/lexers/_mapping.py | 1 + pygments/lexers/esoteric.py | 51 ++++++++++++++- tests/examplefiles/test.bpl | 140 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 189 insertions(+), 4 deletions(-) create mode 100644 tests/examplefiles/test.bpl diff --git a/pygments/formatters/_mapping.py b/pygments/formatters/_mapping.py index 678c069d..bc4d606e 100755 --- a/pygments/formatters/_mapping.py +++ b/pygments/formatters/_mapping.py @@ -32,7 +32,6 @@ FORMATTERS = { 'TestcaseFormatter': ('pygments.formatters.other', 'Testcase', ('testcase',), (), 'Format tokens as appropriate for a new testcase.') } - if __name__ == '__main__': # pragma: no cover import sys import os diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 05ada4f3..a0071ac9 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -49,6 +49,7 @@ LEXERS = { 'BlitzBasicLexer': ('pygments.lexers.basic', 'BlitzBasic', ('blitzbasic', 'b3d', 'bplus'), ('*.bb', '*.decls'), ('text/x-bb',)), 'BlitzMaxLexer': ('pygments.lexers.basic', 'BlitzMax', ('blitzmax', 'bmax'), ('*.bmx',), ('text/x-bmx',)), 'BooLexer': ('pygments.lexers.dotnet', 'Boo', ('boo',), ('*.boo',), ('text/x-boo',)), + 'BoogieLexer': ('pygments.lexers.esoteric', 'Boogie', ('boogie',), ('*.bpl',), ()), 'BrainfuckLexer': ('pygments.lexers.esoteric', 'Brainfuck', ('brainfuck', 'bf'), ('*.bf', '*.b'), ('application/x-brainfuck',)), 'BroLexer': ('pygments.lexers.dsls', 'Bro', ('bro',), ('*.bro',), ()), 'BugsLexer': ('pygments.lexers.modeling', 'BUGS', ('bugs', 'winbugs', 'openbugs'), ('*.bug',), ()), diff --git a/pygments/lexers/esoteric.py b/pygments/lexers/esoteric.py index 7a026aed..3f3e3015 100644 --- a/pygments/lexers/esoteric.py +++ b/pygments/lexers/esoteric.py @@ -9,11 +9,11 @@ :license: BSD, see LICENSE for details. """ -from pygments.lexer import RegexLexer, include +from pygments.lexer import RegexLexer, include, words from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ - Number, Punctuation, Error + Number, Punctuation, Error, Whitespace -__all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer'] +__all__ = ['BrainfuckLexer', 'BefungeLexer', 'BoogieLexer', 'RedcodeLexer'] class BrainfuckLexer(RegexLexer): @@ -112,3 +112,48 @@ class RedcodeLexer(RegexLexer): (r'[-+]?\d+', Number.Integer), ], } + + +class BoogieLexer(RegexLexer): + """ + For `Boogie `_ source code. + + .. versionadded:: 2.0 + """ + name = 'Boogie' + aliases = ['boogie'] + filenames = ['*.bpl'] + + tokens = { + 'root': [ + # Whitespace and Comments + (r'\n', Whitespace), + (r'\s+', Whitespace), + (r'//[/!](.*?)\n', Comment.Doc), + (r'//(.*?)\n', Comment.Single), + (r'/\*', Comment.Multiline, 'comment'), + + (words(( + 'axiom', 'break', 'call', 'ensures', 'else', 'exists', 'function', + 'forall', 'if', 'invariant', 'modifies', 'procedure', 'requires', + 'then', 'var', 'while'), + suffix=r'\b'), Keyword), + (words(('const',), suffix=r'\b'), Keyword.Reserved), + + (words(('bool', 'int', 'ref'), suffix=r'\b'), Keyword.Type), + include('numbers'), + (r"(>=|<=|:=|!=|==>|&&|\|\||[+/\-=>*<\[\]])", Operator), + (r"([{}():;,.])", Punctuation), + # Identifier + (r'[a-zA-Z_]\w*', Name), + ], + 'comment': [ + (r'[^*/]+', Comment.Multiline), + (r'/\*', Comment.Multiline, '#push'), + (r'\*/', Comment.Multiline, '#pop'), + (r'[*/]', Comment.Multiline), + ], + 'numbers': [ + (r'[0-9]+', Number.Integer), + ], + } diff --git a/tests/examplefiles/test.bpl b/tests/examplefiles/test.bpl new file mode 100644 index 00000000..add25e1a --- /dev/null +++ b/tests/examplefiles/test.bpl @@ -0,0 +1,140 @@ +/* + * Test Boogie rendering +*/ + +const N: int; +axiom 0 <= N; + +procedure foo() { + break; +} +// array to sort as global array, because partition & quicksort have to +var a: [int] int; +var original: [int] int; +var perm: [int] int; + +// Is array a of length N sorted? +function is_sorted(a: [int] int, l: int, r: int): bool +{ + (forall j, k: int :: l <= j && j < k && k <= r ==> a[j] <= a[k]) +} + +// is range a[l:r] unchanged? +function is_unchanged(a: [int] int, b: [int] int, l: int, r: int): bool { + (forall i: int :: l <= i && i <= r ==> a[i] == b[i]) +} + +function is_permutation(a: [int] int, original: [int] int, perm: [int] int, N: int): bool +{ + (forall k: int :: 0 <= k && k < N ==> 0 <= perm[k] && perm[k] < N) && + (forall k, j: int :: 0 <= k && k < j && j < N ==> perm[k] != perm[j]) && + (forall k: int :: 0 <= k && k < N ==> a[k] == original[perm[k]]) +} + +function count(a: [int] int, x: int, N: int) returns (int) +{ if N == 0 then 0 else if a[N-1] == x then count(a, x, N - 1) + 1 else count(a, x, N-1) } + + +/* +function count(a: [int] int, x: int, N: int) returns (int) +{ if N == 0 then 0 else if a[N-1] == x then count(a, x, N - 1) + 1 else count(a, x, N-1) } + +function is_permutation(a: [int] int, b: [int] int, l: int, r: int): bool { + (forall i: int :: l <= i && i <= r ==> count(a, a[i], r+1) == count(b, a[i], r+1)) +} +*/ + +procedure partition(l: int, r: int, N: int) returns (p: int) + modifies a, perm; + requires N > 0; + requires l >= 0 && l < r && r < N; + requires ((r+1) < N) ==> (forall k: int :: (k >= l && k <= r) ==> a[k] <= a[r+1]); + requires ((l-1) >= 0) ==> (forall k: int :: (k >= l && k <= r) ==> a[k] > a[l-1]); + + /* a is a permutation of the original array original */ + requires is_permutation(a, original, perm, N); + + ensures (forall k: int :: (k >= l && k <= p ) ==> a[k] <= a[p]); + ensures (forall k: int :: (k > p && k <= r ) ==> a[k] > a[p]); + ensures p >= l && p <= r; + ensures is_unchanged(a, old(a), 0, l-1); + ensures is_unchanged(a, old(a), r+1, N); + ensures ((r+1) < N) ==> (forall k: int :: (k >= l && k <= r) ==> a[k] <= a[r+1]); + ensures ((l-1) >= 0) ==> (forall k: int :: (k >= l && k <= r) ==> a[k] > a[l-1]); + + /* a is a permutation of the original array original */ + ensures is_permutation(a, original, perm, N); +{ + var i: int; + var sv: int; + var pivot: int; + var tmp: int; + + i := l; + sv := l; + pivot := a[r]; + + while (i < r) + invariant i <= r && i >= l; + invariant sv <= i && sv >= l; + invariant pivot == a[r]; + invariant (forall k: int :: (k >= l && k < sv) ==> a[k] <= old(a[r])); + invariant (forall k: int :: (k >= sv && k < i) ==> a[k] > old(a[r])); + + /* a is a permutation of the original array original */ + invariant is_permutation(a, original, perm, N); + + invariant is_unchanged(a, old(a), 0, l-1); + invariant is_unchanged(a, old(a), r+1, N); + invariant ((r+1) < N) ==> (forall k: int :: (k >= l && k <= r) ==> a[k] <= a[r+1]); + invariant ((l-1) >= 0) ==> (forall k: int :: (k >= l && k <= r) ==> a[k] > a[l-1]); + { + if ( a[i] <= pivot) { + tmp := a[i]; a[i] := a[sv]; a[sv] := tmp; + tmp := perm[i]; perm[i] := perm[sv]; perm[sv] := tmp; + sv := sv +1; + } + i := i + 1; + } + + //swap + tmp := a[i]; a[i] := a[sv]; a[sv] := tmp; + tmp := perm[i]; perm[i] := perm[sv]; perm[sv] := tmp; + + p := sv; +} + + +procedure quicksort(l: int, r: int, N: int) + modifies a, perm; + + requires N > 0; + requires l >= 0 && l < r && r < N; + requires ((r+1) < N) ==> (forall k: int :: (k >= l && k <= r) ==> a[k] <= a[r+1]); + requires ((l-1) >= 0) ==> (forall k: int :: (k >= l && k <= r) ==> a[k] > a[l-1]); + + /* a is a permutation of the original array original */ + requires is_permutation(a, original, perm, N); + + ensures ((r+1) < N) ==> (forall k: int :: (k >= l && k <= r) ==> a[k] <= a[r+1]); + ensures ((l-1) >= 0) ==> (forall k: int :: (k >= l && k <= r) ==> a[k] > a[l-1]); + + ensures is_unchanged(a, old(a), 0, l-1); + ensures is_unchanged(a, old(a), r+1, N); + ensures is_sorted(a, l, r); + + /* a is a permutation of the original array original */ + ensures is_permutation(a, original, perm, N); +{ + var p: int; + + call p := partition(l, r, N); + + if ((p-1) > l) { + call quicksort(l, p-1, N); + } + + if ((p+1) < r) { + call quicksort(p+1, r, N); + } +} -- cgit v1.2.1 From cd325e6c717170e533777bf8f57b878cea708c0a Mon Sep 17 00:00:00 2001 From: Chai Feng Date: Thu, 27 Nov 2014 09:58:17 +0800 Subject: Fix some missing Chinese cucumber keywords. --- pygments/lexers/testing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygments/lexers/testing.py b/pygments/lexers/testing.py index 07e3cb31..146f6cbc 100644 --- a/pygments/lexers/testing.py +++ b/pygments/lexers/testing.py @@ -27,9 +27,9 @@ class GherkinLexer(RegexLexer): mimetypes = ['text/x-gherkin'] feature_keywords = u'^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Фича|Особина|Могућност|Özellik|Właściwość|Tính năng|Trajto|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd)(:)(.*)$' - feature_element_keywords = u'^(\\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарій|Сценарио|Сценарий структураси|Сценарий|Структура сценарію|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Передумова|Основа|Концепт|Контекст|Założenia|Wharrimean is|Tình huống|The thing of it is|Tausta|Taust|Tapausaihio|Tapaus|Szenariogrundriss|Szenario|Szablon scenariusza|Stsenaarium|Struktura scenarija|Skica|Skenario konsep|Skenario|Situācija|Senaryo taslağı|Senaryo|Scénář|Scénario|Schema dello scenario|Scenārijs pēc parauga|Scenārijs|Scenár|Scenaro|Scenariusz|Scenariul de şablon|Scenariul de sablon|Scenariu|Scenario Outline|Scenario Amlinellol|Scenario|Scenarijus|Scenarijaus šablonas|Scenarij|Scenarie|Rerefons|Raamstsenaarium|Primer|Pozadí|Pozadina|Pozadie|Plan du scénario|Plan du Scénario|Osnova scénáře|Osnova|Náčrt Scénáře|Náčrt Scenáru|Mate|MISHUN SRSLY|MISHUN|Kịch bản|Konturo de la scenaro|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình huống|Khung kịch bản|Háttér|Grundlage|Geçmiş|Forgatókönyv vázlat|Forgatókönyv|Fono|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l\'escenari|Escenario|Escenari|Dis is what went down|Dasar|Contexto|Contexte|Contesto|Condiţii|Conditii|Cenário|Cenario|Cefndir|Bối cảnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y\'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$' + feature_element_keywords = u'^(\\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|剧本大纲|剧本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарій|Сценарио|Сценарий структураси|Сценарий|Структура сценарію|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Передумова|Основа|Концепт|Контекст|Założenia|Wharrimean is|Tình huống|The thing of it is|Tausta|Taust|Tapausaihio|Tapaus|Szenariogrundriss|Szenario|Szablon scenariusza|Stsenaarium|Struktura scenarija|Skica|Skenario konsep|Skenario|Situācija|Senaryo taslağı|Senaryo|Scénář|Scénario|Schema dello scenario|Scenārijs pēc parauga|Scenārijs|Scenár|Scenaro|Scenariusz|Scenariul de şablon|Scenariul de sablon|Scenariu|Scenario Outline|Scenario Amlinellol|Scenario|Scenarijus|Scenarijaus šablonas|Scenarij|Scenarie|Rerefons|Raamstsenaarium|Primer|Pozadí|Pozadina|Pozadie|Plan du scénario|Plan du Scénario|Osnova scénáře|Osnova|Náčrt Scénáře|Náčrt Scenáru|Mate|MISHUN SRSLY|MISHUN|Kịch bản|Konturo de la scenaro|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình huống|Khung kịch bản|Háttér|Grundlage|Geçmiş|Forgatókönyv vázlat|Forgatókönyv|Fono|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l\'escenari|Escenario|Escenari|Dis is what went down|Dasar|Contexto|Contexte|Contesto|Condiţii|Conditii|Cenário|Cenario|Cefndir|Bối cảnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y\'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$' examples_keywords = u'^(\\s*)(예|例子|例|サンプル|امثلة|דוגמאות|Сценарији|Примери|Приклади|Мисоллар|Значения|Örnekler|Voorbeelden|Variantai|Tapaukset|Scenarios|Scenariji|Scenarijai|Příklady|Példák|Príklady|Przykłady|Primjeri|Primeri|Piemēri|Pavyzdžiai|Paraugs|Juhtumid|Exemplos|Exemples|Exemplele|Exempel|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|EXAMPLZ|Dữ liệu|Contoh|Cobber|Beispiele)(:)(.*)$' - step_keywords = u'^(\\s*)(하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假如|但是|但し|並且|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Și |És |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Youse know when youse got |Youse know like when |Yna |Ya know how |Ya gotta |Y |Wun |Wtedy |When y\'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y\'all |Then |Tapi |Tak |Tada |Tad |Så |Stel |Soit |Siis |Si |Sed |Se |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu\'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kaj |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y\'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Dengan |Den youse gotta |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |Cal |But y\'all |But |Buh |Biết |Bet |BUT |Atès |Atunci |Atesa |Anrhegedig a |Angenommen |And y\'all |And |An |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\* )' + step_keywords = u'^(\\s*)(하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假设|假如|假定|但是|但し|並且|并且|同時|同时|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Și |És |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Youse know when youse got |Youse know like when |Yna |Ya know how |Ya gotta |Y |Wun |Wtedy |When y\'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y\'all |Then |Tapi |Tak |Tada |Tad |Så |Stel |Soit |Siis |Si |Sed |Se |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu\'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kaj |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y\'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Dengan |Den youse gotta |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |Cal |But y\'all |But |Buh |Biết |Bet |BUT |Atès |Atunci |Atesa |Anrhegedig a |Angenommen |And y\'all |And |An |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\* )' tokens = { 'comments': [ -- cgit v1.2.1 From c02cd4b5d85452db116582c5eff1e1fc81a7e1f1 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 3 Dec 2014 11:45:52 +1100 Subject: Improve Rust lifetime highlighting. A lifetime token isn?t normally a label, though it can be in a couple of situations, demonstrated thus:: 'foo: loop { break 'foo; } Therefore, I?ve changed the highlighting for all other places where lifetimes appear from ``Name`` or ``Name.Label`` to ``Name.Attribute``. As for the special lifetime ``'static``, which was being highlighted as ``Keyword``, I changed it to ``Name.Builtin`` which is a little more accurate. --- pygments/lexers/rust.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pygments/lexers/rust.py b/pygments/lexers/rust.py index 4447e1db..3026dd69 100644 --- a/pygments/lexers/rust.py +++ b/pygments/lexers/rust.py @@ -10,7 +10,7 @@ """ from pygments.lexer import RegexLexer, include, bygroups, words, default -from pygments.token import Comment, Operator, Keyword, Name, String, \ +from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ Number, Punctuation, Whitespace __all__ = ['RustLexer'] @@ -37,14 +37,15 @@ class RustLexer(RegexLexer): (r'/\*', Comment.Multiline, 'comment'), # Lifetime - (r"""'[a-zA-Z_]\w*""", Name.Label), + (r"""'static""", Name.Builtin), + (r"""'[a-zA-Z_]\w*""", Name.Attribute), # Macro parameters (r"""\$([a-zA-Z_]\w*|\(,?|\),?|,?)""", Comment.Preproc), # Keywords (words(( - 'as', 'box', 'break', 'continue', 'do', 'else', 'enum', 'extern', + 'as', 'box', 'do', 'else', 'enum', 'extern', # break and continue are in labels 'fn', 'for', 'if', 'impl', 'in', 'loop', 'match', 'mut', 'priv', - 'proc', 'pub', 'ref', 'return', 'static', '\'static', 'struct', + 'proc', 'pub', 'ref', 'return', 'static', 'struct', 'trait', 'true', 'type', 'unsafe', 'while'), suffix=r'\b'), Keyword), (words(('alignof', 'be', 'const', 'offsetof', 'pure', 'sizeof', @@ -84,10 +85,8 @@ class RustLexer(RegexLexer): 'Port', 'Chan', 'SharedChan', 'spawn', 'drop'), suffix=r'\b'), Name.Builtin), (r'(ImmutableTuple\d+|Tuple\d+)\b', Name.Builtin), - # Borrowed pointer - (r'(&)(\'[A-Za-z_]\w*)?', bygroups(Operator, Name)), # Labels - (r'\'[A-Za-z_]\w*:', Name.Label), + (r'(break|continue)(\s*)(\'[A-Za-z_]\w*)?', bygroups(Keyword, Text.Whitespace, Name.Label)), # Character Literal (r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}""" r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""", -- cgit v1.2.1 From e648c90b5dc39c7aab5f16d4bbae761e7f271812 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 3 Dec 2014 12:47:56 +1100 Subject: Fix character literals in Rust. Shifting lifetimes up had broken them. --- pygments/lexers/rust.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pygments/lexers/rust.py b/pygments/lexers/rust.py index 3026dd69..567519a4 100644 --- a/pygments/lexers/rust.py +++ b/pygments/lexers/rust.py @@ -36,9 +36,6 @@ class RustLexer(RegexLexer): (r'//(.*?)\n', Comment.Single), (r'/\*', Comment.Multiline, 'comment'), - # Lifetime - (r"""'static""", Name.Builtin), - (r"""'[a-zA-Z_]\w*""", Name.Attribute), # Macro parameters (r"""\$([a-zA-Z_]\w*|\(,?|\),?|,?)""", Comment.Preproc), # Keywords @@ -105,6 +102,10 @@ class RustLexer(RegexLexer): (r'"', String, 'string'), (r'r(#*)".*?"\1', String.Raw), + # Lifetime + (r"""'static""", Name.Builtin), + (r"""'[a-zA-Z_]\w*""", Name.Attribute), + # Operators and Punctuation (r'[{}()\[\],.;]', Punctuation), (r'[+\-*/%&|<>^!~@=:?]', Operator), -- cgit v1.2.1 From 5baa8b0de1081e303c9cf9659f9e08840739c1f4 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 3 Dec 2014 12:49:45 +1100 Subject: Highlight the suffix of ``9i`` properly in Rust. ``i`` and ``u`` are valid suffixes and should be highlighted. --- pygments/lexers/rust.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygments/lexers/rust.py b/pygments/lexers/rust.py index 567519a4..78ecc305 100644 --- a/pygments/lexers/rust.py +++ b/pygments/lexers/rust.py @@ -130,7 +130,7 @@ class RustLexer(RegexLexer): (r'[*/]', Comment.Multiline), ], 'number_lit': [ - (r'[ui](8|16|32|64)', Keyword, '#pop'), + (r'[ui](8|16|32|64)?', Keyword, '#pop'), (r'f(32|64)', Keyword, '#pop'), default('#pop'), ], -- cgit v1.2.1 From e7d23aec8848e48e2d5d5112a4bdba4c1c769a15 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 3 Dec 2014 12:57:06 +1100 Subject: Highlight strings more properly in Rust. - Raw strings are now ``String`` rather than the unofficial ``String.Raw`` which isn?t styled by default; - Byte strings weren?t being handled at all; - ``\x80`` and above aren?t valid in non-byte strings; - ``\0`` is a thing, ``\777`` for octal 7 is *not* a thing, nor has it ever been, to the best of my knowledge. Not sure why that one was in there at all. --- pygments/lexers/rust.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pygments/lexers/rust.py b/pygments/lexers/rust.py index 78ecc305..c2bea123 100644 --- a/pygments/lexers/rust.py +++ b/pygments/lexers/rust.py @@ -85,7 +85,10 @@ class RustLexer(RegexLexer): # Labels (r'(break|continue)(\s*)(\'[A-Za-z_]\w*)?', bygroups(Keyword, Text.Whitespace, Name.Label)), # Character Literal - (r"""'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}""" + (r"""'(\\['"\\nrt]|\\x[0-7][0-9a-fA-F]|\\0""" + r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""", + String.Char), + (r"""b'(\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\0""" r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}|.)'""", String.Char), # Binary Literal @@ -99,8 +102,9 @@ class RustLexer(RegexLexer): r'\.[0-9_]*|[eE][+\-]?[0-9_]+)', Number.Float, 'number_lit'), (r'[0-9][0-9_]*', Number.Integer, 'number_lit'), # String Literal + (r'b"', String, 'bytestring'), (r'"', String, 'string'), - (r'r(#*)".*?"\1', String.Raw), + (r'b?r(#*)".*?"\1', String), # Lifetime (r"""'static""", Name.Builtin), @@ -136,11 +140,15 @@ class RustLexer(RegexLexer): ], 'string': [ (r'"', String, '#pop'), - (r"""\\['"\\nrt]|\\x[0-9a-fA-F]{2}|\\[0-7]{1,3}""" + (r"""\\['"\\nrt]|\\x[0-7][0-9a-fA-F]|\\0""" r"""|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}""", String.Escape), (r'[^\\"]+', String), (r'\\', String), ], + 'bytestring': [ + (r"""\\x[89a-fA-F][0-9a-fA-F]""", String.Escape), + include('string'), + ], 'macro{': [ (r'\{', Operator, '#push'), (r'\}', Operator, '#pop'), -- cgit v1.2.1 From 3e3640376657ce29367df2eae36d0856a2405f81 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 3 Dec 2014 12:58:14 +1100 Subject: Update the Rust prelude items. --- pygments/lexers/rust.py | 82 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 25 deletions(-) diff --git a/pygments/lexers/rust.py b/pygments/lexers/rust.py index c2bea123..e64657c9 100644 --- a/pygments/lexers/rust.py +++ b/pygments/lexers/rust.py @@ -55,33 +55,65 @@ class RustLexer(RegexLexer): 'int', 'f32', 'f64', 'str', 'bool'), suffix=r'\b'), Keyword.Type), (r'self\b', Name.Builtin.Pseudo), - # Prelude + # Prelude (taken from Rust’s src/libstd/prelude.rs) (words(( - 'Freeze', 'Pod', 'Send', 'Sized', 'Add', 'Sub', 'Mul', 'Div', 'Rem', 'Neg', 'Not', 'BitAnd', - 'BitOr', 'BitXor', 'Drop', 'Shl', 'Shr', 'Index', 'Option', 'Some', 'None', 'Result', - 'Ok', 'Err', 'from_str', 'range', 'print', 'println', 'Any', 'AnyOwnExt', 'AnyRefExt', - 'AnyMutRefExt', 'Ascii', 'AsciiCast', 'OnwedAsciiCast', 'AsciiStr', - 'IntoBytes', 'Bool', 'ToCStr', 'Char', 'Clone', 'DeepClone', 'Eq', 'ApproxEq', - 'Ord', 'TotalEq', 'Ordering', 'Less', 'Equal', 'Greater', 'Equiv', 'Container', - 'Mutable', 'Map', 'MutableMap', 'Set', 'MutableSet', 'Default', 'FromStr', - 'Hash', 'FromIterator', 'Extendable', 'Iterator', 'DoubleEndedIterator', - 'RandomAccessIterator', 'CloneableIterator', 'OrdIterator', - 'MutableDoubleEndedIterator', 'ExactSize', 'Times', 'Algebraic', - 'Trigonometric', 'Exponential', 'Hyperbolic', 'Bitwise', 'BitCount', - 'Bounded', 'Integer', 'Fractional', 'Real', 'RealExt', 'Num', 'NumCast', - 'CheckedAdd', 'CheckedSub', 'CheckedMul', 'Orderable', 'Signed', - 'Unsigned', 'Round', 'Primitive', 'Int', 'Float', 'ToStrRadix', - 'ToPrimitive', 'FromPrimitive', 'GenericPath', 'Path', 'PosixPath', - 'WindowsPath', 'RawPtr', 'Buffer', 'Writer', 'Reader', 'Seek', - 'SendStr', 'SendStrOwned', 'SendStrStatic', 'IntoSendStr', 'Str', - 'StrVector', 'StrSlice', 'OwnedStr', 'IterBytes', 'ToStr', 'IntoStr', - 'CopyableTuple', 'ImmutableTuple', 'ImmutableEqVector', 'ImmutableTotalOrdVector', - 'ImmutableCopyableVector', 'OwnedVector', 'OwnedCopyableVector', - 'OwnedEqVector', 'MutableVector', 'MutableTotalOrdVector', - 'Vector', 'VectorVector', 'CopyableVector', 'ImmutableVector', - 'Port', 'Chan', 'SharedChan', 'spawn', 'drop'), suffix=r'\b'), + # Reexported core operators + 'Copy', 'Send', 'Sized', 'Sync', + 'Add', 'Sub', 'Mul', 'Div', 'Rem', 'Neg', 'Not', + 'BitAnd', 'BitOr', 'BitXor', + 'Drop', 'Deref', 'DerefMut', + 'Shl', 'Shr', + 'Index', 'IndexMut', + 'Slice', 'SliceMut', + 'Fn', 'FnMut', 'FnOnce', + + # Reexported functions + 'range', + 'drop', + 'from_str', + + # Reexported types and traits + 'Ascii', 'AsciiCast', 'OwnedAsciiCast', 'AsciiStr', + 'IntoBytes', + 'IntoCow', + 'ToCStr', + 'Char', 'UnicodeChar', + 'Clone', + 'PartialEq', 'PartialOrd', 'Eq', 'Ord', + 'Ordering', 'Equiv', + 'Less', 'Equal', 'Greater', + 'FromIterator', 'Extend', 'ExactSizeIterator', + 'Iterator', 'IteratorExt', 'DoubleEndedIterator', + 'DoubleEndedIteratorExt', 'CloneIteratorExt', + 'RandomAccessIterator', 'IteratorCloneExt', + 'IteratorOrdExt', 'MutableDoubleEndedIterator', + 'ToPrimitive', 'FromPrimitive', + 'Box', + 'Option', + 'Some', 'None', + 'GenericPath', 'Path', 'PosixPath', 'WindowsPath', + 'RawPtr', 'RawMutPtr', + 'Result', + 'Ok', 'Err', + 'Buffer', 'Writer', 'Reader', 'Seek', 'BufferPrelude', + 'Str', 'StrVector', 'StrPrelude', + 'StrAllocating', 'UnicodeStrPrelude', + 'Tuple1', 'Tuple2', 'Tuple3', 'Tuple4', + 'Tuple5', 'Tuple6', 'Tuple7', 'Tuple8', + 'Tuple9', 'Tuple10', 'Tuple11', 'Tuple12', + 'SlicePrelude', 'AsSlice', 'CloneSlicePrelude', + 'VectorVector', 'PartialEqSlicePrelude', 'OrdSlicePrelude', + 'CloneSliceAllocPrelude', 'OrdSliceAllocPrelude', 'SliceAllocPrelude', + 'BoxedSlicePrelude', + 'IntoString', 'String', 'ToString', + 'Vec', + + # Reexported runtime types + 'sync_channel', 'channel', + 'SyncSender', 'Sender', 'Receiver', + 'spawn', + ), suffix=r'\b'), Name.Builtin), - (r'(ImmutableTuple\d+|Tuple\d+)\b', Name.Builtin), # Labels (r'(break|continue)(\s*)(\'[A-Za-z_]\w*)?', bygroups(Keyword, Text.Whitespace, Name.Label)), # Character Literal -- cgit v1.2.1 From d303d58a5c1f90c707bd5ccaf31a30ef6f9221bb Mon Sep 17 00:00:00 2001 From: "Dan Michael O. Hegg?" Date: Sun, 7 Dec 2014 16:12:27 +0100 Subject: Add TurtleLexer --- pygments/lexers/_mapping.py | 1 + pygments/lexers/rdf.py | 98 +++++++++++++++++++++++++++++++++++++++++- tests/examplefiles/example.ttl | 43 ++++++++++++++++++ 3 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 tests/examplefiles/example.ttl diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 05ada4f3..b30eef97 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -344,6 +344,7 @@ LEXERS = { 'TextLexer': ('pygments.lexers.special', 'Text only', ('text',), ('*.txt',), ('text/plain',)), 'TodotxtLexer': ('pygments.lexers.textfmts', 'Todotxt', ('todotxt',), ('todo.txt', '*.todotxt'), ('text/x-todo',)), 'TreetopLexer': ('pygments.lexers.parsers', 'Treetop', ('treetop',), ('*.treetop', '*.tt'), ()), + 'TurtleLexer': ('pygments.lexers.rdf', 'Turtle', ('turtle',), ('*.ttl',), ('text/turtle', 'application/x-turtle')), 'TwigHtmlLexer': ('pygments.lexers.templates', 'HTML+Twig', ('html+twig',), ('*.twig',), ('text/html+twig',)), 'TwigLexer': ('pygments.lexers.templates', 'Twig', ('twig',), (), ('application/x-twig',)), 'TypeScriptLexer': ('pygments.lexers.javascript', 'TypeScript', ('ts',), ('*.ts',), ('text/x-typescript',)), diff --git a/pygments/lexers/rdf.py b/pygments/lexers/rdf.py index 292b1ae2..05393a6e 100644 --- a/pygments/lexers/rdf.py +++ b/pygments/lexers/rdf.py @@ -12,10 +12,10 @@ import re from pygments.lexer import RegexLexer, bygroups, default -from pygments.token import Keyword, Punctuation, String, Number, Operator, \ +from pygments.token import Keyword, Punctuation, String, Number, Operator, Generic, \ Whitespace, Name, Literal, Comment, Text -__all__ = ['SparqlLexer'] +__all__ = ['SparqlLexer', 'TurtleLexer'] class SparqlLexer(RegexLexer): @@ -97,3 +97,97 @@ class SparqlLexer(RegexLexer): default('#pop:2'), ], } + + +class TurtleLexer(RegexLexer): + """ + Lexer for `Turtle `_ data language. + + .. versionadded:: 2.0 + """ + name = 'Turtle' + aliases = ['turtle'] + filenames = ['*.ttl'] + mimetypes = ['text/turtle', 'application/x-turtle'] + + flags = re.IGNORECASE + + patterns = { + 'PNAME_NS': r'((?:[a-zA-Z][\w-]*)?\:)', # Simplified character range + 'IRIREF': r'(<[^<>"{}|^`\\\x00-\x20]*>)' + } + + # PNAME_NS PN_LOCAL (with simplified character range) + patterns['PrefixedName'] = r'%(PNAME_NS)s([a-z][\w-]*)' % patterns + + tokens = { + 'root': [ + (r'\s+', Whitespace), + + # Base / prefix + (r'(@base|BASE)(\s+)%(IRIREF)s(\s*)(\.?)' % patterns, + bygroups(Keyword, Whitespace, Name.Variable, Whitespace, + Punctuation)), + (r'(@prefix|PREFIX)(\s+)%(PNAME_NS)s(\s+)%(IRIREF)s(\s*)(\.?)' % patterns, + bygroups(Keyword, Whitespace, Name.Namespace, Whitespace, + Name.Variable, Whitespace, Punctuation)), + + # The shorthand predicate 'a' + (r'(?<=\s)a(?=\s)', Keyword.Type), + + # IRIREF + (r'%(IRIREF)s' % patterns, Name.Variable), + + # PrefixedName + (r'%(PrefixedName)s' % patterns, + bygroups(Name.Namespace, Name.Tag)), + + # Comment + (r'#[^\n]+', Comment), + + (r'\b(true|false)\b', Literal), + (r'[+\-]?\d*\.\d+', Number.Float), + (r'[+\-]?\d*(:?\.\d+)?E[+\-]?\d+', Number.Float), + (r'[+\-]?\d+', Number.Integer), + (r'[\[\](){}.;,:^]', Punctuation), + + (r'"""', String, 'triple-double-quoted-string'), + (r'"', String, 'single-double-quoted-string'), + (r"'''", String, 'triple-single-quoted-string'), + (r"'", String, 'single-single-quoted-string'), + ], + 'triple-double-quoted-string': [ + (r'"""', String, 'end-of-string'), + (r'[^\\]+', String), + (r'\\', String, 'string-escape'), + ], + 'single-double-quoted-string': [ + (r'"', String, 'end-of-string'), + (r'[^"\\\n]+', String), + (r'\\', String, 'string-escape'), + ], + 'triple-single-quoted-string': [ + (r"'''", String, 'end-of-string'), + (r'[^\\]+', String), + (r'\\', String, 'string-escape'), + ], + 'single-single-quoted-string': [ + (r"'", String, 'end-of-string'), + (r"[^'\\\n]+", String), + (r'\\', String, 'string-escape'), + ], + 'string-escape': [ + (r'.', String, '#pop'), + ], + 'end-of-string': [ + + (r'(@)([a-zA-Z]+(:?-[a-zA-Z0-9]+)*)', + bygroups(Operator, Generic.Emph), '#pop:2'), + + (r'(\^\^)%(IRIREF)s' % patterns, bygroups(Operator, Generic.Emph), '#pop:2'), + (r'(\^\^)%(PrefixedName)s' % patterns, bygroups(Operator, Generic.Emph, Generic.Emph), '#pop:2'), + + default('#pop:2'), + + ], + } diff --git a/tests/examplefiles/example.ttl b/tests/examplefiles/example.ttl new file mode 100644 index 00000000..e524d86c --- /dev/null +++ b/tests/examplefiles/example.ttl @@ -0,0 +1,43 @@ +@base . +@prefix dcterms: . @prefix xs: . +@prefix mads: . +@prefix skos: . +@PREFIX dc: # SPARQL-like syntax is OK +@prefix : . # empty prefix is OK + + . + +<#doc1> a <#document> + dc:creator "Smith", "Jones"; + :knows + dcterms:hasPart [ # A comment + dc:title "Some title", "Some other title"; + dc:creator "برشت، برتولد"@ar; + dc:date "2009"^^xs:date + ]; + dc:title "A sample title", 23.0; + dcterms:isPartOf [ + dc:title "another", "title" + ] ; + :exists true . + + a mads:Topic, + skos:Concept ; + dcterms:created "2014-08-25"^^xsd:date ; + dcterms:modified "2014-11-12"^^xsd:date ; + dcterms:identifier "REAL006839" ; + skos:prefLabel "Flerbørstemarker"@nb, + "Polychaeta"@la ; + skos:altLabel "Flerbørsteormer"@nb, + "Mangebørstemark"@nb, + "Mangebørsteormer"@nb, + "Havbørsteormer"@nb, + "Havbørstemarker"@nb, + "Polycheter"@nb. + skos:inScheme ; + skos:narrower , + , + ; + skos:exactMatch , + , + . -- cgit v1.2.1 From 1c2cda5b58d4a37b71e5f047cad5fe133463aec0 Mon Sep 17 00:00:00 2001 From: Soonho Kong Date: Tue, 9 Dec 2014 03:39:44 -0500 Subject: Add a missing operator '`' for Lean theorem prover --- pygments/lexers/theorem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygments/lexers/theorem.py b/pygments/lexers/theorem.py index fdd4fd81..b8b08b53 100644 --- a/pygments/lexers/theorem.py +++ b/pygments/lexers/theorem.py @@ -416,7 +416,7 @@ class LeanLexer(RegexLexer): ) operators = ( - '!=', '#', '&', '&&', '*', '+', '-', '/', '@', '!', + '!=', '#', '&', '&&', '*', '+', '-', '/', '@', '!', '`', '-.', '->', '.', '..', '...', '::', ':>', ';', ';;', '<', '<-', '=', '==', '>', '_', '`', '|', '||', '~', '=>', '<=', '>=', '/\\', '\\/', u'∀', u'Π', u'λ', u'↔', u'∧', u'∨', u'≠', u'≤', u'≥', -- cgit v1.2.1 From 73d4107c2d40fa616671fd32821ca450072e702b Mon Sep 17 00:00:00 2001 From: Matt Layman Date: Sun, 14 Dec 2014 23:31:59 -0500 Subject: Add a lexer for the Test Anything Protocol (TAP). --- AUTHORS | 1 + pygments/formatters/_mapping.py | 1 - pygments/lexers/_mapping.py | 1 + pygments/lexers/tap.py | 91 +++++++++++++++++++++++++++++++++++++++++ tests/examplefiles/example.tap | 37 +++++++++++++++++ 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 pygments/lexers/tap.py create mode 100644 tests/examplefiles/example.tap diff --git a/AUTHORS b/AUTHORS index 06119231..1f95aecf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -91,6 +91,7 @@ Other contributors, listed alphabetically, are: * Gerd Kurzbach -- Modelica lexer * Jon Larimer, Google Inc. -- Smali lexer * Olov Lassus -- Dart lexer +* Matt Layman -- TAP lexer * Sylvestre Ledru -- Scilab lexer * Mark Lee -- Vala lexer * Ben Mabey -- Gherkin lexer diff --git a/pygments/formatters/_mapping.py b/pygments/formatters/_mapping.py index 678c069d..bc4d606e 100755 --- a/pygments/formatters/_mapping.py +++ b/pygments/formatters/_mapping.py @@ -32,7 +32,6 @@ FORMATTERS = { 'TestcaseFormatter': ('pygments.formatters.other', 'Testcase', ('testcase',), (), 'Format tokens as appropriate for a new testcase.') } - if __name__ == '__main__': # pragma: no cover import sys import os diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 05ada4f3..3134b81f 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -336,6 +336,7 @@ LEXERS = { 'SwiftLexer': ('pygments.lexers.objective', 'Swift', ('swift',), ('*.swift',), ('text/x-swift',)), 'SwigLexer': ('pygments.lexers.c_like', 'SWIG', ('swig',), ('*.swg', '*.i'), ('text/swig',)), 'SystemVerilogLexer': ('pygments.lexers.hdl', 'systemverilog', ('systemverilog', 'sv'), ('*.sv', '*.svh'), ('text/x-systemverilog',)), + 'TAPLexer': ('pygments.lexers.tap', 'TAP', ('tap',), ('*.tap',), ()), 'Tads3Lexer': ('pygments.lexers.int_fiction', 'TADS 3', ('tads3',), ('*.t',), ()), 'TclLexer': ('pygments.lexers.tcl', 'Tcl', ('tcl',), ('*.tcl', '*.rvt'), ('text/x-tcl', 'text/x-script.tcl', 'application/x-tcl')), 'TcshLexer': ('pygments.lexers.shell', 'Tcsh', ('tcsh', 'csh'), ('*.tcsh', '*.csh'), ('application/x-csh',)), diff --git a/pygments/lexers/tap.py b/pygments/lexers/tap.py new file mode 100644 index 00000000..7d965c80 --- /dev/null +++ b/pygments/lexers/tap.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +""" + pygments.lexers.tap + ~~~~~~~~~~~~~~~~~~~ + + Lexer for the Test Anything Protocol (TAP). + + :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import bygroups, RegexLexer +from pygments.token import Comment, Generic, Keyword, Name, Number, Text + +__all__ = ['TAPLexer'] + + +class TAPLexer(RegexLexer): + """ + For Test Anything Protocol (TAP) output. + + .. versionadded:: 2.1 + """ + name = 'TAP' + aliases = ['tap'] + filenames = ['*.tap'] + + tokens = { + 'root': [ + # A TAP version may be specified. + (r'^TAP version \d+\n', Name.Namespace), + + # Specify a plan with a plan line. + (r'^1..\d+', Keyword.Declaration, 'plan'), + + # A test failure + (r'^(not ok)([^\S\n]*)(\d*)', + bygroups(Generic.Error, Text, Number.Integer), 'test'), + + # A test success + (r'^(ok)([^\S\n]*)(\d*)', + bygroups(Keyword.Reserved, Text, Number.Integer), 'test'), + + # Diagnostics start with a hash. + (r'^#.*\n', Comment), + + # TAP's version of an abort statement. + (r'^Bail out!.*\n', Generic.Error), + + # TAP ignores any unrecognized lines. + (r'^.*\n', Text), + ], + 'plan': [ + # Consume whitespace (but not newline). + (r'[^\S\n]+', Text), + + # A plan may have a directive with it. + (r'#', Comment, 'directive'), + + # Or it could just end. + (r'\n', Comment, '#pop'), + + # Anything else is wrong. + (r'.*\n', Generic.Error, '#pop'), + ], + 'test': [ + # Consume whitespace (but not newline). + (r'[^\S\n]+', Text), + + # A test may have a directive with it. + (r'#', Comment, 'directive'), + + (r'\S+', Text), + + (r'\n', Text, '#pop'), + ], + 'directive': [ + # Consume whitespace (but not newline). + (r'[^\S\n]+', Comment), + + # Extract todo items. + (r'(?i)\bTODO\b', Comment.Preproc), + + # Extract skip items. + (r'(?i)\bSKIP\S*', Comment.Preproc), + + (r'\S+', Comment), + + (r'\n', Comment, '#pop:2'), + ], + } diff --git a/tests/examplefiles/example.tap b/tests/examplefiles/example.tap new file mode 100644 index 00000000..a70a239d --- /dev/null +++ b/tests/examplefiles/example.tap @@ -0,0 +1,37 @@ +TAP version 13 +1..42 +1..13 A plan only supports directives so this text is wrong. +ok 1 A normal test line includes a number. +ok But a test line may also omit a number. + +A random line that does not look like a test or diagnostic should be ignored. + No matter how it is spaced out. + +Or if it is a totally blank line. + +not ok 3 This is a failing test line. + +# Diagnostics are any lines... +# ... beginning with a hash character. + +not ok 4 There are a couple of directives. # TODO is one of those directives. +not ok 5 # TODO: is invalid because the directive must be followed by a space. +ok 6 - Another directive line # toDO is not case sensitive. + +ok 7 A line that is a # SKIP +ok 8 Tests can be # skipped as long as the directive has the "skip" stem. +ok 9 The TODO directive must be followed by a space, but # skip: is valid. +1..0 # Skipped directives can show on a plan line too. + +Bail out! is a special phrase emitted when a TAP file aborted. + +not ok 10 Having TAP version 13 in the middle of a line is not a TAP version. +not ok 11 Having Bail out! in the middle of a line is not a bail out. + +ok 12 Here is an empty directive. # + +# The most basic valid test lines. +ok +not ok + +ok 15 Only the test number should look different. Not another 42, for example. -- cgit v1.2.1 From 51ddb703574903caac2b83156bdc43c97cd73699 Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Wed, 24 Dec 2014 14:29:33 +0100 Subject: Add EmacsLispLexer --- pygments/lexers/lisp.py | 664 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 661 insertions(+), 3 deletions(-) diff --git a/pygments/lexers/lisp.py b/pygments/lexers/lisp.py index 95846b48..21bc31e9 100644 --- a/pygments/lexers/lisp.py +++ b/pygments/lexers/lisp.py @@ -17,9 +17,9 @@ from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ from pygments.lexers.python import PythonLexer -__all__ = ['SchemeLexer', 'CommonLispLexer', 'HyLexer', 'RacketLexer', - 'NewLispLexer'] - +__all__ = ['SchemeLexer', 'CommonLispLexer', + 'HyLexer', 'RacketLexer', + 'NewLispLexer', 'EmacsLispLexer', ] class SchemeLexer(RegexLexer): """ @@ -1478,3 +1478,661 @@ class NewLispLexer(RegexLexer): (r'(?s)(.*?)(\[/text\])', String, '#pop'), ], } + +class EmacsLispLexer(RegexLexer): + """ + An ELisp lexer, parsing a stream and outputting the tokens + needed to highlight elisp code. + + .. versionadded:: 2.0 + """ + name = 'EmacsLisp' + aliases = ['emacs', 'elisp'] + filenames = ['*.el'] + mimetypes = ['text/x-elisp', 'application/x-elisp'] + + flags = re.MULTILINE + + # couple of useful regexes + + # characters that are not macro-characters and can be used to begin a symbol + nonmacro = r'\\.|[\w!$%&*+-/<=>?@\[\]^{}~]' + constituent = nonmacro + '|[#.:]' + terminated = r'(?=[ "()\'\n,;`])' # whitespace or terminating macro characters + + # symbol token, reverse-engineered from hyperspec + # Take a deep breath... + symbol = r'(\|[^|]+\||(?:%s)(?:%s)*)' % (nonmacro, constituent) + + macros = set(( + 'atomic-change-group', 'case', 'block', 'cl-block', 'cl-callf', 'cl-callf2', + 'cl-case', 'cl-decf', 'cl-declaim', 'cl-declare', + 'cl-define-compiler-macro', 'cl-defmacro', 'cl-defstruct', + 'cl-defsubst', 'cl-deftype', 'cl-defun', 'cl-destructuring-bind', + 'cl-do', 'cl-do*', 'cl-do-all-symbols', 'cl-do-symbols', 'cl-dolist', + 'cl-dotimes', 'cl-ecase', 'cl-etypecase', 'eval-when', 'cl-eval-when', 'cl-flet', + 'cl-flet*', 'cl-function', 'cl-incf', 'cl-labels', 'cl-letf', + 'cl-letf*', 'cl-load-time-value', 'cl-locally', 'cl-loop', + 'cl-macrolet', 'cl-multiple-value-bind', 'cl-multiple-value-setq', + 'cl-progv', 'cl-psetf', 'cl-psetq', 'cl-pushnew', 'cl-remf', + 'cl-return', 'cl-return-from', 'cl-rotatef', 'cl-shiftf', + 'cl-symbol-macrolet', 'cl-tagbody', 'cl-the', 'cl-typecase', + 'combine-after-change-calls', 'condition-case-unless-debug', 'decf', + 'declaim', 'declare', 'declare-function', 'def-edebug-spec', + 'defadvice', 'defclass', 'defcustom', 'defface', 'defgeneric', + 'defgroup', 'define-advice', 'define-alternatives', + 'define-compiler-macro', 'define-derived-mode', 'define-generic-mode', + 'define-global-minor-mode', 'define-globalized-minor-mode', + 'define-minor-mode', 'define-modify-macro', + 'define-obsolete-face-alias', 'define-obsolete-function-alias', + 'define-obsolete-variable-alias', 'define-setf-expander', + 'define-skeleton', 'defmacro', 'defmethod', 'defsetf', 'defstruct', + 'defsubst', 'deftheme', 'deftype', 'defun', 'defvar-local', + 'delay-mode-hooks', 'destructuring-bind', 'do', 'do*', + 'do-all-symbols', 'do-symbols', 'dolist', 'dont-compile', 'dotimes', + 'dotimes-with-progress-reporter', 'ecase', 'ert-deftest', 'etypecase', + 'eval-and-compile', 'eval-when-compile', 'flet', 'ignore-errors', + 'incf', 'labels', 'lambda', 'letrec', 'lexical-let', 'lexical-let*', + 'loop', 'multiple-value-bind', 'multiple-value-setq', 'noreturn', + 'oref', 'oref-default', 'oset', 'oset-default', 'pcase', + 'pcase-defmacro', 'pcase-dolist', 'pcase-exhaustive', 'pcase-let', + 'pcase-let*', 'pop', 'psetf', 'psetq', 'push', 'pushnew', 'remf', + 'return', 'rotatef', 'rx', 'save-match-data', 'save-selected-window', + 'save-window-excursion', 'setf', 'setq-local', 'shiftf', + 'track-mouse', 'typecase', 'unless', 'use-package', 'when', + 'while-no-input', 'with-case-table', 'with-category-table', + 'with-coding-priority', 'with-current-buffer', 'with-demoted-errors', + 'with-eval-after-load', 'with-file-modes', 'with-local-quit', + 'with-output-to-string', 'with-output-to-temp-buffer', + 'with-parsed-tramp-file-name', 'with-selected-frame', + 'with-selected-window', 'with-silent-modifications', 'with-slots', + 'with-syntax-table', 'with-temp-buffer', 'with-temp-file', + 'with-temp-message', 'with-timeout', 'with-tramp-connection-property', + 'with-tramp-file-property', 'with-tramp-progress-reporter', + 'with-wrapper-hook', 'load-time-value', 'locally', 'macrolet', 'progv', 'return-from' + )) + + special_forms = set(( + 'and', 'catch', 'cond', 'condition-case', 'defconst', 'defvar', + 'function', 'if', 'interactive', 'let', 'let*', 'or', 'prog1', + 'prog2', 'progn', 'quote', 'save-current-buffer', 'save-excursion', + 'save-restriction', 'setq', 'setq-default', 'subr-arity', + 'unwind-protect', 'while', + )) + + builtin_function = set(( + '%', '*', '+', '-', '/', '/=', '1+', '1-', '<', '<=', '=', '>', '>=', + 'Snarf-documentation', 'abort-recursive-edit', 'abs', + 'accept-process-output', 'access-file', 'accessible-keymaps', 'acos', + 'active-minibuffer-window', 'add-face-text-property', + 'add-name-to-file', 'add-text-properties', 'all-completions', + 'append', 'apply', 'apropos-internal', 'aref', 'arrayp', 'aset', + 'ash', 'asin', 'assoc', 'assoc-string', 'assq', 'atan', 'atom', + 'autoload', 'autoload-do-load', 'backtrace', 'backtrace--locals', + 'backtrace-debug', 'backtrace-eval', 'backtrace-frame', + 'backward-char', 'backward-prefix-chars', 'barf-if-buffer-read-only', + 'base64-decode-region', 'base64-decode-string', + 'base64-encode-region', 'base64-encode-string', 'beginning-of-line', + 'bidi-find-overridden-directionality', 'bidi-resolved-levels', + 'bitmap-spec-p', 'bobp', 'bolp', 'bool-vector', + 'bool-vector-count-consecutive', 'bool-vector-count-population', + 'bool-vector-exclusive-or', 'bool-vector-intersection', + 'bool-vector-not', 'bool-vector-p', 'bool-vector-set-difference', + 'bool-vector-subsetp', 'bool-vector-union', 'boundp', + 'buffer-base-buffer', 'buffer-chars-modified-tick', + 'buffer-enable-undo', 'buffer-file-name', 'buffer-has-markers-at', + 'buffer-list', 'buffer-live-p', 'buffer-local-value', + 'buffer-local-variables', 'buffer-modified-p', 'buffer-modified-tick', + 'buffer-name', 'buffer-size', 'buffer-string', 'buffer-substring', + 'buffer-substring-no-properties', 'buffer-swap-text', 'bufferp', + 'bury-buffer-internal', 'byte-code', 'byte-code-function-p', + 'byte-to-position', 'byte-to-string', 'byteorder', + 'call-interactively', 'call-last-kbd-macro', 'call-process', + 'call-process-region', 'cancel-kbd-macro-events', 'capitalize', + 'capitalize-region', 'capitalize-word', 'car', 'car-less-than-car', + 'car-safe', 'case-table-p', 'category-docstring', + 'category-set-mnemonics', 'category-table', 'category-table-p', + 'ccl-execute', 'ccl-execute-on-string', 'ccl-program-p', 'cdr', + 'cdr-safe', 'ceiling', 'char-after', 'char-before', + 'char-category-set', 'char-charset', 'char-equal', 'char-or-string-p', + 'char-resolve-modifiers', 'char-syntax', 'char-table-extra-slot', + 'char-table-p', 'char-table-parent', 'char-table-range', + 'char-table-subtype', 'char-to-string', 'char-width', 'characterp', + 'charset-after', 'charset-id-internal', 'charset-plist', + 'charset-priority-list', 'charsetp', 'check-coding-system', + 'check-coding-systems-region', 'clear-buffer-auto-save-failure', + 'clear-charset-maps', 'clear-face-cache', 'clear-font-cache', + 'clear-image-cache', 'clear-string', 'clear-this-command-keys', + 'close-font', 'clrhash', 'coding-system-aliases', + 'coding-system-base', 'coding-system-eol-type', 'coding-system-p', + 'coding-system-plist', 'coding-system-priority-list', + 'coding-system-put', 'color-distance', 'color-gray-p', + 'color-supported-p', 'combine-after-change-execute', + 'command-error-default-function', 'command-remapping', 'commandp', + 'compare-buffer-substrings', 'compare-strings', + 'compare-window-configurations', 'completing-read', + 'compose-region-internal', 'compose-string-internal', + 'composition-get-gstring', 'compute-motion', 'concat', 'cons', + 'consp', 'constrain-to-field', 'continue-process', + 'controlling-tty-p', 'coordinates-in-window-p', 'copy-alist', + 'copy-category-table', 'copy-file', 'copy-hash-table', 'copy-keymap', + 'copy-marker', 'copy-sequence', 'copy-syntax-table', 'copysign', + 'cos', 'current-active-maps', 'current-bidi-paragraph-direction', + 'current-buffer', 'current-case-table', 'current-column', + 'current-global-map', 'current-idle-time', 'current-indentation', + 'current-input-mode', 'current-local-map', 'current-message', + 'current-minor-mode-maps', 'current-time', 'current-time-string', + 'current-time-zone', 'current-window-configuration', + 'cygwin-convert-file-name-from-windows', + 'cygwin-convert-file-name-to-windows', 'daemon-initialized', + 'daemonp', 'dbus--init-bus', 'dbus-get-unique-name', + 'dbus-message-internal', 'debug-timer-check', 'declare-equiv-charset', + 'decode-big5-char', 'decode-char', 'decode-coding-region', + 'decode-coding-string', 'decode-sjis-char', 'decode-time', + 'default-boundp', 'default-file-modes', 'default-printer-name', + 'default-toplevel-value', 'default-value', 'define-category', + 'define-charset-alias', 'define-charset-internal', + 'define-coding-system-alias', 'define-coding-system-internal', + 'define-fringe-bitmap', 'define-hash-table-test', 'define-key', + 'define-prefix-command', 'delete', + 'delete-all-overlays', 'delete-and-extract-region', 'delete-char', + 'delete-directory-internal', 'delete-field', 'delete-file', + 'delete-frame', 'delete-other-windows-internal', 'delete-overlay', + 'delete-process', 'delete-region', 'delete-terminal', + 'delete-window-internal', 'delq', 'describe-buffer-bindings', + 'describe-vector', 'destroy-fringe-bitmap', 'detect-coding-region', + 'detect-coding-string', 'ding', 'directory-file-name', + 'directory-files', 'directory-files-and-attributes', 'discard-input', + 'display-supports-face-attributes-p', 'do-auto-save', 'documentation', + 'documentation-property', 'downcase', 'downcase-region', + 'downcase-word', 'draw-string', 'dump-colors', 'dump-emacs', + 'dump-face', 'dump-frame-glyph-matrix', 'dump-glyph-matrix', + 'dump-glyph-row', 'dump-redisplay-history', 'dump-tool-bar-row', + 'elt', 'emacs-pid', 'encode-big5-char', 'encode-char', + 'encode-coding-region', 'encode-coding-string', 'encode-sjis-char', + 'encode-time', 'end-kbd-macro', 'end-of-line', 'eobp', 'eolp', 'eq', + 'eql', 'equal', 'equal-including-properties', 'erase-buffer', + 'error-message-string', 'eval', 'eval-buffer', 'eval-region', + 'event-convert-list', 'execute-kbd-macro', 'exit-recursive-edit', + 'exp', 'expand-file-name', 'expt', 'external-debugging-output', + 'face-attribute-relative-p', 'face-attributes-as-vector', 'face-font', + 'fboundp', 'fceiling', 'fetch-bytecode', 'ffloor', + 'field-beginning', 'field-end', 'field-string', + 'field-string-no-properties', 'file-accessible-directory-p', + 'file-acl', 'file-attributes', 'file-attributes-lessp', + 'file-directory-p', 'file-executable-p', 'file-exists-p', + 'file-locked-p', 'file-modes', 'file-name-absolute-p', + 'file-name-all-completions', 'file-name-as-directory', + 'file-name-completion', 'file-name-directory', + 'file-name-nondirectory', 'file-newer-than-file-p', 'file-readable-p', + 'file-regular-p', 'file-selinux-context', 'file-symlink-p', + 'file-system-info', 'file-system-info', 'file-writable-p', + 'fillarray', 'find-charset-region', 'find-charset-string', + 'find-coding-systems-region-internal', 'find-composition-internal', + 'find-file-name-handler', 'find-font', 'find-operation-coding-system', + 'float', 'float-time', 'floatp', 'floor', 'fmakunbound', + 'following-char', 'font-at', 'font-drive-otf', 'font-face-attributes', + 'font-family-list', 'font-get', 'font-get-glyphs', + 'font-get-system-font', 'font-get-system-normal-font', 'font-info', + 'font-match-p', 'font-otf-alternates', 'font-put', + 'font-shape-gstring', 'font-spec', 'font-variation-glyphs', + 'font-xlfd-name', 'fontp', 'fontset-font', 'fontset-info', + 'fontset-list', 'fontset-list-all', 'force-mode-line-update', + 'force-window-update', 'format', 'format-mode-line', + 'format-network-address', 'format-time-string', 'forward-char', + 'forward-comment', 'forward-line', 'forward-word', + 'frame-border-width', 'frame-bottom-divider-width', + 'frame-can-run-window-configuration-change-hook', 'frame-char-height', + 'frame-char-width', 'frame-face-alist', 'frame-first-window', + 'frame-focus', 'frame-font-cache', 'frame-fringe-width', 'frame-list', + 'frame-live-p', 'frame-or-buffer-changed-p', 'frame-parameter', + 'frame-parameters', 'frame-pixel-height', 'frame-pixel-width', + 'frame-pointer-visible-p', 'frame-right-divider-width', + 'frame-root-window', 'frame-scroll-bar-height', + 'frame-scroll-bar-width', 'frame-selected-window', 'frame-terminal', + 'frame-text-cols', 'frame-text-height', 'frame-text-lines', + 'frame-text-width', 'frame-total-cols', 'frame-total-lines', + 'frame-visible-p', 'framep', 'frexp', 'fringe-bitmaps-at-pos', + 'fround', 'fset', 'ftruncate', 'funcall', 'funcall-interactively', + 'function-equal', 'functionp', 'gap-position', 'gap-size', + 'garbage-collect', 'gc-status', 'generate-new-buffer-name', 'get', + 'get-buffer', 'get-buffer-create', 'get-buffer-process', + 'get-buffer-window', 'get-byte', 'get-char-property', + 'get-char-property-and-overlay', 'get-file-buffer', 'get-file-char', + 'get-internal-run-time', 'get-load-suffixes', 'get-pos-property', + 'get-process', 'get-screen-color', 'get-text-property', + 'get-unicode-property-internal', 'get-unused-category', + 'get-unused-iso-final-char', 'getenv-internal', 'gethash', + 'gfile-add-watch', 'gfile-rm-watch', 'global-key-binding', + 'gnutls-available-p', 'gnutls-boot', 'gnutls-bye', 'gnutls-deinit', + 'gnutls-error-fatalp', 'gnutls-error-string', 'gnutls-errorp', + 'gnutls-get-initstage', 'gnutls-peer-status', + 'gnutls-peer-status-warning-describe', 'goto-char', 'gpm-mouse-start', + 'gpm-mouse-stop', 'group-gid', 'group-real-gid', + 'handle-save-session', 'handle-switch-frame', 'hash-table-count', + 'hash-table-p', 'hash-table-rehash-size', + 'hash-table-rehash-threshold', 'hash-table-size', 'hash-table-test', + 'hash-table-weakness', 'iconify-frame', 'identity', 'image-flush', + 'image-mask-p', 'image-metadata', 'image-size', 'imagemagick-types', + 'imagep', 'indent-to', 'indirect-function', 'indirect-variable', + 'init-image-library', 'inotify-add-watch', 'inotify-rm-watch', + 'input-pending-p', 'insert', 'insert-and-inherit', + 'insert-before-markers', 'insert-before-markers-and-inherit', + 'insert-buffer-substring', 'insert-byte', 'insert-char', + 'insert-file-contents', 'insert-startup-screen', 'int86', + 'integer-or-marker-p', 'integerp', 'interactive-form', 'intern', + 'intern-soft', 'internal--track-mouse', 'internal-char-font', + 'internal-complete-buffer', 'internal-copy-lisp-face', + 'internal-default-process-filter', + 'internal-default-process-sentinel', 'internal-describe-syntax-value', + 'internal-event-symbol-parse-modifiers', + 'internal-face-x-get-resource', 'internal-get-lisp-face-attribute', + 'internal-lisp-face-attribute-values', 'internal-lisp-face-empty-p', + 'internal-lisp-face-equal-p', 'internal-lisp-face-p', + 'internal-make-lisp-face', 'internal-make-var-non-special', + 'internal-merge-in-global-face', + 'internal-set-alternative-font-family-alist', + 'internal-set-alternative-font-registry-alist', + 'internal-set-font-selection-order', + 'internal-set-lisp-face-attribute', + 'internal-set-lisp-face-attribute-from-resource', + 'internal-show-cursor', 'internal-show-cursor-p', 'interrupt-process', + 'invisible-p', 'invocation-directory', 'invocation-name', 'isnan', + 'iso-charset', 'key-binding', 'key-description', + 'keyboard-coding-system', 'keymap-parent', 'keymap-prompt', 'keymapp', + 'keywordp', 'kill-all-local-variables', 'kill-buffer', 'kill-emacs', + 'kill-local-variable', 'kill-process', 'last-nonminibuffer-frame', + 'lax-plist-get', 'lax-plist-put', 'ldexp', 'length', + 'libxml-parse-html-region', 'libxml-parse-xml-region', + 'line-beginning-position', 'line-end-position', 'line-pixel-height', + 'list', 'list-fonts', 'list-system-processes', 'listp', 'load', + 'load-average', 'local-key-binding', 'local-variable-if-set-p', + 'local-variable-p', 'locale-info', 'locate-file-internal', + 'lock-buffer', 'log', 'logand', 'logb', 'logior', 'lognot', 'logxor', + 'looking-at', 'lookup-image', 'lookup-image-map', 'lookup-key', + 'lower-frame', 'lsh', 'macroexpand', 'make-bool-vector', + 'make-byte-code', 'make-category-set', 'make-category-table', + 'make-char', 'make-char-table', 'make-directory-internal', + 'make-frame-invisible', 'make-frame-visible', 'make-hash-table', + 'make-indirect-buffer', 'make-keymap', 'make-list', + 'make-local-variable', 'make-marker', 'make-network-process', + 'make-overlay', 'make-serial-process', 'make-sparse-keymap', + 'make-string', 'make-symbol', 'make-symbolic-link', 'make-temp-name', + 'make-terminal-frame', 'make-variable-buffer-local', + 'make-variable-frame-local', 'make-vector', 'makunbound', + 'map-char-table', 'map-charset-chars', 'map-keymap', + 'map-keymap-internal', 'mapatoms', 'mapc', 'mapcar', 'mapconcat', + 'maphash', 'mark-marker', 'marker-buffer', 'marker-insertion-type', + 'marker-position', 'markerp', 'match-beginning', 'match-data', + 'match-end', 'matching-paren', 'max', 'max-char', 'md5', 'member', + 'memory-info', 'memory-limit', 'memory-use-counts', 'memq', 'memql', + 'menu-bar-menu-at-x-y', 'menu-or-popup-active-p', + 'menu-or-popup-active-p', 'merge-face-attribute', 'message', + 'message-box', 'message-or-box', 'min', + 'minibuffer-completion-contents', 'minibuffer-contents', + 'minibuffer-contents-no-properties', 'minibuffer-depth', + 'minibuffer-prompt', 'minibuffer-prompt-end', + 'minibuffer-selected-window', 'minibuffer-window', 'minibufferp', + 'minor-mode-key-binding', 'mod', 'modify-category-entry', + 'modify-frame-parameters', 'modify-syntax-entry', + 'mouse-pixel-position', 'mouse-position', 'move-overlay', + 'move-point-visually', 'move-to-column', 'move-to-window-line', + 'msdos-downcase-filename', 'msdos-long-file-names', 'msdos-memget', + 'msdos-memput', 'msdos-mouse-disable', 'msdos-mouse-enable', + 'msdos-mouse-init', 'msdos-mouse-p', 'msdos-remember-default-colors', + 'msdos-set-keyboard', 'msdos-set-mouse-buttons', + 'multibyte-char-to-unibyte', 'multibyte-string-p', 'narrow-to-region', + 'natnump', 'nconc', 'network-interface-info', + 'network-interface-list', 'new-fontset', 'newline-cache-check', + 'next-char-property-change', 'next-frame', 'next-overlay-change', + 'next-property-change', 'next-read-file-uses-dialog-p', + 'next-single-char-property-change', 'next-single-property-change', + 'next-window', 'nlistp', 'nreverse', 'nth', 'nthcdr', 'null', + 'number-or-marker-p', 'number-to-string', 'numberp', + 'open-dribble-file', 'open-font', 'open-termscript', + 'optimize-char-table', 'other-buffer', 'other-window-for-scrolling', + 'overlay-buffer', 'overlay-end', 'overlay-get', 'overlay-lists', + 'overlay-properties', 'overlay-put', 'overlay-recenter', + 'overlay-start', 'overlayp', 'overlays-at', 'overlays-in', + 'parse-partial-sexp', 'play-sound-internal', 'plist-get', + 'plist-member', 'plist-put', 'point', 'point-marker', 'point-max', + 'point-max-marker', 'point-min', 'point-min-marker', + 'pos-visible-in-window-p', 'position-bytes', 'posix-looking-at', + 'posix-search-backward', 'posix-search-forward', 'posix-string-match', + 'posn-at-point', 'posn-at-x-y', 'preceding-char', + 'prefix-numeric-value', 'previous-char-property-change', + 'previous-frame', 'previous-overlay-change', + 'previous-property-change', 'previous-single-char-property-change', + 'previous-single-property-change', 'previous-window', 'prin1', + 'prin1-to-string', 'princ', 'print', 'process-attributes', + 'process-buffer', 'process-coding-system', 'process-command', + 'process-connection', 'process-contact', 'process-datagram-address', + 'process-exit-status', 'process-filter', 'process-filter-multibyte-p', + 'process-id', 'process-inherit-coding-system-flag', 'process-list', + 'process-mark', 'process-name', 'process-plist', + 'process-query-on-exit-flag', 'process-running-child-p', + 'process-send-eof', 'process-send-region', 'process-send-string', + 'process-sentinel', 'process-status', 'process-tty-name', + 'process-type', 'processp', 'profiler-cpu-log', + 'profiler-cpu-running-p', 'profiler-cpu-start', 'profiler-cpu-stop', + 'profiler-memory-log', 'profiler-memory-running-p', + 'profiler-memory-start', 'profiler-memory-stop', 'propertize', + 'purecopy', 'put', 'put-text-property', + 'put-unicode-property-internal', 'puthash', 'query-font', + 'query-fontset', 'quit-process', 'raise-frame', 'random', 'rassoc', + 'rassq', 're-search-backward', 're-search-forward', 'read', + 'read-buffer', 'read-char', 'read-char-exclusive', + 'read-coding-system', 'read-command', 'read-event', + 'read-from-minibuffer', 'read-from-string', 'read-function', + 'read-key-sequence', 'read-key-sequence-vector', + 'read-no-blanks-input', 'read-non-nil-coding-system', 'read-string', + 'read-variable', 'recent-auto-save-p', 'recent-doskeys', + 'recent-keys', 'recenter', 'recursion-depth', 'recursive-edit', + 'redirect-debugging-output', 'redirect-frame-focus', 'redisplay', + 'redraw-display', 'redraw-frame', 'regexp-quote', 'region-beginning', + 'region-end', 'register-ccl-program', 'register-code-conversion-map', + 'remhash', 'remove-list-of-text-properties', 'remove-text-properties', + 'rename-buffer', 'rename-file', 'replace-match', + 'reset-this-command-lengths', 'resize-mini-window-internal', + 'restore-buffer-modified-p', 'resume-tty', 'reverse', 'round', + 'run-hook-with-args', 'run-hook-with-args-until-failure', + 'run-hook-with-args-until-success', 'run-hook-wrapped', 'run-hooks', + 'run-window-configuration-change-hook', 'run-window-scroll-functions', + 'safe-length', 'scan-lists', 'scan-sexps', 'scroll-down', + 'scroll-left', 'scroll-other-window', 'scroll-right', 'scroll-up', + 'search-backward', 'search-forward', 'secure-hash', 'select-frame', + 'select-window', 'selected-frame', 'selected-window', + 'self-insert-command', 'send-string-to-terminal', 'sequencep', + 'serial-process-configure', 'set', 'set-buffer', + 'set-buffer-auto-saved', 'set-buffer-major-mode', + 'set-buffer-modified-p', 'set-buffer-multibyte', 'set-case-table', + 'set-category-table', 'set-char-table-extra-slot', + 'set-char-table-parent', 'set-char-table-range', 'set-charset-plist', + 'set-charset-priority', 'set-coding-system-priority', + 'set-cursor-size', 'set-default', 'set-default-file-modes', + 'set-default-toplevel-value', 'set-file-acl', 'set-file-modes', + 'set-file-selinux-context', 'set-file-times', 'set-fontset-font', + 'set-frame-height', 'set-frame-position', 'set-frame-selected-window', + 'set-frame-size', 'set-frame-width', 'set-fringe-bitmap-face', + 'set-input-interrupt-mode', 'set-input-meta-mode', 'set-input-mode', + 'set-keyboard-coding-system-internal', 'set-keymap-parent', + 'set-marker', 'set-marker-insertion-type', 'set-match-data', + 'set-message-beep', 'set-minibuffer-window', + 'set-mouse-pixel-position', 'set-mouse-position', + 'set-network-process-option', 'set-output-flow-control', + 'set-process-buffer', 'set-process-coding-system', + 'set-process-datagram-address', 'set-process-filter', + 'set-process-filter-multibyte', + 'set-process-inherit-coding-system-flag', 'set-process-plist', + 'set-process-query-on-exit-flag', 'set-process-sentinel', + 'set-process-window-size', 'set-quit-char', + 'set-safe-terminal-coding-system-internal', 'set-screen-color', + 'set-standard-case-table', 'set-syntax-table', + 'set-terminal-coding-system-internal', 'set-terminal-local-value', + 'set-terminal-parameter', 'set-text-properties', 'set-time-zone-rule', + 'set-visited-file-modtime', 'set-window-buffer', + 'set-window-combination-limit', 'set-window-configuration', + 'set-window-dedicated-p', 'set-window-display-table', + 'set-window-fringes', 'set-window-hscroll', 'set-window-margins', + 'set-window-new-normal', 'set-window-new-pixel', + 'set-window-new-total', 'set-window-next-buffers', + 'set-window-parameter', 'set-window-point', 'set-window-prev-buffers', + 'set-window-redisplay-end-trigger', 'set-window-scroll-bars', + 'set-window-start', 'set-window-vscroll', 'setcar', 'setcdr', + 'setplist', 'show-face-resources', 'signal', 'signal-process', 'sin', + 'single-key-description', 'skip-chars-backward', 'skip-chars-forward', + 'skip-syntax-backward', 'skip-syntax-forward', 'sleep-for', 'sort', + 'sort-charsets', 'special-variable-p', 'split-char', + 'split-window-internal', 'sqrt', 'standard-case-table', + 'standard-category-table', 'standard-syntax-table', 'start-kbd-macro', + 'start-process', 'stop-process', 'store-kbd-macro-event', 'string', + 'string-as-multibyte', 'string-as-unibyte', 'string-bytes', + 'string-collate-equalp', 'string-collate-lessp', 'string-equal', + 'string-lessp', 'string-make-multibyte', 'string-make-unibyte', + 'string-match', 'string-to-char', 'string-to-multibyte', + 'string-to-number', 'string-to-syntax', 'string-to-unibyte', + 'string-width', 'stringp', 'subr-name', 'subrp', + 'subst-char-in-region', 'substitute-command-keys', + 'substitute-in-file-name', 'substring', 'substring-no-properties', + 'suspend-emacs', 'suspend-tty', 'suspicious-object', 'sxhash', + 'symbol-function', 'symbol-name', 'symbol-plist', 'symbol-value', + 'symbolp', 'syntax-table', 'syntax-table-p', 'system-groups', + 'system-move-file-to-trash', 'system-name', 'system-users', 'tan', + 'terminal-coding-system', 'terminal-list', 'terminal-live-p', + 'terminal-local-value', 'terminal-name', 'terminal-parameter', + 'terminal-parameters', 'terpri', 'test-completion', + 'text-char-description', 'text-properties-at', 'text-property-any', + 'text-property-not-all', 'this-command-keys', + 'this-command-keys-vector', 'this-single-command-keys', + 'this-single-command-raw-keys', 'time-add', 'time-less-p', + 'time-subtract', 'tool-bar-get-system-style', 'tool-bar-height', + 'tool-bar-pixel-width', 'top-level', 'trace-redisplay', + 'trace-to-stderr', 'translate-region-internal', 'transpose-regions', + 'truncate', 'try-completion', 'tty-display-color-cells', + 'tty-display-color-p', 'tty-no-underline', + 'tty-suppress-bold-inverse-default-colors', 'tty-top-frame', + 'tty-type', 'type-of', 'undo-boundary', 'unencodable-char-position', + 'unhandled-file-name-directory', 'unibyte-char-to-multibyte', + 'unibyte-string', 'unicode-property-table-internal', 'unify-charset', + 'unintern', 'unix-sync', 'unlock-buffer', 'upcase', 'upcase-initials', + 'upcase-initials-region', 'upcase-region', 'upcase-word', + 'use-global-map', 'use-local-map', 'user-full-name', + 'user-login-name', 'user-real-login-name', 'user-real-uid', + 'user-uid', 'variable-binding-locus', 'vconcat', 'vector', + 'vector-or-char-table-p', 'vectorp', 'verify-visited-file-modtime', + 'vertical-motion', 'visible-frame-list', 'visited-file-modtime', + 'w16-get-clipboard-data', 'w16-selection-exists-p', + 'w16-set-clipboard-data', 'w32-battery-status', + 'w32-default-color-map', 'w32-define-rgb-color', + 'w32-display-monitor-attributes-list', 'w32-frame-menu-bar-size', + 'w32-frame-rect', 'w32-get-clipboard-data', + 'w32-get-codepage-charset', 'w32-get-console-codepage', + 'w32-get-console-output-codepage', 'w32-get-current-locale-id', + 'w32-get-default-locale-id', 'w32-get-keyboard-layout', + 'w32-get-locale-info', 'w32-get-valid-codepages', + 'w32-get-valid-keyboard-layouts', 'w32-get-valid-locale-ids', + 'w32-has-winsock', 'w32-long-file-name', 'w32-reconstruct-hot-key', + 'w32-register-hot-key', 'w32-registered-hot-keys', + 'w32-selection-exists-p', 'w32-send-sys-command', + 'w32-set-clipboard-data', 'w32-set-console-codepage', + 'w32-set-console-output-codepage', 'w32-set-current-locale', + 'w32-set-keyboard-layout', 'w32-set-process-priority', + 'w32-shell-execute', 'w32-short-file-name', 'w32-toggle-lock-key', + 'w32-unload-winsock', 'w32-unregister-hot-key', 'w32-window-exists-p', + 'w32notify-add-watch', 'w32notify-rm-watch', + 'waiting-for-user-input-p', 'where-is-internal', 'widen', + 'widget-apply', 'widget-get', 'widget-put', + 'window-absolute-pixel-edges', 'window-at', 'window-body-height', + 'window-body-width', 'window-bottom-divider-width', 'window-buffer', + 'window-combination-limit', 'window-configuration-frame', + 'window-configuration-p', 'window-dedicated-p', + 'window-display-table', 'window-edges', 'window-end', 'window-frame', + 'window-fringes', 'window-header-line-height', 'window-hscroll', + 'window-inside-absolute-pixel-edges', 'window-inside-edges', + 'window-inside-pixel-edges', 'window-left-child', + 'window-left-column', 'window-line-height', 'window-list', + 'window-list-1', 'window-live-p', 'window-margins', + 'window-minibuffer-p', 'window-mode-line-height', 'window-new-normal', + 'window-new-pixel', 'window-new-total', 'window-next-buffers', + 'window-next-sibling', 'window-normal-size', 'window-old-point', + 'window-parameter', 'window-parameters', 'window-parent', + 'window-pixel-edges', 'window-pixel-height', 'window-pixel-left', + 'window-pixel-top', 'window-pixel-width', 'window-point', + 'window-prev-buffers', 'window-prev-sibling', + 'window-redisplay-end-trigger', 'window-resize-apply', + 'window-resize-apply-total', 'window-right-divider-width', + 'window-scroll-bar-height', 'window-scroll-bar-width', + 'window-scroll-bars', 'window-start', 'window-system', + 'window-text-height', 'window-text-pixel-size', 'window-text-width', + 'window-top-child', 'window-top-line', 'window-total-height', + 'window-total-width', 'window-use-time', 'window-valid-p', + 'window-vscroll', 'windowp', 'write-char', 'write-region', + 'x-backspace-delete-keys-p', 'x-change-window-property', + 'x-change-window-property', 'x-close-connection', + 'x-close-connection', 'x-create-frame', 'x-create-frame', + 'x-delete-window-property', 'x-delete-window-property', + 'x-disown-selection-internal', 'x-display-backing-store', + 'x-display-backing-store', 'x-display-color-cells', + 'x-display-color-cells', 'x-display-grayscale-p', + 'x-display-grayscale-p', 'x-display-list', 'x-display-list', + 'x-display-mm-height', 'x-display-mm-height', 'x-display-mm-width', + 'x-display-mm-width', 'x-display-monitor-attributes-list', + 'x-display-pixel-height', 'x-display-pixel-height', + 'x-display-pixel-width', 'x-display-pixel-width', 'x-display-planes', + 'x-display-planes', 'x-display-save-under', 'x-display-save-under', + 'x-display-screens', 'x-display-screens', 'x-display-visual-class', + 'x-display-visual-class', 'x-family-fonts', 'x-file-dialog', + 'x-file-dialog', 'x-file-dialog', 'x-focus-frame', 'x-frame-geometry', + 'x-frame-geometry', 'x-get-atom-name', 'x-get-resource', + 'x-get-selection-internal', 'x-hide-tip', 'x-hide-tip', + 'x-list-fonts', 'x-load-color-file', 'x-menu-bar-open-internal', + 'x-menu-bar-open-internal', 'x-open-connection', 'x-open-connection', + 'x-own-selection-internal', 'x-parse-geometry', 'x-popup-dialog', + 'x-popup-menu', 'x-register-dnd-atom', 'x-select-font', + 'x-select-font', 'x-selection-exists-p', 'x-selection-owner-p', + 'x-send-client-message', 'x-server-max-request-size', + 'x-server-max-request-size', 'x-server-vendor', 'x-server-vendor', + 'x-server-version', 'x-server-version', 'x-show-tip', 'x-show-tip', + 'x-synchronize', 'x-synchronize', 'x-uses-old-gtk-dialog', + 'x-window-property', 'x-window-property', 'x-wm-set-size-hint', + 'xw-color-defined-p', 'xw-color-defined-p', 'xw-color-values', + 'xw-color-values', 'xw-display-color-p', 'xw-display-color-p', + 'yes-or-no-p', 'zlib-available-p', 'zlib-decompress-region', + 'forward-point', + )) + + builtin_function_highlighted = set(( + 'defvaralias', 'provide', 'require', + 'with-no-warnings', 'define-widget', 'with-electric-help', + 'throw', 'defalias', 'featurep' + )) + + lambda_list_keywords = set(( + '&allow-other-keys', '&aux', '&body', '&environment', '&key', '&optional', + '&rest', '&whole', + )) + + error_keywords = set(( + 'cl-assert', 'cl-check-type', 'error', 'signal', + 'user-error', 'warn', + )) + + def get_tokens_unprocessed(self, text): + stack = ['root'] + for index, token, value in RegexLexer.get_tokens_unprocessed(self, text, stack): + if token is Name.Variable: + if value in EmacsLispLexer.builtin_function: + yield index, Name.Function, value + continue + if value in EmacsLispLexer.special_forms: + yield index, Keyword, value + continue + if value in EmacsLispLexer.error_keywords: + yield index, Name.Exception, value + continue + if value in EmacsLispLexer.builtin_function_highlighted: + yield index, Name.Builtin, value + continue + if value in EmacsLispLexer.macros: + yield index, Name.Builtin, value + continue + if value in EmacsLispLexer.lambda_list_keywords: + yield index, Keyword.Pseudo, value + continue + yield index, token, value + + tokens = { + 'root': [ + default('body'), + ], + 'body': [ + # whitespace + (r'\s+', Text), + + # single-line comment + (r';.*$', Comment.Single), + + # encoding comment (?) + (r'#\d*Y.*$', Comment.Special), + + # strings and characters + (r'"(\\.|\\\n|[^"\\])*"', String), + # quoting + (r":" + symbol, Name.Builtin), + (r"::" + symbol, String.Symbol), + (r":#" + symbol, String.Symbol), + (r"'" + symbol, String.Symbol), + (r"'", Operator), + (r"`", Operator), + + # decimal numbers + (r'[-+]?\d+\.?' + terminated, Number.Integer), + (r'[-+]?\d+/\d+' + terminated, Number), + (r'[-+]?(\d*\.\d+([defls][-+]?\d+)?|\d+(\.\d*)?[defls][-+]?\d+)' + + terminated, Number.Float), + + # sharpsign strings and characters + (r"#\\." + terminated, String.Char), + (r"#\\" + symbol, String.Char), + + # vector + (r'#\(', Operator, 'body'), + + # bitstring + (r'#\d*\*[01]*', Literal.Other), + + # uninterned symbol + (r'#:' + symbol, String.Symbol), + + # read-time and load-time evaluation + (r'#[.,]', Operator), + + # function shorthand + (r'#\'', Name.Function), + + # binary rational + (r'#b[+-]?[01]+(/[01]+)?', Number.Bin), + + # octal rational + (r'#o[+-]?[0-7]+(/[0-7]+)?', Number.Oct), + + # hex rational + (r'#x[+-]?[0-9a-f]+(/[0-9a-f]+)?', Number.Hex), + + # radix rational + (r'#\d+r[+-]?[0-9a-z]+(/[0-9a-z]+)?', Number), + + # complex + (r'(#c)(\()', bygroups(Number, Punctuation), 'body'), + + # array + (r'(#\d+a)(\()', bygroups(Literal.Other, Punctuation), 'body'), + + # structure + (r'(#s)(\()', bygroups(Literal.Other, Punctuation), 'body'), + + # path + (r'#p?"(\\.|[^"])*"', Literal.Other), + + # reference + (r'#\d+=', Operator), + (r'#\d+#', Operator), + + # read-time conditional + (r'#[+-]', Operator), + + # special operators that should have been parsed already + (r'(,@|,|\.)', Operator), + + # special constants + (r'(t|nil)' + terminated, Name.Constant), + + # functions and variables + (r'\*' + symbol + '\*', Name.Variable.Global), + (symbol, Name.Variable), + + # parentheses + (r'\(', Punctuation, 'body'), + (r'\)', Punctuation, '#pop'), + ], + } -- cgit v1.2.1 From 9ce1f8ce800f5308d0df46a0a4aee874039abb64 Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Wed, 24 Dec 2014 14:34:46 +0100 Subject: Ran `make mapfiles` for EmacsLispLexer tests/examplefiles/ediff.el: Add. --- pygments/formatters/_mapping.py | 1 - pygments/lexers/_mapping.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/pygments/formatters/_mapping.py b/pygments/formatters/_mapping.py index 678c069d..bc4d606e 100755 --- a/pygments/formatters/_mapping.py +++ b/pygments/formatters/_mapping.py @@ -32,7 +32,6 @@ FORMATTERS = { 'TestcaseFormatter': ('pygments.formatters.other', 'Testcase', ('testcase',), (), 'Format tokens as appropriate for a new testcase.') } - if __name__ == '__main__': # pragma: no cover import sys import os diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 05ada4f3..7a40f195 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -113,6 +113,7 @@ LEXERS = { 'EiffelLexer': ('pygments.lexers.eiffel', 'Eiffel', ('eiffel',), ('*.e',), ('text/x-eiffel',)), 'ElixirConsoleLexer': ('pygments.lexers.erlang', 'Elixir iex session', ('iex',), (), ('text/x-elixir-shellsession',)), 'ElixirLexer': ('pygments.lexers.erlang', 'Elixir', ('elixir', 'ex', 'exs'), ('*.ex', '*.exs'), ('text/x-elixir',)), + 'EmacsLispLexer': ('pygments.lexers.lisp', 'EmacsLisp', ('emacs', 'elisp'), ('*.el',), ('text/x-elisp', 'application/x-elisp')), 'ErbLexer': ('pygments.lexers.templates', 'ERB', ('erb',), (), ('application/x-ruby-templating',)), 'ErlangLexer': ('pygments.lexers.erlang', 'Erlang', ('erlang',), ('*.erl', '*.hrl', '*.es', '*.escript'), ('text/x-erlang',)), 'ErlangShellLexer': ('pygments.lexers.erlang', 'Erlang erl session', ('erl',), ('*.erl-sh',), ('text/x-erl-shellsession',)), -- cgit v1.2.1 From cee05919253a9524fc82644e3e40e867cabb23fd Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Wed, 24 Dec 2014 17:00:03 +0100 Subject: Fix EmacsLispLexer. Now `make test` passes. --- pygments/formatters/_mapping.py | 1 + pygments/lexers/_mapping.py | 2 +- pygments/lexers/lisp.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pygments/formatters/_mapping.py b/pygments/formatters/_mapping.py index bc4d606e..678c069d 100755 --- a/pygments/formatters/_mapping.py +++ b/pygments/formatters/_mapping.py @@ -32,6 +32,7 @@ FORMATTERS = { 'TestcaseFormatter': ('pygments.formatters.other', 'Testcase', ('testcase',), (), 'Format tokens as appropriate for a new testcase.') } + if __name__ == '__main__': # pragma: no cover import sys import os diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 7a40f195..7044c1df 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -77,7 +77,7 @@ LEXERS = { 'ColdfusionCFCLexer': ('pygments.lexers.templates', 'Coldfusion CFC', ('cfc',), ('*.cfc',), ()), 'ColdfusionHtmlLexer': ('pygments.lexers.templates', 'Coldfusion HTML', ('cfm',), ('*.cfm', '*.cfml'), ('application/x-coldfusion',)), 'ColdfusionLexer': ('pygments.lexers.templates', 'cfstatement', ('cfs',), (), ()), - 'CommonLispLexer': ('pygments.lexers.lisp', 'Common Lisp', ('common-lisp', 'cl', 'lisp', 'elisp', 'emacs', 'emacs-lisp'), ('*.cl', '*.lisp', '*.el'), ('text/x-common-lisp',)), + 'CommonLispLexer': ('pygments.lexers.lisp', 'Common Lisp', ('common-lisp', 'cl', 'lisp'), ('*.cl', '*.lisp'), ('text/x-common-lisp',)), 'CoqLexer': ('pygments.lexers.theorem', 'Coq', ('coq',), ('*.v',), ('text/x-coq',)), 'CppLexer': ('pygments.lexers.c_cpp', 'C++', ('cpp', 'c++'), ('*.cpp', '*.hpp', '*.c++', '*.h++', '*.cc', '*.hh', '*.cxx', '*.hxx', '*.C', '*.H', '*.cp', '*.CPP'), ('text/x-c++hdr', 'text/x-c++src')), 'CppObjdumpLexer': ('pygments.lexers.asm', 'cpp-objdump', ('cpp-objdump', 'c++-objdumb', 'cxx-objdump'), ('*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'), ('text/x-cpp-objdump',)), diff --git a/pygments/lexers/lisp.py b/pygments/lexers/lisp.py index 21bc31e9..cff52b34 100644 --- a/pygments/lexers/lisp.py +++ b/pygments/lexers/lisp.py @@ -171,8 +171,8 @@ class CommonLispLexer(RegexLexer): .. versionadded:: 0.9 """ name = 'Common Lisp' - aliases = ['common-lisp', 'cl', 'lisp', 'elisp', 'emacs', 'emacs-lisp'] - filenames = ['*.cl', '*.lisp', '*.el'] # use for Elisp too + aliases = ['common-lisp', 'cl', 'lisp'] + filenames = ['*.cl', '*.lisp'] mimetypes = ['text/x-common-lisp'] flags = re.IGNORECASE | re.MULTILINE -- cgit v1.2.1 From 5a6b44cae1edbea60db15217de4b745bd38c54bc Mon Sep 17 00:00:00 2001 From: James Edwards Date: Sat, 27 Dec 2014 18:38:08 +0000 Subject: Added a new lexer for Terraform files. Should hopefully syntax highlight terraform *.tf files. Syntax is similar to json but not identical and it has it's own keywords and lookup functions. More details here: https://www.terraform.io/docs/configuration/index.html --- pygments/lexers/terraform.py | 82 +++++++++++++++++++++ tests/examplefiles/example.tf | 162 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+) create mode 100644 pygments/lexers/terraform.py create mode 100644 tests/examplefiles/example.tf diff --git a/pygments/lexers/terraform.py b/pygments/lexers/terraform.py new file mode 100644 index 00000000..1600d154 --- /dev/null +++ b/pygments/lexers/terraform.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +""" + pygments.lexers.terraform + ~~~~~~~~~~~~~~~~~~~~~ + + Lexer for Terraform tf files + + :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import re + +from pygments.lexer import Lexer, RegexLexer, bygroups, include +from pygments.token import Text, Comment, Operator, Keyword, Name, String, Punctuation, Number +__all__ = ['TerraformLexer'] + +class TerraformLexer(RegexLexer): + """ + Lexer for terraformi .tf files: https://www.terraform.io/ + + """ + name = 'Terraform' + aliases = ['terraform', 'tf'] + filenames = ['*.tf'] + mimetypes = ['application/x-tf', 'application/x-terraform'] + tokens = { + 'root': [ + include ('string'), + include ('punctuation'), + include ('curly'), + include('basic'), + include('whitespace'), + (r'[0-9]+', Number), + ], + 'basic': [ + (r'\b(true|false)\b', Keyword.Type), + (r'\s*/\*', Comment.Multiline, 'comment'), + (r'\s*#.*\n', Comment.Single), + (r'(.*?)(\s*)(=)', + bygroups(Name.Attribute, Text, Operator)), + (r'\bvariable|resource|provider|provisioner|module\b',Keyword.Reserved,'function'), + (r'\bingress|egress|listener|default|connection\b',Keyword.Declaration), + ('\$\{',String.Interpol,'var_builtin'), + ], + 'function':[ + (r'(\s+)(".*")(\s+)', bygroups(Text,String,Text)), + include ('punctuation'), + include ('curly'), + ], + 'var_builtin':[ + (r'\$\{', String.Interpol, '#push'), + (r'\bconcat|file|join|lookup|element\b',Name.Builtin), + include ('string'), + include ('punctuation'), + (r'\s+', Text), + (r'\}',String.Interpol, '#pop'), + ], + 'string':[ + (r'(".*")',bygroups(String.Double)), + ], + 'punctuation':[ + (r'[\[\]\(\),.]',Punctuation), + ], + # Keep this seperate from punctuation - we sometimes want to use different + # Tokens for { } + 'curly':[ + (r'\{',Text.Punctuation), + (r'\}',Text.Punctuation), + ], + 'comment': [ + (r'[^*/]', Comment.Multiline), + (r'/\*', Comment.Multiline, '#push'), + (r'\*/', Comment.Multiline, '#pop'), + (r'[*/]', Comment.Multiline) + ], + 'whitespace': [ + (r'\n', Text), + (r'\s+', Text), + (r'\\\n', Text), + ], + } diff --git a/tests/examplefiles/example.tf b/tests/examplefiles/example.tf new file mode 100644 index 00000000..d3f02779 --- /dev/null +++ b/tests/examplefiles/example.tf @@ -0,0 +1,162 @@ +variable "key_name" { + description = "Name of the SSH keypair to use in AWS." +} + +variable "key_path" { + description = "Path to the private portion of the SSH key specified." +} + +variable "aws_region" { + description = "AWS region to launch servers." + default = "us-west-2" + somevar = true +} + +# Ubuntu Precise 12.04 LTS (x64) +variable "aws_amis" { + default = { + eu-west-1 = "ami-b1cf19c6" + us-east-1 = "ami-de7ab6b6" + us-west-1 = "ami-3f75767a" + us-west-2 = "ami-21f78e11" + } +} + + + + + + +provider "aws" { + access_key = "${myvar}" + secret_key = "your aws secret key" + region = "us-east-1" +} +/* multiline + + comment + +*/ + + +# Single line comment +resource "aws_instance" "example" { + ami = "ami-408c7f28" + instance_type = "t1.micro" + key_name = "your-aws-key-name" +} + +# Create our Heroku application. Heroku will +# automatically assign a name. +resource "heroku_app" "web" {} + +# Create our DNSimple record to point to the +# heroku application. +resource "dnsimple_record" "web" { + domain = "${var.dnsimple_domain}" + + + # heroku_hostname is a computed attribute on the heroku + # application we can use to determine the hostname + value = "${heroku_app.web.heroku_hostname}" + + type = "CNAME" + ttl = 3600 +} + +# The Heroku domain, which will be created and added +# to the heroku application after we have assigned the domain +# in DNSimple +resource "heroku_domain" "foobar" { + app = "${heroku_app.web.name}" + hostname = "${dnsimple_record.web.hostname}" +} + + +# Specify the provider and access details +provider "aws" { + region = "${var.aws_region}" + value = ${file("path.txt")} +} + +# Our default security group to access +# the instances over SSH and HTTP +resource "aws_security_group" "default" { + name = "terraform_example" + description = "Used in the terraform" + + # SSH access from anywhere + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + # HTTP access from anywhere + ingress { + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } +} + + +resource "aws_elb" "web" { + name = "terraform-example-elb" + + # The same availability zone as our instance + availability_zones = ["${aws_instance.web.availability_zone}"] + + listener { + instance_port = 80 + instance_protocol = "http" + lb_port = 80 + lb_protocol = "http" + } + + # The instance is registered automatically + instances = ["${aws_instance.web.id}"] +} + + +resource "aws_instance" "web" { + # The connection block tells our provisioner how to + # communicate with the resource (instance) + connection { + # The default username for our AMI + user = "ubuntu" + + # The path to your keyfile + key_file = "${var.key_path}" + } + + instance_type = "m1.small" + + # Lookup the correct AMI based on the region + # we specified + ami = "${lookup(var.aws_amis, var.aws_region)}" + + # The name of our SSH keypair you've created and downloaded + # from the AWS console. + # + # https://console.aws.amazon.com/ec2/v2/home?region=us-west-2#KeyPairs: + # + key_name = "${var.key_name}" + + # Our Security group to allow HTTP and SSH access + security_groups = ["${aws_security_group.default.name}"] + + # We run a remote provisioner on the instance after creating it. + # In this case, we just install nginx and start it. By default, + # this should be on port 80 + provisioner "remote-exec" { + inline = [ + "sudo apt-get -y update", + "sudo apt-get -y install nginx", + "sudo service nginx start" + ] + } +} + -- cgit v1.2.1 From c5f9bab22bc0487090381b7baec70aacb2307432 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Mon, 29 Dec 2014 21:35:18 +0100 Subject: updated cocoa builtins for iOS 8.1 --- pygments/lexers/_cocoa_builtins.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pygments/lexers/_cocoa_builtins.py b/pygments/lexers/_cocoa_builtins.py index 84f3eeea..48918ce6 100644 --- a/pygments/lexers/_cocoa_builtins.py +++ b/pygments/lexers/_cocoa_builtins.py @@ -14,16 +14,15 @@ from __future__ import print_function -COCOA_INTERFACES = set(['UITableViewCell', 'HKCorrelationQuery', 'NSURLSessionDataTask', 'PHFetchOptions', 'NSLinguisticTagger', 'NSStream', 'AVAudioUnitDelay', 'GCMotion', 'SKPhysicsWorld', 'NSString', 'CMAttitude', 'AVAudioEnvironmentDistanceAttenuationParameters', 'HKStatisticsCollection', 'SCNPlane', 'CBPeer', 'JSContext', 'SCNTransaction', 'SCNTorus', 'AVAudioUnitEffect', 'UICollectionReusableView', 'MTLSamplerDescriptor', 'AVAssetReaderSampleReferenceOutput', 'AVMutableCompositionTrack', 'GKLeaderboard', 'NSFetchedResultsController', 'SKRange', 'MKTileOverlayRenderer', 'MIDINetworkSession', 'UIVisualEffectView', 'CIWarpKernel', 'PKObject', 'MKRoute', 'MPVolumeView', 'UIPrintInfo', 'SCNText', 'ADClient', 'UIKeyCommand', 'AVMutableAudioMix', 'GLKEffectPropertyLight', 'WKScriptMessage', 'AVMIDIPlayer', 'PHCollectionListChangeRequest', 'UICollectionViewLayout', 'NSMutableCharacterSet', 'SKPaymentTransaction', 'NEOnDemandRuleConnect', 'NSShadow', 'SCNView', 'NSURLSessionConfiguration', 'MTLVertexAttributeDescriptor', 'CBCharacteristic', 'HKQuantityType', 'CKLocationSortDescriptor', 'NEVPNIKEv2SecurityAssociationParameters', 'CMStepCounter', 'NSNetService', 'AVAssetWriterInputMetadataAdaptor', 'UICollectionView', 'UIViewPrintFormatter', 'SCNLevelOfDetail', 'CAShapeLayer', 'MCPeerID', 'MPRatingCommand', 'WKNavigation', 'NSDictionary', 'NSFileVersion', 'CMGyroData', 'AVAudioUnitDistortion', 'CKFetchRecordsOperation', 'SKPhysicsJointSpring', 'SCNHitTestResult', 'AVAudioTime', 'CIFilter', 'UIView', 'SCNConstraint', 'CAPropertyAnimation', 'MKMapItem', 'MPRemoteCommandCenter', 'UICollectionViewFlowLayoutInvalidationContext', 'UIInputViewController', 'PKPass', 'SCNPhysicsBehavior', 'MTLRenderPassColorAttachmentDescriptor', 'MKPolygonRenderer', 'CKNotification', 'JSValue', 'PHCollectionList', 'CLGeocoder', 'NSByteCountFormatter', 'AVCaptureScreenInput', 'MPFeedbackCommand', 'CAAnimation', 'MKOverlayPathView', 'UIActionSheet', 'UIMotionEffectGroup', 'NSLengthFormatter', 'UIBarItem', 'SKProduct', 'AVAssetExportSession', 'NSKeyedUnarchiver', 'NSMutableSet', 'SCNPyramid', 'PHAssetCollection', 'MKMapView', 'HMHomeManager', 'CATransition', 'MTLCompileOptions', 'UIVibrancyEffect', 'CLCircularRegion', 'MKTileOverlay', 'SCNShape', 'ACAccountCredential', 'SKPhysicsJointLimit', 'MKMapSnapshotter', 'AVMediaSelectionGroup', 'NSIndexSet', 'CBPeripheralManager', 'CKRecordZone', 'AVAudioRecorder', 'NSURL', 'CBCentral', 'NSNumber', 'AVAudioOutputNode', 'MTLVertexAttributeDescriptorArray', 'MKETAResponse', 'SKTransition', 'SSReadingList', 'HKSourceQuery', 'UITableViewRowAction', 'UITableView', 'SCNParticlePropertyController', 'AVCaptureStillImageOutput', 'GCController', 'AVAudioPlayerNode', 'AVAudioSessionPortDescription', 'NSHTTPURLResponse', 'NEOnDemandRuleEvaluateConnection', 'SKEffectNode', 'HKQuantity', 'GCControllerElement', 'AVPlayerItemAccessLogEvent', 'SCNBox', 'NSExtensionContext', 'MKOverlayRenderer', 'SCNPhysicsVehicle', 'NSDecimalNumber', 'EKReminder', 'MKPolylineView', 'CKQuery', 'AVAudioMixerNode', 'GKAchievementDescription', 'EKParticipant', 'NSBlockOperation', 'UIActivityItemProvider', 'CLLocation', 'NSBatchUpdateRequest', 'PHContentEditingOutput', 'PHObjectChangeDetails', 'MPMoviePlayerController', 'AVAudioFormat', 'HMTrigger', 'MTLRenderPassDepthAttachmentDescriptor', 'SCNRenderer', 'GKScore', 'UISplitViewController', 'HKSource', 'NSURLConnection', 'ABUnknownPersonViewController', 'SCNTechnique', 'UIMenuController', 'NSEvent', 'SKTextureAtlas', 'NSKeyedArchiver', 'GKLeaderboardSet', 'NSSimpleCString', 'AVAudioPCMBuffer', 'CBATTRequest', 'GKMatchRequest', 'AVMetadataObject', 'SKProductsRequest', 'UIAlertView', 'NSIncrementalStore', 'MFMailComposeViewController', 'SCNFloor', 'NSSortDescriptor', 'CKFetchNotificationChangesOperation', 'MPMovieAccessLog', 'NSManagedObjectContext', 'AVAudioUnitGenerator', 'WKBackForwardList', 'SKMutableTexture', 'AVCaptureAudioDataOutput', 'ACAccount', 'AVMetadataItem', 'MPRatingCommandEvent', 'AVCaptureDeviceInputSource', 'CLLocationManager', 'MPRemoteCommand', 'AVCaptureSession', 'UIStepper', 'UIRefreshControl', 'NEEvaluateConnectionRule', 'CKModifyRecordsOperation', 'UICollectionViewTransitionLayout', 'CBCentralManager', 'NSPurgeableData', 'SLComposeViewController', 'NSHashTable', 'MKUserTrackingBarButtonItem', 'UILexiconEntry', 'CMMotionActivity', 'SKAction', 'SKShader', 'AVPlayerItemOutput', 'MTLRenderPassAttachmentDescriptor', 'UIDocumentInteractionController', 'UIDynamicItemBehavior', 'NSMutableDictionary', 'UILabel', 'AVCaptureInputPort', 'NSExpression', 'CAInterAppAudioTransportView', 'SKMutablePayment', 'UIImage', 'PHCachingImageManager', 'SCNTransformConstraint', 'UIColor', 'SCNGeometrySource', 'AVCaptureAutoExposureBracketedStillImageSettings', 'UIPopoverBackgroundView', 'UIToolbar', 'NSNotificationCenter', 'AVAssetReaderOutputMetadataAdaptor', 'NSEntityMigrationPolicy', 'NSLocale', 'NSURLSession', 'SCNCamera', 'NSTimeZone', 'UIManagedDocument', 'AVMutableVideoCompositionLayerInstruction', 'AVAssetTrackGroup', 'NSInvocationOperation', 'ALAssetRepresentation', 'AVQueuePlayer', 'HMServiceGroup', 'UIPasteboard', 'PHContentEditingInput', 'NSLayoutManager', 'EKCalendarChooser', 'EKObject', 'CATiledLayer', 'GLKReflectionMapEffect', 'NSManagedObjectID', 'NSEnergyFormatter', 'SLRequest', 'HMCharacteristic', 'AVPlayerLayer', 'MTLRenderPassDescriptor', 'SKPayment', 'NSPointerArray', 'AVAudioMix', 'SCNLight', 'MCAdvertiserAssistant', 'MKMapSnapshotOptions', 'HKCategorySample', 'AVAudioEnvironmentReverbParameters', 'SCNMorpher', 'AVTimedMetadataGroup', 'CBMutableCharacteristic', 'NSFetchRequest', 'UIDevice', 'NSManagedObject', 'NKAssetDownload', 'AVOutputSettingsAssistant', 'SKPhysicsJointPin', 'UITabBar', 'UITextInputMode', 'NSFetchRequestExpression', 'HMActionSet', 'CTSubscriber', 'PHAssetChangeRequest', 'NSPersistentStoreRequest', 'UITabBarController', 'HKQuantitySample', 'AVPlayerItem', 'AVSynchronizedLayer', 'MKDirectionsRequest', 'NSMetadataItem', 'UIPresentationController', 'UINavigationItem', 'PHFetchResultChangeDetails', 'PHImageManager', 'AVCaptureManualExposureBracketedStillImageSettings', 'UIStoryboardPopoverSegue', 'SCNLookAtConstraint', 'UIGravityBehavior', 'UIWindow', 'CBMutableDescriptor', 'NEOnDemandRuleDisconnect', 'UIBezierPath', 'UINavigationController', 'ABPeoplePickerNavigationController', 'EKSource', 'AVAssetWriterInput', 'AVPlayerItemTrack', 'GLKEffectPropertyTexture', 'NSURLResponse', 'SKPaymentQueue', 'NSAssertionHandler', 'MKReverseGeocoder', 'GCControllerAxisInput', 'NSArray', 'NSOrthography', 'NSURLSessionUploadTask', 'NSCharacterSet', 'AVMutableVideoCompositionInstruction', 'AVAssetReaderOutput', 'EAGLContext', 'WKFrameInfo', 'CMPedometer', 'MyClass', 'CKModifyBadgeOperation', 'AVCaptureAudioFileOutput', 'SKEmitterNode', 'NSMachPort', 'AVVideoCompositionCoreAnimationTool', 'PHCollection', 'SCNPhysicsWorld', 'NSURLRequest', 'CMAccelerometerData', 'NSNetServiceBrowser', 'CLFloor', 'AVAsynchronousVideoCompositionRequest', 'SCNGeometry', 'SCNIKConstraint', 'CIKernel', 'CAGradientLayer', 'HKCharacteristicType', 'NSFormatter', 'SCNAction', 'CATransaction', 'CBUUID', 'UIStoryboard', 'MPMediaLibrary', 'UITapGestureRecognizer', 'MPMediaItemArtwork', 'NSURLSessionTask', 'AVAudioUnit', 'MCBrowserViewController', 'NSRelationshipDescription', 'HKSample', 'WKWebView', 'NSMutableAttributedString', 'NSPersistentStoreAsynchronousResult', 'MPNowPlayingInfoCenter', 'MKLocalSearch', 'EAAccessory', 'HKCorrelation', 'CATextLayer', 'NSNotificationQueue', 'UINib', 'GLKTextureLoader', 'HKObjectType', 'NSValue', 'NSMutableIndexSet', 'SKPhysicsContact', 'NSProgress', 'AVPlayerViewController', 'CAScrollLayer', 'GKSavedGame', 'NSTextCheckingResult', 'PHObjectPlaceholder', 'SKConstraint', 'EKEventEditViewController', 'NSEntityDescription', 'NSURLCredentialStorage', 'UIApplication', 'SKDownload', 'SCNNode', 'MKLocalSearchRequest', 'SKScene', 'UISearchDisplayController', 'NEOnDemandRule', 'MTLRenderPassStencilAttachmentDescriptor', 'CAReplicatorLayer', 'UIPrintPageRenderer', 'EKCalendarItem', 'NSUUID', 'EAAccessoryManager', 'NEOnDemandRuleIgnore', 'SKRegion', 'AVAssetResourceLoader', 'EAWiFiUnconfiguredAccessoryBrowser', 'NSUserActivity', 'CTCall', 'UIPrinterPickerController', 'CIVector', 'UINavigationBar', 'UIPanGestureRecognizer', 'MPMediaQuery', 'ABNewPersonViewController', 'CKRecordZoneID', 'HKAnchoredObjectQuery', 'CKFetchRecordZonesOperation', 'UIStoryboardSegue', 'ACAccountType', 'GKSession', 'SKVideoNode', 'PHChange', 'SKReceiptRefreshRequest', 'GCExtendedGamepadSnapshot', 'MPSeekCommandEvent', 'GCExtendedGamepad', 'CAValueFunction', 'SCNCylinder', 'NSNotification', 'NSBatchUpdateResult', 'PKPushCredentials', 'SCNPhysicsSliderJoint', 'AVCaptureDeviceFormat', 'AVPlayerItemErrorLog', 'NSMapTable', 'NSSet', 'CMMotionManager', 'GKVoiceChatService', 'UIPageControl', 'UILexicon', 'MTLArrayType', 'AVAudioUnitReverb', 'MKGeodesicPolyline', 'AVMutableComposition', 'NSLayoutConstraint', 'UIPrinter', 'NSOrderedSet', 'CBAttribute', 'PKPushPayload', 'NSIncrementalStoreNode', 'EKEventStore', 'MPRemoteCommandEvent', 'UISlider', 'UIBlurEffect', 'CKAsset', 'AVCaptureInput', 'AVAudioEngine', 'MTLVertexDescriptor', 'SKPhysicsBody', 'NSOperation', 'UIImageAsset', 'MKMapCamera', 'SKProductsResponse', 'GLKEffectPropertyMaterial', 'AVCaptureDevice', 'CTCallCenter', 'CABTMIDILocalPeripheralViewController', 'NEVPNManager', 'HKQuery', 'SCNPhysicsContact', 'CBMutableService', 'AVSampleBufferDisplayLayer', 'SCNSceneSource', 'SKLightNode', 'CKDiscoveredUserInfo', 'NSMutableArray', 'MTLDepthStencilDescriptor', 'MTLArgument', 'NSMassFormatter', 'CIRectangleFeature', 'PKPushRegistry', 'NEVPNConnection', 'MCNearbyServiceBrowser', 'NSOperationQueue', 'MKPolylineRenderer', 'UICollectionViewLayoutAttributes', 'NSValueTransformer', 'UICollectionViewFlowLayout', 'CIBarcodeFeature', 'MPChangePlaybackRateCommandEvent', 'NSEntityMapping', 'SKTexture', 'NSMergePolicy', 'UITextInputStringTokenizer', 'NSRecursiveLock', 'AVAsset', 'NSUndoManager', 'AVAudioUnitSampler', 'NSItemProvider', 'SKUniform', 'MPMediaPickerController', 'CKOperation', 'MTLRenderPipelineDescriptor', 'EAWiFiUnconfiguredAccessory', 'NSFileCoordinator', 'SKRequest', 'NSFileHandle', 'NSConditionLock', 'UISegmentedControl', 'NSManagedObjectModel', 'UITabBarItem', 'SCNCone', 'MPMediaItem', 'SCNMaterial', 'EKRecurrenceRule', 'UIEvent', 'UITouch', 'UIPrintInteractionController', 'CMDeviceMotion', 'NEVPNProtocol', 'NSCompoundPredicate', 'HKHealthStore', 'MKMultiPoint', 'HKSampleType', 'UIPrintFormatter', 'AVAudioUnitEQFilterParameters', 'SKView', 'NSConstantString', 'UIPopoverController', 'CKDatabase', 'AVMetadataFaceObject', 'UIAccelerometer', 'EKEventViewController', 'CMAltitudeData', 'MTLStencilDescriptor', 'UISwipeGestureRecognizer', 'NSPort', 'MKCircleRenderer', 'AVCompositionTrack', 'NSAsynchronousFetchRequest', 'NSUbiquitousKeyValueStore', 'NSMetadataQueryResultGroup', 'AVAssetResourceLoadingDataRequest', 'UITableViewHeaderFooterView', 'CKNotificationID', 'AVAudioSession', 'HKUnit', 'NSNull', 'NSPersistentStoreResult', 'MKCircleView', 'AVAudioChannelLayout', 'NEVPNProtocolIKEv2', 'WKProcessPool', 'UIAttachmentBehavior', 'CLBeacon', 'NSInputStream', 'NSURLCache', 'GKPlayer', 'NSMappingModel', 'NSHTTPCookie', 'AVMutableVideoComposition', 'PHFetchResult', 'NSAttributeDescription', 'AVPlayer', 'MKAnnotationView', 'UIFontDescriptor', 'NSTimer', 'CBDescriptor', 'MKOverlayView', 'AVAudioUnitTimePitch', 'NSSaveChangesRequest', 'UIReferenceLibraryViewController', 'SKPhysicsJointFixed', 'UILocalizedIndexedCollation', 'UIInterpolatingMotionEffect', 'UIDocumentPickerViewController', 'AVAssetWriter', 'NSBundle', 'SKStoreProductViewController', 'GLKViewController', 'NSMetadataQueryAttributeValueTuple', 'GKTurnBasedMatch', 'AVAudioFile', 'UIActivity', 'NSPipe', 'MKShape', 'NSMergeConflict', 'CIImage', 'HKObject', 'UIRotationGestureRecognizer', 'AVPlayerItemLegibleOutput', 'AVAssetImageGenerator', 'GCControllerButtonInput', 'CKMarkNotificationsReadOperation', 'CKSubscription', 'MPTimedMetadata', 'NKIssue', 'UIScreenMode', 'HMAccessoryBrowser', 'GKTurnBasedEventHandler', 'UIWebView', 'MKPolyline', 'JSVirtualMachine', 'AVAssetReader', 'NSAttributedString', 'GKMatchmakerViewController', 'NSCountedSet', 'UIButton', 'WKNavigationResponse', 'GKLocalPlayer', 'MPMovieErrorLog', 'AVSpeechUtterance', 'HKStatistics', 'UILocalNotification', 'HKBiologicalSexObject', 'AVURLAsset', 'CBPeripheral', 'NSDateComponentsFormatter', 'SKSpriteNode', 'UIAccessibilityElement', 'AVAssetWriterInputGroup', 'HMZone', 'AVAssetReaderAudioMixOutput', 'NSEnumerator', 'UIDocument', 'MKLocalSearchResponse', 'UISimpleTextPrintFormatter', 'PHPhotoLibrary', 'CBService', 'UIDocumentMenuViewController', 'MCSession', 'QLPreviewController', 'CAMediaTimingFunction', 'UITextPosition', 'ASIdentifierManager', 'AVAssetResourceLoadingRequest', 'SLComposeServiceViewController', 'UIPinchGestureRecognizer', 'PHObject', 'NSExtensionItem', 'HKSampleQuery', 'MTLRenderPipelineColorAttachmentDescriptorArray', 'MKRouteStep', 'SCNCapsule', 'NSMetadataQuery', 'AVAssetResourceLoadingContentInformationRequest', 'UITraitCollection', 'CTCarrier', 'NSFileSecurity', 'UIAcceleration', 'UIMotionEffect', 'MTLRenderPipelineReflection', 'CLHeading', 'CLVisit', 'MKDirectionsResponse', 'HMAccessory', 'MTLStructType', 'UITextView', 'CMMagnetometerData', 'UICollisionBehavior', 'UIProgressView', 'CKServerChangeToken', 'UISearchBar', 'MKPlacemark', 'AVCaptureConnection', 'NSPropertyMapping', 'ALAssetsFilter', 'SK3DNode', 'AVPlayerItemErrorLogEvent', 'NSJSONSerialization', 'AVAssetReaderVideoCompositionOutput', 'ABPersonViewController', 'CIDetector', 'GKTurnBasedMatchmakerViewController', 'MPMediaItemCollection', 'SCNSphere', 'NSCondition', 'NSURLCredential', 'MIDINetworkConnection', 'NSFileProviderExtension', 'NSDecimalNumberHandler', 'NSAtomicStoreCacheNode', 'NSAtomicStore', 'EKAlarm', 'CKNotificationInfo', 'AVAudioUnitEQ', 'UIPercentDrivenInteractiveTransition', 'MKPolygon', 'AVAssetTrackSegment', 'MTLVertexAttribute', 'NSExpressionDescription', 'HKStatisticsCollectionQuery', 'NSURLAuthenticationChallenge', 'NSDirectoryEnumerator', 'MKDistanceFormatter', 'UIAlertAction', 'NSPropertyListSerialization', 'GKPeerPickerController', 'UIUserNotificationSettings', 'UITableViewController', 'GKNotificationBanner', 'MKPointAnnotation', 'MTLRenderPassColorAttachmentDescriptorArray', 'NSCache', 'SKPhysicsJoint', 'NSXMLParser', 'UIViewController', 'MFMessageComposeViewController', 'AVAudioInputNode', 'NSDataDetector', 'CABTMIDICentralViewController', 'AVAudioUnitMIDIInstrument', 'AVCaptureVideoPreviewLayer', 'AVAssetWriterInputPassDescription', 'MPChangePlaybackRateCommand', 'NSURLComponents', 'CAMetalLayer', 'UISnapBehavior', 'AVMetadataMachineReadableCodeObject', 'CKDiscoverUserInfosOperation', 'NSTextAttachment', 'NSException', 'UIMenuItem', 'CMMotionActivityManager', 'SCNGeometryElement', 'NCWidgetController', 'CAEmitterLayer', 'MKUserLocation', 'UIImagePickerController', 'CIFeature', 'AVCaptureDeviceInput', 'ALAsset', 'NSURLSessionDownloadTask', 'SCNPhysicsHingeJoint', 'MPMoviePlayerViewController', 'NSMutableOrderedSet', 'SCNMaterialProperty', 'UIFont', 'AVCaptureVideoDataOutput', 'NSCachedURLResponse', 'ALAssetsLibrary', 'NSInvocation', 'UILongPressGestureRecognizer', 'NSTextStorage', 'WKWebViewConfiguration', 'CIFaceFeature', 'MKMapSnapshot', 'GLKEffectPropertyFog', 'AVComposition', 'CKDiscoverAllContactsOperation', 'AVAudioMixInputParameters', 'CAEmitterBehavior', 'PKPassLibrary', 'UIMutableUserNotificationCategory', 'NSLock', 'NEVPNProtocolIPSec', 'ADBannerView', 'UIDocumentPickerExtensionViewController', 'UIActivityIndicatorView', 'AVPlayerMediaSelectionCriteria', 'CALayer', 'UIAccessibilityCustomAction', 'UIBarButtonItem', 'AVAudioSessionRouteDescription', 'CLBeaconRegion', 'HKBloodTypeObject', 'MTLVertexBufferLayoutDescriptorArray', 'CABasicAnimation', 'AVVideoCompositionInstruction', 'AVMutableTimedMetadataGroup', 'EKRecurrenceEnd', 'NSTextContainer', 'TWTweetComposeViewController', 'UIScrollView', 'WKNavigationAction', 'AVPlayerItemMetadataOutput', 'EKRecurrenceDayOfWeek', 'NSNumberFormatter', 'MTLComputePipelineReflection', 'UIScreen', 'CLRegion', 'NSProcessInfo', 'GLKTextureInfo', 'SCNSkinner', 'AVCaptureMetadataOutput', 'SCNAnimationEvent', 'NSTextTab', 'JSManagedValue', 'NSDate', 'UITextChecker', 'WKBackForwardListItem', 'NSData', 'NSParagraphStyle', 'AVMutableMetadataItem', 'EKCalendar', 'NSMutableURLRequest', 'UIVideoEditorController', 'HMTimerTrigger', 'AVAudioUnitVarispeed', 'UIDynamicAnimator', 'AVCompositionTrackSegment', 'GCGamepadSnapshot', 'MPMediaEntity', 'GLKSkyboxEffect', 'UISwitch', 'EKStructuredLocation', 'UIGestureRecognizer', 'NSProxy', 'GLKBaseEffect', 'UIPushBehavior', 'GKScoreChallenge', 'NSCoder', 'MPMediaPlaylist', 'NSDateComponents', 'WKUserScript', 'EKEvent', 'NSDateFormatter', 'NSAsynchronousFetchResult', 'AVAssetWriterInputPixelBufferAdaptor', 'UIVisualEffect', 'UICollectionViewCell', 'UITextField', 'CLPlacemark', 'MPPlayableContentManager', 'AVCaptureOutput', 'HMCharacteristicWriteAction', 'CKModifySubscriptionsOperation', 'NSPropertyDescription', 'GCGamepad', 'UIMarkupTextPrintFormatter', 'SCNTube', 'NSPersistentStoreCoordinator', 'AVAudioEnvironmentNode', 'GKMatchmaker', 'CIContext', 'NSThread', 'SLComposeSheetConfigurationItem', 'SKPhysicsJointSliding', 'NSPredicate', 'GKVoiceChat', 'SKCropNode', 'AVCaptureAudioPreviewOutput', 'NSStringDrawingContext', 'GKGameCenterViewController', 'UIPrintPaper', 'SCNPhysicsBallSocketJoint', 'UICollectionViewLayoutInvalidationContext', 'GLKEffectPropertyTransform', 'AVAudioIONode', 'UIDatePicker', 'MKDirections', 'ALAssetsGroup', 'CKRecordZoneNotification', 'SCNScene', 'MPMovieAccessLogEvent', 'CKFetchSubscriptionsOperation', 'CAEmitterCell', 'AVAudioUnitTimeEffect', 'HMCharacteristicMetadata', 'MKPinAnnotationView', 'UIPickerView', 'UIImageView', 'UIUserNotificationCategory', 'SCNPhysicsVehicleWheel', 'HKCategoryType', 'MPMediaQuerySection', 'GKFriendRequestComposeViewController', 'NSError', 'MTLRenderPipelineColorAttachmentDescriptor', 'SCNPhysicsShape', 'UISearchController', 'SCNPhysicsBody', 'CTSubscriberInfo', 'AVPlayerItemAccessLog', 'MPMediaPropertyPredicate', 'CMLogItem', 'NSAutoreleasePool', 'NSSocketPort', 'AVAssetReaderTrackOutput', 'SKNode', 'UIMutableUserNotificationAction', 'SCNProgram', 'AVSpeechSynthesisVoice', 'CMAltimeter', 'AVCaptureAudioChannel', 'GKTurnBasedExchangeReply', 'AVVideoCompositionLayerInstruction', 'AVSpeechSynthesizer', 'GKChallengeEventHandler', 'AVCaptureFileOutput', 'UIControl', 'SCNPhysicsField', 'CKReference', 'LAContext', 'CKRecordID', 'ADInterstitialAd', 'AVAudioSessionDataSourceDescription', 'AVAudioBuffer', 'CIColorKernel', 'GCControllerDirectionPad', 'NSFileManager', 'AVMutableAudioMixInputParameters', 'UIScreenEdgePanGestureRecognizer', 'CAKeyframeAnimation', 'CKQueryNotification', 'PHAdjustmentData', 'EASession', 'AVAssetResourceRenewalRequest', 'UIInputView', 'NSFileWrapper', 'UIResponder', 'NSPointerFunctions', 'NSHTTPCookieStorage', 'AVMediaSelectionOption', 'NSRunLoop', 'NSFileAccessIntent', 'CAAnimationGroup', 'MKCircle', 'UIAlertController', 'NSMigrationManager', 'NSDateIntervalFormatter', 'UICollectionViewUpdateItem', 'CKDatabaseOperation', 'PHImageRequestOptions', 'SKReachConstraints', 'CKRecord', 'CAInterAppAudioSwitcherView', 'WKWindowFeatures', 'GKInvite', 'NSMutableData', 'PHAssetCollectionChangeRequest', 'NSMutableParagraphStyle', 'UIDynamicBehavior', 'GLKEffectProperty', 'CKFetchRecordChangesOperation', 'SKShapeNode', 'MPMovieErrorLogEvent', 'MKPolygonView', 'MPContentItem', 'HMAction', 'NSScanner', 'GKAchievementChallenge', 'AVAudioPlayer', 'CKContainer', 'AVVideoComposition', 'NKLibrary', 'NSPersistentStore', 'AVCaptureMovieFileOutput', 'HMRoom', 'GKChallenge', 'UITextRange', 'NSURLProtectionSpace', 'ACAccountStore', 'MPSkipIntervalCommand', 'NSComparisonPredicate', 'HMHome', 'PHVideoRequestOptions', 'NSOutputStream', 'MPSkipIntervalCommandEvent', 'PKAddPassesViewController', 'UITextSelectionRect', 'CTTelephonyNetworkInfo', 'AVTextStyleRule', 'NSFetchedPropertyDescription', 'UIPageViewController', 'CATransformLayer', 'UICollectionViewController', 'AVAudioNode', 'MCNearbyServiceAdvertiser', 'NSObject', 'PHAsset', 'GKLeaderboardViewController', 'CKQueryCursor', 'MPMusicPlayerController', 'MKOverlayPathRenderer', 'CMPedometerData', 'HMService', 'SKFieldNode', 'GKAchievement', 'WKUserContentController', 'AVAssetTrack', 'TWRequest', 'SKLabelNode', 'AVCaptureBracketedStillImageSettings', 'MIDINetworkHost', 'MPMediaPredicate', 'AVFrameRateRange', 'MTLTextureDescriptor', 'MTLVertexBufferLayoutDescriptor', 'MPFeedbackCommandEvent', 'UIUserNotificationAction', 'HKStatisticsQuery', 'SCNParticleSystem', 'NSIndexPath', 'AVVideoCompositionRenderContext', 'CADisplayLink', 'HKObserverQuery', 'UIPopoverPresentationController', 'CKQueryOperation', 'CAEAGLLayer', 'NSMutableString', 'NSMessagePort', 'NSURLQueryItem', 'MTLStructMember', 'AVAudioSessionChannelDescription', 'GLKView', 'UIActivityViewController', 'GKAchievementViewController', 'GKTurnBasedParticipant', 'NSURLProtocol', 'NSUserDefaults', 'NSCalendar', 'SKKeyframeSequence', 'AVMetadataItemFilter', 'CKModifyRecordZonesOperation', 'WKPreferences', 'NSMethodSignature', 'NSRegularExpression', 'EAGLSharegroup', 'AVPlayerItemVideoOutput', 'PHContentEditingInputRequestOptions', 'GKMatch', 'CIColor', 'UIDictationPhrase']) -COCOA_PROTOCOLS = set(['SKStoreProductViewControllerDelegate', 'AVVideoCompositionInstruction', 'AVAudioSessionDelegate', 'GKMatchDelegate', 'NSFileManagerDelegate', 'UILayoutSupport', 'NSCopying', 'UIPrintInteractionControllerDelegate', 'QLPreviewControllerDataSource', 'SKProductsRequestDelegate', 'NSTextStorageDelegate', 'MCBrowserViewControllerDelegate', 'MTLComputeCommandEncoder', 'SCNSceneExportDelegate', 'UISearchResultsUpdating', 'MFMailComposeViewControllerDelegate', 'MTLBlitCommandEncoder', 'NSDecimalNumberBehaviors', 'PHContentEditingController', 'NSMutableCopying', 'UIActionSheetDelegate', 'UIViewControllerTransitioningDelegate', 'UIAlertViewDelegate', 'AVAudioPlayerDelegate', 'MKReverseGeocoderDelegate', 'NSCoding', 'UITextInputTokenizer', 'GKFriendRequestComposeViewControllerDelegate', 'UIActivityItemSource', 'NSCacheDelegate', 'UIAdaptivePresentationControllerDelegate', 'GKAchievementViewControllerDelegate', 'UIViewControllerTransitionCoordinator', 'EKEventEditViewDelegate', 'NSURLConnectionDelegate', 'UITableViewDelegate', 'GKPeerPickerControllerDelegate', 'UIGuidedAccessRestrictionDelegate', 'AVSpeechSynthesizerDelegate', 'AVAudio3DMixing', 'AVPlayerItemLegibleOutputPushDelegate', 'ADInterstitialAdDelegate', 'HMAccessoryBrowserDelegate', 'AVAssetResourceLoaderDelegate', 'UITabBarControllerDelegate', 'CKRecordValue', 'SKPaymentTransactionObserver', 'AVCaptureAudioDataOutputSampleBufferDelegate', 'UIInputViewAudioFeedback', 'GKChallengeListener', 'SKSceneDelegate', 'UIPickerViewDelegate', 'UIWebViewDelegate', 'UIApplicationDelegate', 'GKInviteEventListener', 'MPMediaPlayback', 'MyClassJavaScriptMethods', 'AVAsynchronousKeyValueLoading', 'QLPreviewItem', 'SCNBoundingVolume', 'NSPortDelegate', 'UIContentContainer', 'SCNNodeRendererDelegate', 'SKRequestDelegate', 'SKPhysicsContactDelegate', 'HMAccessoryDelegate', 'UIPageViewControllerDataSource', 'SCNSceneRendererDelegate', 'SCNPhysicsContactDelegate', 'MKMapViewDelegate', 'AVPlayerItemOutputPushDelegate', 'UICollectionViewDelegate', 'UIImagePickerControllerDelegate', 'MTLRenderCommandEncoder', 'UIToolbarDelegate', 'WKUIDelegate', 'SCNActionable', 'NSURLConnectionDataDelegate', 'MKOverlay', 'CBCentralManagerDelegate', 'JSExport', 'NSTextLayoutOrientationProvider', 'UIPickerViewDataSource', 'PKPushRegistryDelegate', 'UIViewControllerTransitionCoordinatorContext', 'NSLayoutManagerDelegate', 'MTLLibrary', 'NSFetchedResultsControllerDelegate', 'ABPeoplePickerNavigationControllerDelegate', 'MTLResource', 'NSDiscardableContent', 'UITextFieldDelegate', 'MTLBuffer', 'MTLSamplerState', 'GKGameCenterControllerDelegate', 'MPMediaPickerControllerDelegate', 'UISplitViewControllerDelegate', 'UIAppearance', 'UIPickerViewAccessibilityDelegate', 'UITraitEnvironment', 'UIScrollViewAccessibilityDelegate', 'ADBannerViewDelegate', 'MPPlayableContentDataSource', 'MTLComputePipelineState', 'NSURLSessionDelegate', 'MTLCommandBuffer', 'NSXMLParserDelegate', 'UIViewControllerRestoration', 'UISearchBarDelegate', 'UIBarPositioning', 'CBPeripheralDelegate', 'UISearchDisplayDelegate', 'CAAction', 'PKAddPassesViewControllerDelegate', 'MCNearbyServiceAdvertiserDelegate', 'MTLDepthStencilState', 'GKTurnBasedMatchmakerViewControllerDelegate', 'MPPlayableContentDelegate', 'AVCaptureVideoDataOutputSampleBufferDelegate', 'UIAppearanceContainer', 'UIStateRestoring', 'UITextDocumentProxy', 'MTLDrawable', 'NSURLSessionTaskDelegate', 'NSFilePresenter', 'AVAudioStereoMixing', 'UIViewControllerContextTransitioning', 'UITextInput', 'CBPeripheralManagerDelegate', 'UITextInputDelegate', 'NSFastEnumeration', 'NSURLAuthenticationChallengeSender', 'SCNProgramDelegate', 'AVVideoCompositing', 'SCNAnimatable', 'NSSecureCoding', 'MCAdvertiserAssistantDelegate', 'GKLocalPlayerListener', 'GLKNamedEffect', 'UIPopoverControllerDelegate', 'AVCaptureMetadataOutputObjectsDelegate', 'NSExtensionRequestHandling', 'UITextSelecting', 'UIPrinterPickerControllerDelegate', 'NCWidgetProviding', 'MTLCommandEncoder', 'NSURLProtocolClient', 'MFMessageComposeViewControllerDelegate', 'UIVideoEditorControllerDelegate', 'WKNavigationDelegate', 'GKSavedGameListener', 'UITableViewDataSource', 'MTLFunction', 'EKCalendarChooserDelegate', 'NSUserActivityDelegate', 'UICollisionBehaviorDelegate', 'NSStreamDelegate', 'MCNearbyServiceBrowserDelegate', 'HMHomeDelegate', 'UINavigationControllerDelegate', 'MCSessionDelegate', 'UIDocumentPickerDelegate', 'UIViewControllerInteractiveTransitioning', 'GKTurnBasedEventListener', 'SCNSceneRenderer', 'MTLTexture', 'GLKViewDelegate', 'EAAccessoryDelegate', 'WKScriptMessageHandler', 'PHPhotoLibraryChangeObserver', 'NSKeyedUnarchiverDelegate', 'AVPlayerItemMetadataOutputPushDelegate', 'NSMachPortDelegate', 'SCNShadable', 'UIPopoverBackgroundViewMethods', 'UIDocumentMenuDelegate', 'UIBarPositioningDelegate', 'ABPersonViewControllerDelegate', 'NSNetServiceBrowserDelegate', 'EKEventViewDelegate', 'UIScrollViewDelegate', 'NSURLConnectionDownloadDelegate', 'UIGestureRecognizerDelegate', 'UINavigationBarDelegate', 'AVAudioMixing', 'NSFetchedResultsSectionInfo', 'UIDocumentInteractionControllerDelegate', 'MTLParallelRenderCommandEncoder', 'QLPreviewControllerDelegate', 'UIAccessibilityReadingContent', 'ABUnknownPersonViewControllerDelegate', 'GLKViewControllerDelegate', 'UICollectionViewDelegateFlowLayout', 'UIPopoverPresentationControllerDelegate', 'UIDynamicAnimatorDelegate', 'NSTextAttachmentContainer', 'MKAnnotation', 'UIAccessibilityIdentification', 'UICoordinateSpace', 'ABNewPersonViewControllerDelegate', 'MTLDevice', 'CAMediaTiming', 'AVCaptureFileOutputRecordingDelegate', 'HMHomeManagerDelegate', 'UITextViewDelegate', 'UITabBarDelegate', 'GKLeaderboardViewControllerDelegate', 'UISearchControllerDelegate', 'EAWiFiUnconfiguredAccessoryBrowserDelegate', 'UITextInputTraits', 'MTLRenderPipelineState', 'GKVoiceChatClient', 'UIKeyInput', 'UICollectionViewDataSource', 'SCNTechniqueSupport', 'NSLocking', 'AVCaptureFileOutputDelegate', 'GKChallengeEventHandlerDelegate', 'UIObjectRestoration', 'CIFilterConstructor', 'AVPlayerItemOutputPullDelegate', 'EAGLDrawable', 'AVVideoCompositionValidationHandling', 'UIViewControllerAnimatedTransitioning', 'NSURLSessionDownloadDelegate', 'UIAccelerometerDelegate', 'UIPageViewControllerDelegate', 'MTLCommandQueue', 'UIDataSourceModelAssociation', 'AVAudioRecorderDelegate', 'GKSessionDelegate', 'NSKeyedArchiverDelegate', 'CAMetalDrawable', 'UIDynamicItem', 'CLLocationManagerDelegate', 'NSMetadataQueryDelegate', 'NSNetServiceDelegate', 'GKMatchmakerViewControllerDelegate', 'NSURLSessionDataDelegate']) -COCOA_PRIMITIVES = set(['ROTAHeader', '__CFBundle', 'MortSubtable', 'AudioFilePacketTableInfo', 'CGPDFOperatorTable', 'KerxStateEntry', 'ExtendedTempoEvent', 'CTParagraphStyleSetting', 'OpaqueMIDIPort', '_GLKMatrix3', '_GLKMatrix2', '_GLKMatrix4', 'ExtendedControlEvent', 'CAFAudioDescription', 'OpaqueCMBlockBuffer', 'CGTextDrawingMode', 'EKErrorCode', 'GCAcceleration', 'AudioUnitParameterInfo', '__SCPreferences', '__CTFrame', '__CTLine', 'AudioFile_SMPTE_Time', 'gss_krb5_lucid_context_v1', 'OpaqueJSValue', 'TrakTableEntry', 'AudioFramePacketTranslation', 'CGImageSource', 'OpaqueJSPropertyNameAccumulator', 'JustPCGlyphRepeatAddAction', '__CFBinaryHeap', 'OpaqueMIDIThruConnection', 'opaqueCMBufferQueue', 'OpaqueMusicSequence', 'MortRearrangementSubtable', 'MixerDistanceParams', 'MorxSubtable', 'MIDIObjectPropertyChangeNotification', 'SFNTLookupSegment', 'CGImageMetadataErrors', 'CGPath', 'OpaqueMIDIEndpoint', 'AudioComponentPlugInInterface', 'gss_ctx_id_t_desc_struct', 'sfntFontFeatureSetting', 'OpaqueJSContextGroup', '__SCNetworkConnection', 'AudioUnitParameterValueTranslation', 'CGImageMetadataType', 'CGPattern', 'AudioFileTypeAndFormatID', 'CGContext', 'AUNodeInteraction', 'SFNTLookupTable', 'JustPCDecompositionAction', 'KerxControlPointHeader', 'AudioStreamPacketDescription', 'KernSubtableHeader', '__SecCertificate', 'AUMIDIOutputCallbackStruct', 'MIDIMetaEvent', 'AudioQueueChannelAssignment', 'AnchorPoint', 'JustTable', '__CFNetService', 'CF_BRIDGED_TYPE', 'gss_krb5_lucid_key', 'CGPDFDictionary', 'KerxSubtableHeader', 'CAF_UUID_ChunkHeader', 'gss_krb5_cfx_keydata', 'OpaqueJSClass', 'CGGradient', 'OpaqueMIDISetup', 'JustPostcompTable', '__CTParagraphStyle', 'AudioUnitParameterHistoryInfo', 'OpaqueJSContext', 'CGShading', 'MIDIThruConnectionParams', 'BslnFormat0Part', 'SFNTLookupSingle', '__CFHost', '__SecRandom', '__CTFontDescriptor', '_NSRange', 'sfntDirectory', 'AudioQueueLevelMeterState', 'CAFPositionPeak', 'PropLookupSegment', '__CVOpenGLESTextureCache', 'sfntInstance', '_GLKQuaternion', 'AnkrTable', '__SCNetworkProtocol', 'gss_buffer_desc_struct', 'CAFFileHeader', 'KerxOrderedListHeader', 'CGBlendMode', 'STXEntryOne', 'CAFRegion', 'SFNTLookupTrimmedArrayHeader', 'SCNMatrix4', 'KerxControlPointEntry', 'OpaqueMusicTrack', '_GLKVector4', 'gss_OID_set_desc_struct', 'OpaqueMusicPlayer', '_CFHTTPAuthentication', 'CGAffineTransform', 'CAFMarkerChunk', 'AUHostIdentifier', 'ROTAGlyphEntry', 'BslnTable', 'gss_krb5_lucid_context_version', '_GLKMatrixStack', 'CGImage', 'KernStateEntry', 'SFNTLookupSingleHeader', 'MortLigatureSubtable', 'CAFUMIDChunk', 'SMPTETime', 'CAFDataChunk', 'CGPDFStream', 'AudioFileRegionList', 'STEntryTwo', 'SFNTLookupBinarySearchHeader', 'OpbdTable', '__CTGlyphInfo', 'BslnFormat2Part', 'KerxIndexArrayHeader', 'TrakTable', 'KerxKerningPair', '__CFBitVector', 'KernVersion0SubtableHeader', 'OpaqueAudioComponentInstance', 'AudioChannelLayout', '__CFUUID', 'MIDISysexSendRequest', '__CFNumberFormatter', 'CGImageSourceStatus', 'AudioFileMarkerList', 'AUSamplerBankPresetData', 'CGDataProvider', 'AudioFormatInfo', '__SecIdentity', 'sfntCMapExtendedSubHeader', 'MIDIChannelMessage', 'KernOffsetTable', 'CGColorSpaceModel', 'MFMailComposeErrorCode', 'CGFunction', '__SecTrust', 'AVAudio3DAngularOrientation', 'CGFontPostScriptFormat', 'KernStateHeader', 'AudioUnitCocoaViewInfo', 'CGDataConsumer', 'OpaqueMIDIDevice', 'KernVersion0Header', 'AnchorPointTable', 'CGImageDestination', 'CAFInstrumentChunk', 'AudioUnitMeterClipping', 'MorxChain', '__CTFontCollection', 'STEntryOne', 'STXEntryTwo', 'ExtendedNoteOnEvent', 'CGColorRenderingIntent', 'KerxSimpleArrayHeader', 'MorxTable', '_GLKVector3', '_GLKVector2', 'MortTable', 'CGPDFBox', 'AudioUnitParameterValueFromString', '__CFSocket', 'ALCdevice_struct', 'MIDINoteMessage', 'sfntFeatureHeader', 'CGRect', '__SCNetworkInterface', '__CFTree', 'MusicEventUserData', 'TrakTableData', 'GCQuaternion', 'MortContextualSubtable', '__CTRun', 'AudioUnitFrequencyResponseBin', 'MortChain', 'MorxInsertionSubtable', 'CGImageMetadata', 'gss_auth_identity', 'AudioUnitMIDIControlMapping', 'CAFChunkHeader', 'CGImagePropertyOrientation', 'CGPDFScanner', 'OpaqueMusicEventIterator', 'sfntDescriptorHeader', 'AudioUnitNodeConnection', 'OpaqueMIDIDeviceList', 'ExtendedAudioFormatInfo', 'BslnFormat1Part', 'sfntFontDescriptor', 'KernSimpleArrayHeader', '__CFRunLoopObserver', 'CGPatternTiling', 'MIDINotification', 'MorxLigatureSubtable', 'MessageComposeResult', 'MIDIThruConnectionEndpoint', 'MusicDeviceStdNoteParams', 'opaqueCMSimpleQueue', 'ALCcontext_struct', 'OpaqueAudioQueue', 'PropLookupSingle', 'CGInterpolationQuality', 'CGColor', 'AudioOutputUnitStartAtTimeParams', 'gss_name_t_desc_struct', 'CGFunctionCallbacks', 'CAFPacketTableHeader', 'AudioChannelDescription', 'sfntFeatureName', 'MorxContextualSubtable', 'CVSMPTETime', 'AudioValueRange', 'CGTextEncoding', 'AudioStreamBasicDescription', 'AUNodeRenderCallback', 'AudioPanningInfo', 'KerxOrderedListEntry', '__CFAllocator', 'OpaqueJSPropertyNameArray', '__SCDynamicStore', 'OpaqueMIDIEntity', '__CTRubyAnnotation', 'SCNVector4', 'CFHostClientContext', 'CFNetServiceClientContext', 'AudioUnitPresetMAS_SettingData', 'opaqueCMBufferQueueTriggerToken', 'AudioUnitProperty', 'CAFRegionChunk', 'CGPDFString', '__GLsync', '__CFStringTokenizer', 'JustWidthDeltaEntry', 'sfntVariationAxis', '__CFNetDiagnostic', 'CAFOverviewSample', 'sfntCMapEncoding', 'CGVector', '__SCNetworkService', 'opaqueCMSampleBuffer', 'AUHostVersionIdentifier', 'AudioBalanceFade', 'sfntFontRunFeature', 'KerxCoordinateAction', 'sfntCMapSubHeader', 'CVPlanarPixelBufferInfo', 'AUNumVersion', 'AUSamplerInstrumentData', 'AUPreset', '__CTRunDelegate', 'OpaqueAudioQueueProcessingTap', 'KerxTableHeader', '_NSZone', 'OpaqueExtAudioFile', '__CFRunLoopSource', '__CVMetalTextureCache', 'KerxAnchorPointAction', 'OpaqueJSString', 'AudioQueueParameterEvent', '__CFHTTPMessage', 'OpaqueCMClock', 'ScheduledAudioFileRegion', 'STEntryZero', 'AVAudio3DPoint', 'gss_channel_bindings_struct', 'sfntVariationHeader', 'AUChannelInfo', 'UIOffset', 'GLKEffectPropertyPrv', 'KerxStateHeader', 'CGLineJoin', 'CGPDFDocument', '__CFBag', 'KernOrderedListHeader', '__SCNetworkSet', '__SecKey', 'MIDIObjectAddRemoveNotification', 'AudioUnitParameter', 'JustPCActionSubrecord', 'AudioComponentDescription', 'AudioUnitParameterValueName', 'AudioUnitParameterEvent', 'KerxControlPointAction', 'AudioTimeStamp', 'KernKerningPair', 'gss_buffer_set_desc_struct', 'MortFeatureEntry', 'FontVariation', 'CAFStringID', 'LcarCaretClassEntry', 'AudioUnitParameterStringFromValue', 'ACErrorCode', 'ALMXGlyphEntry', 'LtagTable', '__CTTypesetter', 'AuthorizationOpaqueRef', 'UIEdgeInsets', 'CGPathElement', 'CAFMarker', 'KernTableHeader', 'NoteParamsControlValue', 'SSLContext', 'gss_cred_id_t_desc_struct', 'AudioUnitParameterNameInfo', 'CGDataConsumerCallbacks', 'ALMXHeader', 'CGLineCap', 'MIDIControlTransform', 'CGPDFArray', '__SecPolicy', 'AudioConverterPrimeInfo', '__CTTextTab', '__CFNetServiceMonitor', 'AUInputSamplesInOutputCallbackStruct', '__CTFramesetter', 'CGPDFDataFormat', 'STHeader', 'CVPlanarPixelBufferInfo_YCbCrPlanar', 'MIDIValueMap', 'JustDirectionTable', '__SCBondStatus', 'SFNTLookupSegmentHeader', 'OpaqueCMMemoryPool', 'CGPathDrawingMode', 'CGFont', '__SCNetworkReachability', 'AudioClassDescription', 'CGPoint', 'AVAudio3DVectorOrientation', 'CAFStrings', '__CFNetServiceBrowser', 'opaqueMTAudioProcessingTap', 'sfntNameRecord', 'CGPDFPage', 'CGLayer', 'ComponentInstanceRecord', 'CAFInfoStrings', 'HostCallbackInfo', 'MusicDeviceNoteParams', 'OpaqueVTCompressionSession', 'KernIndexArrayHeader', 'CVPlanarPixelBufferInfo_YCbCrBiPlanar', 'MusicTrackLoopInfo', 'opaqueCMFormatDescription', 'STClassTable', 'sfntDirectoryEntry', 'OpaqueCMTimebase', 'CGDataProviderDirectCallbacks', 'MIDIPacketList', 'CAFOverviewChunk', 'MIDIPacket', 'ScheduledAudioSlice', 'CGDataProviderSequentialCallbacks', 'AudioBuffer', 'MorxRearrangementSubtable', 'CGPatternCallbacks', 'AUDistanceAttenuationData', 'MIDIIOErrorNotification', 'CGPDFContentStream', 'IUnknownVTbl', 'MIDITransform', 'MortInsertionSubtable', 'CABarBeatTime', 'AudioBufferList', '__CVBuffer', 'AURenderCallbackStruct', 'STXEntryZero', 'JustPCDuctilityAction', 'OpaqueAudioQueueTimeline', 'VTDecompressionOutputCallbackRecord', 'OpaqueMIDIClient', '__CFPlugInInstance', 'AudioQueueBuffer', '__CFFileDescriptor', 'AudioUnitConnection', '_GKTurnBasedExchangeStatus', 'LcarCaretTable', 'CVPlanarComponentInfo', 'JustWidthDeltaGroup', 'OpaqueAudioComponent', 'ParameterEvent', '__CVPixelBufferPool', '__CTFont', 'CGColorSpace', 'CGSize', 'AUDependentParameter', 'MIDIDriverInterface', 'gss_krb5_rfc1964_keydata', '__CFDateFormatter', 'LtagStringRange', 'OpaqueVTDecompressionSession', 'gss_iov_buffer_desc_struct', 'AUPresetEvent', 'PropTable', 'KernOrderedListEntry', 'CF_BRIDGED_MUTABLE_TYPE', 'gss_OID_desc_struct', 'AudioUnitPresetMAS_Settings', 'AudioFileMarker', 'JustPCConditionalAddAction', 'BslnFormat3Part', '__CFNotificationCenter', 'MortSwashSubtable', 'AUParameterMIDIMapping', 'SCNVector3', 'OpaqueAudioConverter', 'MIDIRawData', 'sfntNameHeader', '__CFRunLoop', 'MFMailComposeResult', 'CATransform3D', 'OpbdSideValues', 'CAF_SMPTE_Time', '__SecAccessControl', 'JustPCAction', 'OpaqueVTFrameSilo', 'OpaqueVTMultiPassStorage', 'CGPathElementType', 'AudioFormatListItem', 'AudioUnitExternalBuffer', 'AudioFileRegion', 'AudioValueTranslation', 'CGImageMetadataTag', 'CAFPeakChunk', 'AudioBytePacketTranslation', 'sfntCMapHeader', '__CFURLEnumerator', 'STXHeader', 'CGPDFObjectType', 'SFNTLookupArrayHeader']) - +COCOA_INTERFACES = set(['UITableViewCell', 'HKCorrelationQuery', 'NSURLSessionDataTask', 'PHFetchOptions', 'NSLinguisticTagger', 'NSStream', 'AVAudioUnitDelay', 'GCMotion', 'SKPhysicsWorld', 'NSString', 'CMAttitude', 'AVAudioEnvironmentDistanceAttenuationParameters', 'HKStatisticsCollection', 'SCNPlane', 'CBPeer', 'JSContext', 'SCNTransaction', 'SCNTorus', 'AVAudioUnitEffect', 'UICollectionReusableView', 'MTLSamplerDescriptor', 'AVAssetReaderSampleReferenceOutput', 'AVMutableCompositionTrack', 'GKLeaderboard', 'NSFetchedResultsController', 'SKRange', 'MKTileOverlayRenderer', 'MIDINetworkSession', 'UIVisualEffectView', 'CIWarpKernel', 'PKObject', 'MKRoute', 'MPVolumeView', 'UIPrintInfo', 'SCNText', 'ADClient', 'PKPayment', 'AVMutableAudioMix', 'GLKEffectPropertyLight', 'WKScriptMessage', 'AVMIDIPlayer', 'PHCollectionListChangeRequest', 'UICollectionViewLayout', 'NSMutableCharacterSet', 'SKPaymentTransaction', 'NEOnDemandRuleConnect', 'NSShadow', 'SCNView', 'NSURLSessionConfiguration', 'MTLVertexAttributeDescriptor', 'CBCharacteristic', 'HKQuantityType', 'CKLocationSortDescriptor', 'NEVPNIKEv2SecurityAssociationParameters', 'CMStepCounter', 'NSNetService', 'AVAssetWriterInputMetadataAdaptor', 'UICollectionView', 'UIViewPrintFormatter', 'SCNLevelOfDetail', 'CAShapeLayer', 'MCPeerID', 'MPRatingCommand', 'WKNavigation', 'NSDictionary', 'NSFileVersion', 'CMGyroData', 'AVAudioUnitDistortion', 'CKFetchRecordsOperation', 'SKPhysicsJointSpring', 'SCNHitTestResult', 'AVAudioTime', 'CIFilter', 'UIView', 'SCNConstraint', 'CAPropertyAnimation', 'MKMapItem', 'MPRemoteCommandCenter', 'PKPaymentSummaryItem', 'UICollectionViewFlowLayoutInvalidationContext', 'UIInputViewController', 'PKPass', 'SCNPhysicsBehavior', 'MTLRenderPassColorAttachmentDescriptor', 'MKPolygonRenderer', 'CKNotification', 'JSValue', 'PHCollectionList', 'CLGeocoder', 'NSByteCountFormatter', 'AVCaptureScreenInput', 'MPFeedbackCommand', 'CAAnimation', 'MKOverlayPathView', 'UIActionSheet', 'UIMotionEffectGroup', 'NSLengthFormatter', 'UIBarItem', 'SKProduct', 'AVAssetExportSession', 'NSKeyedUnarchiver', 'NSMutableSet', 'SCNPyramid', 'PHAssetCollection', 'MKMapView', 'HMHomeManager', 'CATransition', 'MTLCompileOptions', 'UIVibrancyEffect', 'CLCircularRegion', 'MKTileOverlay', 'SCNShape', 'ACAccountCredential', 'SKPhysicsJointLimit', 'MKMapSnapshotter', 'AVMediaSelectionGroup', 'NSIndexSet', 'CBPeripheralManager', 'CKRecordZone', 'AVAudioRecorder', 'NSURL', 'CBCentral', 'NSNumber', 'AVAudioOutputNode', 'MTLVertexAttributeDescriptorArray', 'MKETAResponse', 'SKTransition', 'SSReadingList', 'HKSourceQuery', 'UITableViewRowAction', 'UITableView', 'SCNParticlePropertyController', 'AVCaptureStillImageOutput', 'GCController', 'AVAudioPlayerNode', 'AVAudioSessionPortDescription', 'NSHTTPURLResponse', 'NEOnDemandRuleEvaluateConnection', 'SKEffectNode', 'HKQuantity', 'GCControllerElement', 'AVPlayerItemAccessLogEvent', 'SCNBox', 'NSExtensionContext', 'MKOverlayRenderer', 'SCNPhysicsVehicle', 'NSDecimalNumber', 'EKReminder', 'MKPolylineView', 'CKQuery', 'AVAudioMixerNode', 'GKAchievementDescription', 'EKParticipant', 'NSBlockOperation', 'UIActivityItemProvider', 'CLLocation', 'NSBatchUpdateRequest', 'PHContentEditingOutput', 'PHObjectChangeDetails', 'HKWorkoutType', 'MPMoviePlayerController', 'AVAudioFormat', 'HMTrigger', 'MTLRenderPassDepthAttachmentDescriptor', 'SCNRenderer', 'GKScore', 'UISplitViewController', 'HKSource', 'NSURLConnection', 'ABUnknownPersonViewController', 'SCNTechnique', 'UIMenuController', 'NSEvent', 'SKTextureAtlas', 'NSKeyedArchiver', 'GKLeaderboardSet', 'NSSimpleCString', 'AVAudioPCMBuffer', 'CBATTRequest', 'GKMatchRequest', 'AVMetadataObject', 'SKProductsRequest', 'UIAlertView', 'NSIncrementalStore', 'MFMailComposeViewController', 'SCNFloor', 'NSSortDescriptor', 'CKFetchNotificationChangesOperation', 'MPMovieAccessLog', 'NSManagedObjectContext', 'AVAudioUnitGenerator', 'WKBackForwardList', 'SKMutableTexture', 'AVCaptureAudioDataOutput', 'ACAccount', 'AVMetadataItem', 'MPRatingCommandEvent', 'AVCaptureDeviceInputSource', 'CLLocationManager', 'MPRemoteCommand', 'AVCaptureSession', 'UIStepper', 'UIRefreshControl', 'NEEvaluateConnectionRule', 'CKModifyRecordsOperation', 'UICollectionViewTransitionLayout', 'CBCentralManager', 'NSPurgeableData', 'PKShippingMethod', 'SLComposeViewController', 'NSHashTable', 'MKUserTrackingBarButtonItem', 'UILexiconEntry', 'CMMotionActivity', 'SKAction', 'SKShader', 'AVPlayerItemOutput', 'MTLRenderPassAttachmentDescriptor', 'UIDocumentInteractionController', 'UIDynamicItemBehavior', 'NSMutableDictionary', 'UILabel', 'AVCaptureInputPort', 'NSExpression', 'CAInterAppAudioTransportView', 'SKMutablePayment', 'UIImage', 'PHCachingImageManager', 'SCNTransformConstraint', 'HKCorrelationType', 'UIColor', 'SCNGeometrySource', 'AVCaptureAutoExposureBracketedStillImageSettings', 'UIPopoverBackgroundView', 'UIToolbar', 'NSNotificationCenter', 'UICollectionViewLayoutAttributes', 'AVAssetReaderOutputMetadataAdaptor', 'NSEntityMigrationPolicy', 'HMUser', 'NSLocale', 'NSURLSession', 'SCNCamera', 'NSTimeZone', 'UIManagedDocument', 'AVMutableVideoCompositionLayerInstruction', 'AVAssetTrackGroup', 'NSInvocationOperation', 'ALAssetRepresentation', 'AVQueuePlayer', 'HMServiceGroup', 'UIPasteboard', 'PHContentEditingInput', 'NSLayoutManager', 'EKCalendarChooser', 'EKObject', 'CATiledLayer', 'GLKReflectionMapEffect', 'NSManagedObjectID', 'NSEnergyFormatter', 'SLRequest', 'HMCharacteristic', 'AVPlayerLayer', 'MTLRenderPassDescriptor', 'SKPayment', 'NSPointerArray', 'AVAudioMix', 'SCNLight', 'MCAdvertiserAssistant', 'MKMapSnapshotOptions', 'HKCategorySample', 'AVAudioEnvironmentReverbParameters', 'SCNMorpher', 'AVTimedMetadataGroup', 'CBMutableCharacteristic', 'NSFetchRequest', 'UIDevice', 'NSManagedObject', 'NKAssetDownload', 'AVOutputSettingsAssistant', 'SKPhysicsJointPin', 'UITabBar', 'UITextInputMode', 'NSFetchRequestExpression', 'HMActionSet', 'CTSubscriber', 'PHAssetChangeRequest', 'NSPersistentStoreRequest', 'UITabBarController', 'HKQuantitySample', 'AVPlayerItem', 'AVSynchronizedLayer', 'MKDirectionsRequest', 'NSMetadataItem', 'UIPresentationController', 'UINavigationItem', 'PHFetchResultChangeDetails', 'PHImageManager', 'AVCaptureManualExposureBracketedStillImageSettings', 'UIStoryboardPopoverSegue', 'SCNLookAtConstraint', 'UIGravityBehavior', 'UIWindow', 'CBMutableDescriptor', 'NEOnDemandRuleDisconnect', 'UIBezierPath', 'UINavigationController', 'ABPeoplePickerNavigationController', 'EKSource', 'AVAssetWriterInput', 'AVPlayerItemTrack', 'GLKEffectPropertyTexture', 'NSHTTPCookie', 'NSURLResponse', 'SKPaymentQueue', 'NSAssertionHandler', 'MKReverseGeocoder', 'GCControllerAxisInput', 'NSArray', 'NSOrthography', 'NSURLSessionUploadTask', 'NSCharacterSet', 'AVMutableVideoCompositionInstruction', 'AVAssetReaderOutput', 'EAGLContext', 'WKFrameInfo', 'CMPedometer', 'MyClass', 'CKModifyBadgeOperation', 'AVCaptureAudioFileOutput', 'SKEmitterNode', 'NSMachPort', 'AVVideoCompositionCoreAnimationTool', 'PHCollection', 'SCNPhysicsWorld', 'NSURLRequest', 'CMAccelerometerData', 'NSNetServiceBrowser', 'CLFloor', 'AVAsynchronousVideoCompositionRequest', 'SCNGeometry', 'SCNIKConstraint', 'CIKernel', 'CAGradientLayer', 'HKCharacteristicType', 'NSFormatter', 'SCNAction', 'CATransaction', 'CBUUID', 'UIStoryboard', 'MPMediaLibrary', 'UITapGestureRecognizer', 'MPMediaItemArtwork', 'NSURLSessionTask', 'AVAudioUnit', 'MCBrowserViewController', 'UIFontDescriptor', 'NSRelationshipDescription', 'HKSample', 'WKWebView', 'NSMutableAttributedString', 'NSPersistentStoreAsynchronousResult', 'MPNowPlayingInfoCenter', 'MKLocalSearch', 'EAAccessory', 'HKCorrelation', 'CATextLayer', 'NSNotificationQueue', 'UINib', 'GLKTextureLoader', 'HKObjectType', 'NSValue', 'NSMutableIndexSet', 'SKPhysicsContact', 'NSProgress', 'AVPlayerViewController', 'CAScrollLayer', 'GKSavedGame', 'NSTextCheckingResult', 'PHObjectPlaceholder', 'SKConstraint', 'EKEventEditViewController', 'NSEntityDescription', 'NSURLCredentialStorage', 'UIApplication', 'SKDownload', 'SCNNode', 'MKLocalSearchRequest', 'SKScene', 'UISearchDisplayController', 'NEOnDemandRule', 'MTLRenderPassStencilAttachmentDescriptor', 'CAReplicatorLayer', 'UIPrintPageRenderer', 'EKCalendarItem', 'NSUUID', 'EAAccessoryManager', 'NEOnDemandRuleIgnore', 'SKRegion', 'AVAssetResourceLoader', 'EAWiFiUnconfiguredAccessoryBrowser', 'NSUserActivity', 'CTCall', 'UIPrinterPickerController', 'CIVector', 'UINavigationBar', 'UIPanGestureRecognizer', 'MPMediaQuery', 'ABNewPersonViewController', 'CKRecordZoneID', 'HKAnchoredObjectQuery', 'CKFetchRecordZonesOperation', 'UIStoryboardSegue', 'ACAccountType', 'GKSession', 'SKVideoNode', 'PHChange', 'SKReceiptRefreshRequest', 'GCExtendedGamepadSnapshot', 'MPSeekCommandEvent', 'GCExtendedGamepad', 'CAValueFunction', 'SCNCylinder', 'NSNotification', 'NSBatchUpdateResult', 'PKPushCredentials', 'SCNPhysicsSliderJoint', 'AVCaptureDeviceFormat', 'AVPlayerItemErrorLog', 'NSMapTable', 'NSSet', 'CMMotionManager', 'GKVoiceChatService', 'UIPageControl', 'UILexicon', 'MTLArrayType', 'AVAudioUnitReverb', 'MKGeodesicPolyline', 'AVMutableComposition', 'NSLayoutConstraint', 'UIPrinter', 'NSOrderedSet', 'CBAttribute', 'PKPushPayload', 'NSIncrementalStoreNode', 'EKEventStore', 'MPRemoteCommandEvent', 'UISlider', 'UIBlurEffect', 'CKAsset', 'AVCaptureInput', 'AVAudioEngine', 'MTLVertexDescriptor', 'SKPhysicsBody', 'NSOperation', 'PKPaymentPass', 'UIImageAsset', 'MKMapCamera', 'SKProductsResponse', 'GLKEffectPropertyMaterial', 'AVCaptureDevice', 'CTCallCenter', 'CABTMIDILocalPeripheralViewController', 'NEVPNManager', 'HKQuery', 'SCNPhysicsContact', 'CBMutableService', 'AVSampleBufferDisplayLayer', 'SCNSceneSource', 'SKLightNode', 'CKDiscoveredUserInfo', 'NSMutableArray', 'MTLDepthStencilDescriptor', 'MTLArgument', 'NSMassFormatter', 'CIRectangleFeature', 'PKPushRegistry', 'NEVPNConnection', 'MCNearbyServiceBrowser', 'NSOperationQueue', 'MKPolylineRenderer', 'HKWorkout', 'NSValueTransformer', 'UICollectionViewFlowLayout', 'MPChangePlaybackRateCommandEvent', 'NSEntityMapping', 'SKTexture', 'NSMergePolicy', 'UITextInputStringTokenizer', 'NSRecursiveLock', 'AVAsset', 'NSUndoManager', 'AVAudioUnitSampler', 'NSItemProvider', 'SKUniform', 'MPMediaPickerController', 'CKOperation', 'MTLRenderPipelineDescriptor', 'EAWiFiUnconfiguredAccessory', 'NSFileCoordinator', 'SKRequest', 'NSFileHandle', 'NSConditionLock', 'UISegmentedControl', 'NSManagedObjectModel', 'UITabBarItem', 'SCNCone', 'MPMediaItem', 'SCNMaterial', 'EKRecurrenceRule', 'UIEvent', 'UITouch', 'UIPrintInteractionController', 'CMDeviceMotion', 'NEVPNProtocol', 'NSCompoundPredicate', 'HKHealthStore', 'MKMultiPoint', 'HKSampleType', 'UIPrintFormatter', 'AVAudioUnitEQFilterParameters', 'SKView', 'NSConstantString', 'UIPopoverController', 'CKDatabase', 'AVMetadataFaceObject', 'UIAccelerometer', 'EKEventViewController', 'CMAltitudeData', 'MTLStencilDescriptor', 'UISwipeGestureRecognizer', 'NSPort', 'MKCircleRenderer', 'AVCompositionTrack', 'NSAsynchronousFetchRequest', 'NSUbiquitousKeyValueStore', 'NSMetadataQueryResultGroup', 'AVAssetResourceLoadingDataRequest', 'UITableViewHeaderFooterView', 'CKNotificationID', 'AVAudioSession', 'HKUnit', 'NSNull', 'NSPersistentStoreResult', 'MKCircleView', 'AVAudioChannelLayout', 'NEVPNProtocolIKEv2', 'WKProcessPool', 'UIAttachmentBehavior', 'CLBeacon', 'NSInputStream', 'NSURLCache', 'GKPlayer', 'NSMappingModel', 'CIQRCodeFeature', 'AVMutableVideoComposition', 'PHFetchResult', 'NSAttributeDescription', 'AVPlayer', 'MKAnnotationView', 'PKPaymentRequest', 'NSTimer', 'CBDescriptor', 'MKOverlayView', 'AVAudioUnitTimePitch', 'NSSaveChangesRequest', 'UIReferenceLibraryViewController', 'SKPhysicsJointFixed', 'UILocalizedIndexedCollation', 'UIInterpolatingMotionEffect', 'UIDocumentPickerViewController', 'AVAssetWriter', 'NSBundle', 'SKStoreProductViewController', 'GLKViewController', 'NSMetadataQueryAttributeValueTuple', 'GKTurnBasedMatch', 'AVAudioFile', 'UIActivity', 'NSPipe', 'MKShape', 'NSMergeConflict', 'CIImage', 'HKObject', 'UIRotationGestureRecognizer', 'AVPlayerItemLegibleOutput', 'AVAssetImageGenerator', 'GCControllerButtonInput', 'CKMarkNotificationsReadOperation', 'CKSubscription', 'MPTimedMetadata', 'NKIssue', 'UIScreenMode', 'HMAccessoryBrowser', 'GKTurnBasedEventHandler', 'UIWebView', 'MKPolyline', 'JSVirtualMachine', 'AVAssetReader', 'NSAttributedString', 'GKMatchmakerViewController', 'NSCountedSet', 'UIButton', 'WKNavigationResponse', 'GKLocalPlayer', 'MPMovieErrorLog', 'AVSpeechUtterance', 'HKStatistics', 'UILocalNotification', 'HKBiologicalSexObject', 'AVURLAsset', 'CBPeripheral', 'NSDateComponentsFormatter', 'SKSpriteNode', 'UIAccessibilityElement', 'AVAssetWriterInputGroup', 'HMZone', 'AVAssetReaderAudioMixOutput', 'NSEnumerator', 'UIDocument', 'MKLocalSearchResponse', 'UISimpleTextPrintFormatter', 'PHPhotoLibrary', 'CBService', 'UIDocumentMenuViewController', 'MCSession', 'QLPreviewController', 'CAMediaTimingFunction', 'UITextPosition', 'ASIdentifierManager', 'AVAssetResourceLoadingRequest', 'SLComposeServiceViewController', 'UIPinchGestureRecognizer', 'PHObject', 'NSExtensionItem', 'HKSampleQuery', 'MTLRenderPipelineColorAttachmentDescriptorArray', 'MKRouteStep', 'SCNCapsule', 'NSMetadataQuery', 'AVAssetResourceLoadingContentInformationRequest', 'UITraitCollection', 'CTCarrier', 'NSFileSecurity', 'UIAcceleration', 'UIMotionEffect', 'MTLRenderPipelineReflection', 'CLHeading', 'CLVisit', 'MKDirectionsResponse', 'HMAccessory', 'MTLStructType', 'UITextView', 'CMMagnetometerData', 'UICollisionBehavior', 'UIProgressView', 'CKServerChangeToken', 'UISearchBar', 'MKPlacemark', 'AVCaptureConnection', 'NSPropertyMapping', 'ALAssetsFilter', 'SK3DNode', 'AVPlayerItemErrorLogEvent', 'NSJSONSerialization', 'AVAssetReaderVideoCompositionOutput', 'ABPersonViewController', 'CIDetector', 'GKTurnBasedMatchmakerViewController', 'MPMediaItemCollection', 'SCNSphere', 'NSCondition', 'NSURLCredential', 'MIDINetworkConnection', 'NSFileProviderExtension', 'NSDecimalNumberHandler', 'NSAtomicStoreCacheNode', 'NSAtomicStore', 'EKAlarm', 'CKNotificationInfo', 'AVAudioUnitEQ', 'UIPercentDrivenInteractiveTransition', 'MKPolygon', 'AVAssetTrackSegment', 'MTLVertexAttribute', 'NSExpressionDescription', 'HKStatisticsCollectionQuery', 'NSURLAuthenticationChallenge', 'NSDirectoryEnumerator', 'MKDistanceFormatter', 'UIAlertAction', 'NSPropertyListSerialization', 'GKPeerPickerController', 'UIUserNotificationSettings', 'UITableViewController', 'GKNotificationBanner', 'MKPointAnnotation', 'MTLRenderPassColorAttachmentDescriptorArray', 'NSCache', 'SKPhysicsJoint', 'NSXMLParser', 'UIViewController', 'PKPaymentToken', 'MFMessageComposeViewController', 'AVAudioInputNode', 'NSDataDetector', 'CABTMIDICentralViewController', 'AVAudioUnitMIDIInstrument', 'AVCaptureVideoPreviewLayer', 'AVAssetWriterInputPassDescription', 'MPChangePlaybackRateCommand', 'NSURLComponents', 'CAMetalLayer', 'UISnapBehavior', 'AVMetadataMachineReadableCodeObject', 'CKDiscoverUserInfosOperation', 'NSTextAttachment', 'NSException', 'UIMenuItem', 'CMMotionActivityManager', 'SCNGeometryElement', 'NCWidgetController', 'CAEmitterLayer', 'MKUserLocation', 'UIImagePickerController', 'CIFeature', 'AVCaptureDeviceInput', 'ALAsset', 'NSURLSessionDownloadTask', 'SCNPhysicsHingeJoint', 'MPMoviePlayerViewController', 'NSMutableOrderedSet', 'SCNMaterialProperty', 'UIFont', 'AVCaptureVideoDataOutput', 'NSCachedURLResponse', 'ALAssetsLibrary', 'NSInvocation', 'UILongPressGestureRecognizer', 'NSTextStorage', 'WKWebViewConfiguration', 'CIFaceFeature', 'MKMapSnapshot', 'GLKEffectPropertyFog', 'AVComposition', 'CKDiscoverAllContactsOperation', 'AVAudioMixInputParameters', 'CAEmitterBehavior', 'PKPassLibrary', 'UIMutableUserNotificationCategory', 'NSLock', 'NEVPNProtocolIPSec', 'ADBannerView', 'UIDocumentPickerExtensionViewController', 'UIActivityIndicatorView', 'AVPlayerMediaSelectionCriteria', 'CALayer', 'UIAccessibilityCustomAction', 'UIBarButtonItem', 'AVAudioSessionRouteDescription', 'CLBeaconRegion', 'HKBloodTypeObject', 'MTLVertexBufferLayoutDescriptorArray', 'CABasicAnimation', 'AVVideoCompositionInstruction', 'AVMutableTimedMetadataGroup', 'EKRecurrenceEnd', 'NSTextContainer', 'TWTweetComposeViewController', 'PKPaymentAuthorizationViewController', 'UIScrollView', 'WKNavigationAction', 'AVPlayerItemMetadataOutput', 'EKRecurrenceDayOfWeek', 'NSNumberFormatter', 'MTLComputePipelineReflection', 'UIScreen', 'CLRegion', 'NSProcessInfo', 'GLKTextureInfo', 'SCNSkinner', 'AVCaptureMetadataOutput', 'SCNAnimationEvent', 'NSTextTab', 'JSManagedValue', 'NSDate', 'UITextChecker', 'WKBackForwardListItem', 'NSData', 'NSParagraphStyle', 'AVMutableMetadataItem', 'EKCalendar', 'HKWorkoutEvent', 'NSMutableURLRequest', 'UIVideoEditorController', 'HMTimerTrigger', 'AVAudioUnitVarispeed', 'UIDynamicAnimator', 'AVCompositionTrackSegment', 'GCGamepadSnapshot', 'MPMediaEntity', 'GLKSkyboxEffect', 'UISwitch', 'EKStructuredLocation', 'UIGestureRecognizer', 'NSProxy', 'GLKBaseEffect', 'UIPushBehavior', 'GKScoreChallenge', 'NSCoder', 'MPMediaPlaylist', 'NSDateComponents', 'WKUserScript', 'EKEvent', 'NSDateFormatter', 'NSAsynchronousFetchResult', 'AVAssetWriterInputPixelBufferAdaptor', 'UIVisualEffect', 'UICollectionViewCell', 'UITextField', 'CLPlacemark', 'MPPlayableContentManager', 'AVCaptureOutput', 'HMCharacteristicWriteAction', 'CKModifySubscriptionsOperation', 'NSPropertyDescription', 'GCGamepad', 'UIMarkupTextPrintFormatter', 'SCNTube', 'NSPersistentStoreCoordinator', 'AVAudioEnvironmentNode', 'GKMatchmaker', 'CIContext', 'NSThread', 'SLComposeSheetConfigurationItem', 'SKPhysicsJointSliding', 'NSPredicate', 'GKVoiceChat', 'SKCropNode', 'AVCaptureAudioPreviewOutput', 'NSStringDrawingContext', 'GKGameCenterViewController', 'UIPrintPaper', 'SCNPhysicsBallSocketJoint', 'UICollectionViewLayoutInvalidationContext', 'GLKEffectPropertyTransform', 'AVAudioIONode', 'UIDatePicker', 'MKDirections', 'ALAssetsGroup', 'CKRecordZoneNotification', 'SCNScene', 'MPMovieAccessLogEvent', 'CKFetchSubscriptionsOperation', 'CAEmitterCell', 'AVAudioUnitTimeEffect', 'HMCharacteristicMetadata', 'MKPinAnnotationView', 'UIPickerView', 'UIImageView', 'UIUserNotificationCategory', 'SCNPhysicsVehicleWheel', 'HKCategoryType', 'MPMediaQuerySection', 'GKFriendRequestComposeViewController', 'NSError', 'MTLRenderPipelineColorAttachmentDescriptor', 'SCNPhysicsShape', 'UISearchController', 'SCNPhysicsBody', 'CTSubscriberInfo', 'AVPlayerItemAccessLog', 'MPMediaPropertyPredicate', 'CMLogItem', 'NSAutoreleasePool', 'NSSocketPort', 'AVAssetReaderTrackOutput', 'SKNode', 'UIMutableUserNotificationAction', 'SCNProgram', 'AVSpeechSynthesisVoice', 'CMAltimeter', 'AVCaptureAudioChannel', 'GKTurnBasedExchangeReply', 'AVVideoCompositionLayerInstruction', 'AVSpeechSynthesizer', 'GKChallengeEventHandler', 'AVCaptureFileOutput', 'UIControl', 'SCNPhysicsField', 'CKReference', 'LAContext', 'CKRecordID', 'ADInterstitialAd', 'AVAudioSessionDataSourceDescription', 'AVAudioBuffer', 'CIColorKernel', 'GCControllerDirectionPad', 'NSFileManager', 'AVMutableAudioMixInputParameters', 'UIScreenEdgePanGestureRecognizer', 'CAKeyframeAnimation', 'CKQueryNotification', 'PHAdjustmentData', 'EASession', 'AVAssetResourceRenewalRequest', 'UIInputView', 'NSFileWrapper', 'UIResponder', 'NSPointerFunctions', 'UIKeyCommand', 'NSHTTPCookieStorage', 'AVMediaSelectionOption', 'NSRunLoop', 'NSFileAccessIntent', 'CAAnimationGroup', 'MKCircle', 'UIAlertController', 'NSMigrationManager', 'NSDateIntervalFormatter', 'UICollectionViewUpdateItem', 'CKDatabaseOperation', 'PHImageRequestOptions', 'SKReachConstraints', 'CKRecord', 'CAInterAppAudioSwitcherView', 'WKWindowFeatures', 'GKInvite', 'NSMutableData', 'PHAssetCollectionChangeRequest', 'NSMutableParagraphStyle', 'UIDynamicBehavior', 'GLKEffectProperty', 'CKFetchRecordChangesOperation', 'SKShapeNode', 'MPMovieErrorLogEvent', 'MKPolygonView', 'MPContentItem', 'HMAction', 'NSScanner', 'GKAchievementChallenge', 'AVAudioPlayer', 'CKContainer', 'AVVideoComposition', 'NKLibrary', 'NSPersistentStore', 'AVCaptureMovieFileOutput', 'HMRoom', 'GKChallenge', 'UITextRange', 'NSURLProtectionSpace', 'ACAccountStore', 'MPSkipIntervalCommand', 'NSComparisonPredicate', 'HMHome', 'PHVideoRequestOptions', 'NSOutputStream', 'MPSkipIntervalCommandEvent', 'PKAddPassesViewController', 'UITextSelectionRect', 'CTTelephonyNetworkInfo', 'AVTextStyleRule', 'NSFetchedPropertyDescription', 'UIPageViewController', 'CATransformLayer', 'UICollectionViewController', 'AVAudioNode', 'MCNearbyServiceAdvertiser', 'NSObject', 'PHAsset', 'GKLeaderboardViewController', 'CKQueryCursor', 'MPMusicPlayerController', 'MKOverlayPathRenderer', 'CMPedometerData', 'HMService', 'SKFieldNode', 'GKAchievement', 'WKUserContentController', 'AVAssetTrack', 'TWRequest', 'SKLabelNode', 'AVCaptureBracketedStillImageSettings', 'MIDINetworkHost', 'MPMediaPredicate', 'AVFrameRateRange', 'MTLTextureDescriptor', 'MTLVertexBufferLayoutDescriptor', 'MPFeedbackCommandEvent', 'UIUserNotificationAction', 'HKStatisticsQuery', 'SCNParticleSystem', 'NSIndexPath', 'AVVideoCompositionRenderContext', 'CADisplayLink', 'HKObserverQuery', 'UIPopoverPresentationController', 'CKQueryOperation', 'CAEAGLLayer', 'NSMutableString', 'NSMessagePort', 'NSURLQueryItem', 'MTLStructMember', 'AVAudioSessionChannelDescription', 'GLKView', 'UIActivityViewController', 'GKAchievementViewController', 'GKTurnBasedParticipant', 'NSURLProtocol', 'NSUserDefaults', 'NSCalendar', 'SKKeyframeSequence', 'AVMetadataItemFilter', 'CKModifyRecordZonesOperation', 'WKPreferences', 'NSMethodSignature', 'NSRegularExpression', 'EAGLSharegroup', 'AVPlayerItemVideoOutput', 'PHContentEditingInputRequestOptions', 'GKMatch', 'CIColor', 'UIDictationPhrase']) +COCOA_PROTOCOLS = set(['SKStoreProductViewControllerDelegate', 'AVVideoCompositionInstruction', 'AVAudioSessionDelegate', 'GKMatchDelegate', 'NSFileManagerDelegate', 'UILayoutSupport', 'NSCopying', 'UIPrintInteractionControllerDelegate', 'QLPreviewControllerDataSource', 'SKProductsRequestDelegate', 'NSTextStorageDelegate', 'MCBrowserViewControllerDelegate', 'MTLComputeCommandEncoder', 'SCNSceneExportDelegate', 'UISearchResultsUpdating', 'MFMailComposeViewControllerDelegate', 'MTLBlitCommandEncoder', 'NSDecimalNumberBehaviors', 'PHContentEditingController', 'NSMutableCopying', 'UIActionSheetDelegate', 'UIViewControllerTransitioningDelegate', 'UIAlertViewDelegate', 'AVAudioPlayerDelegate', 'MKReverseGeocoderDelegate', 'NSCoding', 'UITextInputTokenizer', 'GKFriendRequestComposeViewControllerDelegate', 'UIActivityItemSource', 'NSCacheDelegate', 'UIAdaptivePresentationControllerDelegate', 'GKAchievementViewControllerDelegate', 'UIViewControllerTransitionCoordinator', 'EKEventEditViewDelegate', 'NSURLConnectionDelegate', 'UITableViewDelegate', 'GKPeerPickerControllerDelegate', 'UIGuidedAccessRestrictionDelegate', 'AVSpeechSynthesizerDelegate', 'AVAudio3DMixing', 'AVPlayerItemLegibleOutputPushDelegate', 'ADInterstitialAdDelegate', 'HMAccessoryBrowserDelegate', 'AVAssetResourceLoaderDelegate', 'UITabBarControllerDelegate', 'CKRecordValue', 'SKPaymentTransactionObserver', 'AVCaptureAudioDataOutputSampleBufferDelegate', 'UIInputViewAudioFeedback', 'GKChallengeListener', 'SKSceneDelegate', 'UIPickerViewDelegate', 'UIWebViewDelegate', 'UIApplicationDelegate', 'GKInviteEventListener', 'MPMediaPlayback', 'MyClassJavaScriptMethods', 'AVAsynchronousKeyValueLoading', 'QLPreviewItem', 'SCNBoundingVolume', 'NSPortDelegate', 'UIContentContainer', 'SCNNodeRendererDelegate', 'SKRequestDelegate', 'SKPhysicsContactDelegate', 'HMAccessoryDelegate', 'UIPageViewControllerDataSource', 'SCNSceneRendererDelegate', 'SCNPhysicsContactDelegate', 'MKMapViewDelegate', 'AVPlayerItemOutputPushDelegate', 'UICollectionViewDelegate', 'UIImagePickerControllerDelegate', 'MTLRenderCommandEncoder', 'PKPaymentAuthorizationViewControllerDelegate', 'UIToolbarDelegate', 'WKUIDelegate', 'SCNActionable', 'NSURLConnectionDataDelegate', 'MKOverlay', 'CBCentralManagerDelegate', 'JSExport', 'NSTextLayoutOrientationProvider', 'UIPickerViewDataSource', 'PKPushRegistryDelegate', 'UIViewControllerTransitionCoordinatorContext', 'NSLayoutManagerDelegate', 'MTLLibrary', 'NSFetchedResultsControllerDelegate', 'ABPeoplePickerNavigationControllerDelegate', 'MTLResource', 'NSDiscardableContent', 'UITextFieldDelegate', 'MTLBuffer', 'MTLSamplerState', 'GKGameCenterControllerDelegate', 'MPMediaPickerControllerDelegate', 'UISplitViewControllerDelegate', 'UIAppearance', 'UIPickerViewAccessibilityDelegate', 'UITraitEnvironment', 'UIScrollViewAccessibilityDelegate', 'ADBannerViewDelegate', 'MPPlayableContentDataSource', 'MTLComputePipelineState', 'NSURLSessionDelegate', 'MTLCommandBuffer', 'NSXMLParserDelegate', 'UIViewControllerRestoration', 'UISearchBarDelegate', 'UIBarPositioning', 'CBPeripheralDelegate', 'UISearchDisplayDelegate', 'CAAction', 'PKAddPassesViewControllerDelegate', 'MCNearbyServiceAdvertiserDelegate', 'MTLDepthStencilState', 'GKTurnBasedMatchmakerViewControllerDelegate', 'MPPlayableContentDelegate', 'AVCaptureVideoDataOutputSampleBufferDelegate', 'UIAppearanceContainer', 'UIStateRestoring', 'UITextDocumentProxy', 'MTLDrawable', 'NSURLSessionTaskDelegate', 'NSFilePresenter', 'AVAudioStereoMixing', 'UIViewControllerContextTransitioning', 'UITextInput', 'CBPeripheralManagerDelegate', 'UITextInputDelegate', 'NSFastEnumeration', 'NSURLAuthenticationChallengeSender', 'SCNProgramDelegate', 'AVVideoCompositing', 'SCNAnimatable', 'NSSecureCoding', 'MCAdvertiserAssistantDelegate', 'GKLocalPlayerListener', 'GLKNamedEffect', 'UIPopoverControllerDelegate', 'AVCaptureMetadataOutputObjectsDelegate', 'NSExtensionRequestHandling', 'UITextSelecting', 'UIPrinterPickerControllerDelegate', 'NCWidgetProviding', 'MTLCommandEncoder', 'NSURLProtocolClient', 'MFMessageComposeViewControllerDelegate', 'UIVideoEditorControllerDelegate', 'WKNavigationDelegate', 'GKSavedGameListener', 'UITableViewDataSource', 'MTLFunction', 'EKCalendarChooserDelegate', 'NSUserActivityDelegate', 'UICollisionBehaviorDelegate', 'NSStreamDelegate', 'MCNearbyServiceBrowserDelegate', 'HMHomeDelegate', 'UINavigationControllerDelegate', 'MCSessionDelegate', 'UIDocumentPickerDelegate', 'UIViewControllerInteractiveTransitioning', 'GKTurnBasedEventListener', 'SCNSceneRenderer', 'MTLTexture', 'GLKViewDelegate', 'EAAccessoryDelegate', 'WKScriptMessageHandler', 'PHPhotoLibraryChangeObserver', 'NSKeyedUnarchiverDelegate', 'AVPlayerItemMetadataOutputPushDelegate', 'NSMachPortDelegate', 'SCNShadable', 'UIPopoverBackgroundViewMethods', 'UIDocumentMenuDelegate', 'UIBarPositioningDelegate', 'ABPersonViewControllerDelegate', 'NSNetServiceBrowserDelegate', 'EKEventViewDelegate', 'UIScrollViewDelegate', 'NSURLConnectionDownloadDelegate', 'UIGestureRecognizerDelegate', 'UINavigationBarDelegate', 'AVAudioMixing', 'NSFetchedResultsSectionInfo', 'UIDocumentInteractionControllerDelegate', 'MTLParallelRenderCommandEncoder', 'QLPreviewControllerDelegate', 'UIAccessibilityReadingContent', 'ABUnknownPersonViewControllerDelegate', 'GLKViewControllerDelegate', 'UICollectionViewDelegateFlowLayout', 'UIPopoverPresentationControllerDelegate', 'UIDynamicAnimatorDelegate', 'NSTextAttachmentContainer', 'MKAnnotation', 'UIAccessibilityIdentification', 'UICoordinateSpace', 'ABNewPersonViewControllerDelegate', 'MTLDevice', 'CAMediaTiming', 'AVCaptureFileOutputRecordingDelegate', 'HMHomeManagerDelegate', 'UITextViewDelegate', 'UITabBarDelegate', 'GKLeaderboardViewControllerDelegate', 'UISearchControllerDelegate', 'EAWiFiUnconfiguredAccessoryBrowserDelegate', 'UITextInputTraits', 'MTLRenderPipelineState', 'GKVoiceChatClient', 'UIKeyInput', 'UICollectionViewDataSource', 'SCNTechniqueSupport', 'NSLocking', 'AVCaptureFileOutputDelegate', 'GKChallengeEventHandlerDelegate', 'UIObjectRestoration', 'CIFilterConstructor', 'AVPlayerItemOutputPullDelegate', 'EAGLDrawable', 'AVVideoCompositionValidationHandling', 'UIViewControllerAnimatedTransitioning', 'NSURLSessionDownloadDelegate', 'UIAccelerometerDelegate', 'UIPageViewControllerDelegate', 'MTLCommandQueue', 'UIDataSourceModelAssociation', 'AVAudioRecorderDelegate', 'GKSessionDelegate', 'NSKeyedArchiverDelegate', 'CAMetalDrawable', 'UIDynamicItem', 'CLLocationManagerDelegate', 'NSMetadataQueryDelegate', 'NSNetServiceDelegate', 'GKMatchmakerViewControllerDelegate', 'NSURLSessionDataDelegate']) +COCOA_PRIMITIVES = set(['ROTAHeader', '__CFBundle', 'MortSubtable', 'AudioFilePacketTableInfo', 'CGPDFOperatorTable', 'KerxStateEntry', 'ExtendedTempoEvent', 'CTParagraphStyleSetting', 'OpaqueMIDIPort', '_GLKMatrix3', '_GLKMatrix2', '_GLKMatrix4', 'ExtendedControlEvent', 'CAFAudioDescription', 'OpaqueCMBlockBuffer', 'CGTextDrawingMode', 'EKErrorCode', 'gss_buffer_desc_struct', 'AudioUnitParameterInfo', '__SCPreferences', '__CTFrame', '__CTLine', 'AudioFile_SMPTE_Time', 'gss_krb5_lucid_context_v1', 'OpaqueJSValue', 'TrakTableEntry', 'AudioFramePacketTranslation', 'CGImageSource', 'OpaqueJSPropertyNameAccumulator', 'JustPCGlyphRepeatAddAction', '__CFBinaryHeap', 'OpaqueMIDIThruConnection', 'opaqueCMBufferQueue', 'OpaqueMusicSequence', 'MortRearrangementSubtable', 'MixerDistanceParams', 'MorxSubtable', 'MIDIObjectPropertyChangeNotification', 'SFNTLookupSegment', 'CGImageMetadataErrors', 'CGPath', 'OpaqueMIDIEndpoint', 'AudioComponentPlugInInterface', 'gss_ctx_id_t_desc_struct', 'sfntFontFeatureSetting', 'OpaqueJSContextGroup', '__SCNetworkConnection', 'AudioUnitParameterValueTranslation', 'CGImageMetadataType', 'CGPattern', 'AudioFileTypeAndFormatID', 'CGContext', 'AUNodeInteraction', 'SFNTLookupTable', 'JustPCDecompositionAction', 'KerxControlPointHeader', 'AudioStreamPacketDescription', 'KernSubtableHeader', '__SecCertificate', 'AUMIDIOutputCallbackStruct', 'MIDIMetaEvent', 'AudioQueueChannelAssignment', 'AnchorPoint', 'JustTable', '__CFNetService', 'CF_BRIDGED_TYPE', 'gss_krb5_lucid_key', 'CGPDFDictionary', 'KerxSubtableHeader', 'CAF_UUID_ChunkHeader', 'gss_krb5_cfx_keydata', 'OpaqueJSClass', 'CGGradient', 'OpaqueMIDISetup', 'JustPostcompTable', '__CTParagraphStyle', 'AudioUnitParameterHistoryInfo', 'OpaqueJSContext', 'CGShading', 'MIDIThruConnectionParams', 'BslnFormat0Part', 'SFNTLookupSingle', '__CFHost', '__SecRandom', '__CTFontDescriptor', '_NSRange', 'sfntDirectory', 'AudioQueueLevelMeterState', 'CAFPositionPeak', 'PropLookupSegment', '__CVOpenGLESTextureCache', 'sfntInstance', '_GLKQuaternion', 'AnkrTable', '__SCNetworkProtocol', 'CAFFileHeader', 'KerxOrderedListHeader', 'CGBlendMode', 'STXEntryOne', 'CAFRegion', 'SFNTLookupTrimmedArrayHeader', 'SCNMatrix4', 'KerxControlPointEntry', 'OpaqueMusicTrack', '_GLKVector4', 'gss_OID_set_desc_struct', 'OpaqueMusicPlayer', '_CFHTTPAuthentication', 'CGAffineTransform', 'CAFMarkerChunk', 'AUHostIdentifier', 'ROTAGlyphEntry', 'BslnTable', 'gss_krb5_lucid_context_version', '_GLKMatrixStack', 'CGImage', 'KernStateEntry', 'SFNTLookupSingleHeader', 'MortLigatureSubtable', 'CAFUMIDChunk', 'SMPTETime', 'CAFDataChunk', 'CGPDFStream', 'AudioFileRegionList', 'STEntryTwo', 'SFNTLookupBinarySearchHeader', 'OpbdTable', '__CTGlyphInfo', 'BslnFormat2Part', 'KerxIndexArrayHeader', 'TrakTable', 'KerxKerningPair', '__CFBitVector', 'KernVersion0SubtableHeader', 'OpaqueAudioComponentInstance', 'AudioChannelLayout', '__CFUUID', 'MIDISysexSendRequest', '__CFNumberFormatter', 'CGImageSourceStatus', 'AudioFileMarkerList', 'AUSamplerBankPresetData', 'CGDataProvider', 'AudioFormatInfo', '__SecIdentity', 'sfntCMapExtendedSubHeader', 'MIDIChannelMessage', 'KernOffsetTable', 'CGColorSpaceModel', 'MFMailComposeErrorCode', 'CGFunction', '__SecTrust', 'AVAudio3DAngularOrientation', 'CGFontPostScriptFormat', 'KernStateHeader', 'AudioUnitCocoaViewInfo', 'CGDataConsumer', 'OpaqueMIDIDevice', 'KernVersion0Header', 'AnchorPointTable', 'CGImageDestination', 'CAFInstrumentChunk', 'AudioUnitMeterClipping', 'MorxChain', '__CTFontCollection', 'STEntryOne', 'STXEntryTwo', 'ExtendedNoteOnEvent', 'CGColorRenderingIntent', 'KerxSimpleArrayHeader', 'MorxTable', '_GLKVector3', '_GLKVector2', 'MortTable', 'CGPDFBox', 'AudioUnitParameterValueFromString', '__CFSocket', 'ALCdevice_struct', 'MIDINoteMessage', 'sfntFeatureHeader', 'CGRect', '__SCNetworkInterface', '__CFTree', 'MusicEventUserData', 'TrakTableData', 'GCQuaternion', 'MortContextualSubtable', '__CTRun', 'AudioUnitFrequencyResponseBin', 'MortChain', 'MorxInsertionSubtable', 'CGImageMetadata', 'gss_auth_identity', 'AudioUnitMIDIControlMapping', 'CAFChunkHeader', 'CGImagePropertyOrientation', 'CGPDFScanner', 'OpaqueMusicEventIterator', 'sfntDescriptorHeader', 'AudioUnitNodeConnection', 'OpaqueMIDIDeviceList', 'ExtendedAudioFormatInfo', 'BslnFormat1Part', 'sfntFontDescriptor', 'KernSimpleArrayHeader', '__CFRunLoopObserver', 'CGPatternTiling', 'MIDINotification', 'MorxLigatureSubtable', 'MessageComposeResult', 'MIDIThruConnectionEndpoint', 'MusicDeviceStdNoteParams', 'opaqueCMSimpleQueue', 'ALCcontext_struct', 'OpaqueAudioQueue', 'PropLookupSingle', 'CGInterpolationQuality', 'CGColor', 'AudioOutputUnitStartAtTimeParams', 'gss_name_t_desc_struct', 'CGFunctionCallbacks', 'CAFPacketTableHeader', 'AudioChannelDescription', 'sfntFeatureName', 'MorxContextualSubtable', 'CVSMPTETime', 'AudioValueRange', 'CGTextEncoding', 'AudioStreamBasicDescription', 'AUNodeRenderCallback', 'AudioPanningInfo', 'KerxOrderedListEntry', '__CFAllocator', 'OpaqueJSPropertyNameArray', '__SCDynamicStore', 'OpaqueMIDIEntity', '__CTRubyAnnotation', 'SCNVector4', 'CFHostClientContext', 'CFNetServiceClientContext', 'AudioUnitPresetMAS_SettingData', 'opaqueCMBufferQueueTriggerToken', 'AudioUnitProperty', 'CAFRegionChunk', 'CGPDFString', '__GLsync', '__CFStringTokenizer', 'JustWidthDeltaEntry', 'sfntVariationAxis', '__CFNetDiagnostic', 'CAFOverviewSample', 'sfntCMapEncoding', 'CGVector', '__SCNetworkService', 'opaqueCMSampleBuffer', 'AUHostVersionIdentifier', 'AudioBalanceFade', 'sfntFontRunFeature', 'KerxCoordinateAction', 'sfntCMapSubHeader', 'CVPlanarPixelBufferInfo', 'AUNumVersion', 'AUSamplerInstrumentData', 'AUPreset', '__CTRunDelegate', 'OpaqueAudioQueueProcessingTap', 'KerxTableHeader', '_NSZone', 'OpaqueExtAudioFile', '__CFRunLoopSource', '__CVMetalTextureCache', 'KerxAnchorPointAction', 'OpaqueJSString', 'AudioQueueParameterEvent', '__CFHTTPMessage', 'OpaqueCMClock', 'ScheduledAudioFileRegion', 'STEntryZero', 'AVAudio3DPoint', 'gss_channel_bindings_struct', 'sfntVariationHeader', 'AUChannelInfo', 'UIOffset', 'GLKEffectPropertyPrv', 'KerxStateHeader', 'CGLineJoin', 'CGPDFDocument', '__CFBag', 'KernOrderedListHeader', '__SCNetworkSet', '__SecKey', 'MIDIObjectAddRemoveNotification', 'AudioUnitParameter', 'JustPCActionSubrecord', 'AudioComponentDescription', 'AudioUnitParameterValueName', 'AudioUnitParameterEvent', 'KerxControlPointAction', 'AudioTimeStamp', 'KernKerningPair', 'gss_buffer_set_desc_struct', 'MortFeatureEntry', 'FontVariation', 'CAFStringID', 'LcarCaretClassEntry', 'AudioUnitParameterStringFromValue', 'ACErrorCode', 'ALMXGlyphEntry', 'LtagTable', '__CTTypesetter', 'AuthorizationOpaqueRef', 'UIEdgeInsets', 'CGPathElement', 'CAFMarker', 'KernTableHeader', 'NoteParamsControlValue', 'SSLContext', 'gss_cred_id_t_desc_struct', 'AudioUnitParameterNameInfo', 'CGDataConsumerCallbacks', 'ALMXHeader', 'CGLineCap', 'MIDIControlTransform', 'CGPDFArray', '__SecPolicy', 'AudioConverterPrimeInfo', '__CTTextTab', '__CFNetServiceMonitor', 'AUInputSamplesInOutputCallbackStruct', '__CTFramesetter', 'CGPDFDataFormat', 'STHeader', 'CVPlanarPixelBufferInfo_YCbCrPlanar', 'MIDIValueMap', 'JustDirectionTable', '__SCBondStatus', 'SFNTLookupSegmentHeader', 'OpaqueCMMemoryPool', 'CGPathDrawingMode', 'CGFont', '__SCNetworkReachability', 'AudioClassDescription', 'CGPoint', 'AVAudio3DVectorOrientation', 'CAFStrings', '__CFNetServiceBrowser', 'opaqueMTAudioProcessingTap', 'sfntNameRecord', 'CGPDFPage', 'CGLayer', 'ComponentInstanceRecord', 'CAFInfoStrings', 'HostCallbackInfo', 'MusicDeviceNoteParams', 'OpaqueVTCompressionSession', 'KernIndexArrayHeader', 'CVPlanarPixelBufferInfo_YCbCrBiPlanar', 'MusicTrackLoopInfo', 'opaqueCMFormatDescription', 'STClassTable', 'sfntDirectoryEntry', 'OpaqueCMTimebase', 'CGDataProviderDirectCallbacks', 'MIDIPacketList', 'CAFOverviewChunk', 'MIDIPacket', 'ScheduledAudioSlice', 'CGDataProviderSequentialCallbacks', 'AudioBuffer', 'MorxRearrangementSubtable', 'CGPatternCallbacks', 'AUDistanceAttenuationData', 'MIDIIOErrorNotification', 'CGPDFContentStream', 'IUnknownVTbl', 'MIDITransform', 'MortInsertionSubtable', 'CABarBeatTime', 'AudioBufferList', '__CVBuffer', 'AURenderCallbackStruct', 'STXEntryZero', 'JustPCDuctilityAction', 'OpaqueAudioQueueTimeline', 'VTDecompressionOutputCallbackRecord', 'OpaqueMIDIClient', '__CFPlugInInstance', 'AudioQueueBuffer', '__CFFileDescriptor', 'AudioUnitConnection', '_GKTurnBasedExchangeStatus', 'LcarCaretTable', 'CVPlanarComponentInfo', 'JustWidthDeltaGroup', 'OpaqueAudioComponent', 'ParameterEvent', '__CVPixelBufferPool', '__CTFont', 'CGColorSpace', 'CGSize', 'AUDependentParameter', 'MIDIDriverInterface', 'gss_krb5_rfc1964_keydata', '__CFDateFormatter', 'LtagStringRange', 'OpaqueVTDecompressionSession', 'gss_iov_buffer_desc_struct', 'AUPresetEvent', 'PropTable', 'KernOrderedListEntry', 'CF_BRIDGED_MUTABLE_TYPE', 'gss_OID_desc_struct', 'AudioUnitPresetMAS_Settings', 'AudioFileMarker', 'JustPCConditionalAddAction', 'BslnFormat3Part', '__CFNotificationCenter', 'MortSwashSubtable', 'AUParameterMIDIMapping', 'SCNVector3', 'OpaqueAudioConverter', 'MIDIRawData', 'sfntNameHeader', '__CFRunLoop', 'MFMailComposeResult', 'CATransform3D', 'OpbdSideValues', 'CAF_SMPTE_Time', '__SecAccessControl', 'JustPCAction', 'OpaqueVTFrameSilo', 'OpaqueVTMultiPassStorage', 'CGPathElementType', 'AudioFormatListItem', 'AudioUnitExternalBuffer', 'AudioFileRegion', 'AudioValueTranslation', 'CGImageMetadataTag', 'CAFPeakChunk', 'AudioBytePacketTranslation', 'sfntCMapHeader', '__CFURLEnumerator', 'STXHeader', 'CGPDFObjectType', 'SFNTLookupArrayHeader']) if __name__ == '__main__': # pragma: no cover import os import re - FRAMEWORKS_PATH = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks/' + FRAMEWORKS_PATH = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/System/Library/Frameworks/' frameworks = os.listdir(FRAMEWORKS_PATH) all_interfaces = set() -- cgit v1.2.1 From 41e23d60dc516a22966325f97b7b00b448bd55a7 Mon Sep 17 00:00:00 2001 From: Soonho Kong Date: Thu, 15 Jan 2015 16:37:45 +0900 Subject: Add three missing operators '?', '?', '?' for Lean theorem prover --- pygments/lexers/theorem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygments/lexers/theorem.py b/pygments/lexers/theorem.py index b8b08b53..addf4186 100644 --- a/pygments/lexers/theorem.py +++ b/pygments/lexers/theorem.py @@ -420,7 +420,7 @@ class LeanLexer(RegexLexer): '-.', '->', '.', '..', '...', '::', ':>', ';', ';;', '<', '<-', '=', '==', '>', '_', '`', '|', '||', '~', '=>', '<=', '>=', '/\\', '\\/', u'∀', u'Π', u'λ', u'↔', u'∧', u'∨', u'≠', u'≤', u'≥', - u'¬', u'⁻¹', u'⬝', u'▸', u'→', u'∃', u'ℕ', u'ℤ', u'≈', u'×' + u'¬', u'⁻¹', u'⬝', u'▸', u'→', u'∃', u'ℕ', u'ℤ', u'≈', u'×', u'⌞', u'⌟', u'≡' ) word_operators = ('and', 'or', 'not', 'iff', 'eq') -- cgit v1.2.1 From f0fb7b24cb57727640f119c7497127c290549bd5 Mon Sep 17 00:00:00 2001 From: Soonho Kong Date: Fri, 16 Jan 2015 07:49:39 +0900 Subject: remove tactics, word_operators, and primitives from highlighting --- pygments/lexers/theorem.py | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/pygments/lexers/theorem.py b/pygments/lexers/theorem.py index addf4186..5b71bf97 100644 --- a/pygments/lexers/theorem.py +++ b/pygments/lexers/theorem.py @@ -395,11 +395,13 @@ class LeanLexer(RegexLexer): 'options', 'precedence', 'postfix', 'prefix', 'calc_trans', 'calc_subst', 'calc_refl', 'infix', 'infixl', 'infixr', 'notation', 'eval', 'check', 'exit', 'coercion', 'end', 'private', 'using', 'namespace', 'including', 'instance', 'section', 'context', - 'protected', 'expose', 'export', 'set_option', 'add_rewrite', 'extends') + 'protected', 'expose', 'export', 'set_option', 'add_rewrite', 'extends', + 'open', 'example', 'constant', 'constants', 'print', 'opaque', 'reducible', 'irreducible' + ) keywords2 = ( - 'forall', 'exists', 'fun', 'Pi', 'obtain', 'from', 'have', 'show', 'assume', 'take', - 'let', 'if', 'else', 'then', 'by', 'in', 'with', 'begin', 'proof', 'qed', 'calc' + 'forall', 'fun', 'Pi', 'obtain', 'from', 'have', 'show', 'assume', 'take', + 'let', 'if', 'else', 'then', 'by', 'in', 'with', 'begin', 'proof', 'qed', 'calc', 'match' ) keywords3 = ( @@ -407,14 +409,6 @@ class LeanLexer(RegexLexer): 'Type', 'Prop', ) - keywords4 = ( - # Tactics - 'apply', 'and_then', 'or_else', 'append', 'interleave', 'par', 'fixpoint', 'repeat', - 'at_most', 'discard', 'focus_at', 'rotate', 'try_for', 'now', 'assumption', 'eassumption', - 'state', 'intro', 'generalize', 'exact', 'unfold', 'beta', 'trace', 'focus', 'repeat1', - 'determ', 'destruct', 'try', 'auto', 'intros' - ) - operators = ( '!=', '#', '&', '&&', '*', '+', '-', '/', '@', '!', '`', '-.', '->', '.', '..', '...', '::', ':>', ';', ';;', '<', @@ -423,33 +417,24 @@ class LeanLexer(RegexLexer): u'¬', u'⁻¹', u'⬝', u'▸', u'→', u'∃', u'ℕ', u'ℤ', u'≈', u'×', u'⌞', u'⌟', u'≡' ) - word_operators = ('and', 'or', 'not', 'iff', 'eq') - punctuation = ('(', ')', ':', '{', '}', '[', ']', u'⦃', u'⦄', ':=', ',') - primitives = ('unit', 'int', 'bool', 'string', 'char', 'list', - 'array', 'prod', 'sum', 'pair', 'real', 'nat', 'num', 'path') - tokens = { 'root': [ (r'\s+', Text), - (r'\b(false|true)\b|\(\)|\[\]', Name.Builtin.Pseudo), (r'/-', Comment, 'comment'), (r'--.*?$', Comment.Single), (words(keywords1, prefix=r'\b', suffix=r'\b'), Keyword.Namespace), (words(keywords2, prefix=r'\b', suffix=r'\b'), Keyword), (words(keywords3, prefix=r'\b', suffix=r'\b'), Keyword.Type), - (words(keywords4, prefix=r'\b', suffix=r'\b'), Keyword), (words(operators), Name.Builtin.Pseudo), - (words(word_operators, prefix=r'\b', suffix=r'\b'), Name.Builtin.Pseudo), (words(punctuation), Operator), - (words(primitives, prefix=r'\b', suffix=r'\b'), Keyword.Type), (u"[A-Za-z_\u03b1-\u03ba\u03bc-\u03fb\u1f00-\u1ffe\u2100-\u214f]" u"[A-Za-z_'\u03b1-\u03ba\u03bc-\u03fb\u1f00-\u1ffe\u2070-\u2079" - u"\u207f-\u2089\u2090-\u209c\u2100-\u214f]*", Name), + u"\u207f-\u2089\u2090-\u209c\u2100-\u214f0-9]*", Name), (r'\d+', Number.Integer), (r'"', String.Double, 'string'), - (r'[~?][a-z][\w\']*:', Name.Variable) + (r'[~?][A-z][\w\']*:', Name.Variable) ], 'comment': [ # Multiline Comments -- cgit v1.2.1 From e776ca304cd6b2241dc15490cefbd275e87a574a Mon Sep 17 00:00:00 2001 From: Soonho Kong Date: Fri, 16 Jan 2015 18:07:07 +0900 Subject: Rollback to [a-z] for the Name.Variable --- pygments/lexers/theorem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygments/lexers/theorem.py b/pygments/lexers/theorem.py index 5b71bf97..b2a51dcf 100644 --- a/pygments/lexers/theorem.py +++ b/pygments/lexers/theorem.py @@ -434,7 +434,7 @@ class LeanLexer(RegexLexer): u"\u207f-\u2089\u2090-\u209c\u2100-\u214f0-9]*", Name), (r'\d+', Number.Integer), (r'"', String.Double, 'string'), - (r'[~?][A-z][\w\']*:', Name.Variable) + (r'[~?][a-z][\w\']*:', Name.Variable) ], 'comment': [ # Multiline Comments -- cgit v1.2.1 From 84912b7d20dacce310b32eb7ad01fc503828921e Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 20 Jan 2015 07:55:32 +0100 Subject: Fix Python tracebacks getting duplicated in the console lexer (closes #1068). --- CHANGES | 9 +++++++++ pygments/lexers/python.py | 1 + 2 files changed, 10 insertions(+) diff --git a/CHANGES b/CHANGES index 7031852e..5145acb4 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,15 @@ pull request numbers to the requests at . +Version 2.0.2 +------------- +(released Jan 20, 2014) + +- Fix Python tracebacks getting duplicated in the console lexer (#1068). + +- Backquote-delimited identifiers are now recognized in F# (#1062). + + Version 2.0.1 ------------- (released Nov 10, 2014) diff --git a/pygments/lexers/python.py b/pygments/lexers/python.py index 259d1a9c..01ab1e7d 100644 --- a/pygments/lexers/python.py +++ b/pygments/lexers/python.py @@ -378,6 +378,7 @@ class PythonConsoleLexer(Lexer): tb = 0 for i, t, v in tblexer.get_tokens_unprocessed(curtb): yield tbindex+i, t, v + curtb = '' else: yield match.start(), Generic.Output, line if curcode: -- cgit v1.2.1 -- cgit v1.2.1 From 25fcdc1d2a43c24efa38b0ac4075913fccfc2072 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 20 Jan 2015 07:57:03 +0100 Subject: Bump to 2.0.2. --- pygments/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pygments/__init__.py b/pygments/__init__.py index dc377369..9563818b 100644 --- a/pygments/__init__.py +++ b/pygments/__init__.py @@ -26,7 +26,7 @@ :license: BSD, see LICENSE for details. """ -__version__ = '2.0.1' +__version__ = '2.0.2' __docformat__ = 'restructuredtext' __all__ = ['lex', 'format', 'highlight'] diff --git a/setup.py b/setup.py index c46d805e..875cb424 100755 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ else: setup( name = 'Pygments', - version = '2.0.1', + version = '2.0.2', url = 'http://pygments.org/', license = 'BSD License', author = 'Georg Brandl', -- cgit v1.2.1 -- cgit v1.2.1 From 181e8bff0a08fe2e31607991ef2c5b5b5d060f1b Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 21 Jan 2015 07:25:35 +0100 Subject: Closes #1075: fix docs for @simplefilter. The function needs a "self" argument since it is used as a method in the automatically created class. No use fixing that in the code, as it kills backwards compatibility. --- .hgignore | 1 + doc/docs/filterdevelopment.rst | 5 +++-- pygments/filter.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.hgignore b/.hgignore index 509abffa..6fd21b49 100644 --- a/.hgignore +++ b/.hgignore @@ -10,5 +10,6 @@ Pygments.egg-info/* tests/examplefiles/output .idea/ .tags +TAGS tests/.coverage tests/cover diff --git a/doc/docs/filterdevelopment.rst b/doc/docs/filterdevelopment.rst index 5f9ca8c7..fbcd0a09 100644 --- a/doc/docs/filterdevelopment.rst +++ b/doc/docs/filterdevelopment.rst @@ -58,7 +58,7 @@ You can also use the `simplefilter` decorator from the `pygments.filter` module: @simplefilter - def uncolor(lexer, stream, options): + def uncolor(self, lexer, stream, options): class_too = get_bool_opt(options, 'classtoo') for ttype, value in stream: if ttype is Name.Function or (class_too and @@ -67,4 +67,5 @@ You can also use the `simplefilter` decorator from the `pygments.filter` module: yield ttype, value The decorator automatically subclasses an internal filter class and uses the -decorated function for filtering. +decorated function as a method for filtering. (That's why there is a `self` +argument that you probably won't end up using in the method.) diff --git a/pygments/filter.py b/pygments/filter.py index 092ef331..12eb6f03 100644 --- a/pygments/filter.py +++ b/pygments/filter.py @@ -29,7 +29,7 @@ def simplefilter(f): Decorator that converts a function into a filter:: @simplefilter - def lowercase(lexer, stream, options): + def lowercase(self, lexer, stream, options): for ttype, value in stream: yield ttype, value.lower() """ -- cgit v1.2.1 From 7b9fa24091fe62a1be03c5c7889ce1ba6248c6a2 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 21 Jan 2015 07:25:35 +0100 Subject: Closes #1075: fix docs for @simplefilter. The function needs a "self" argument since it is used as a method in the automatically created class. No use fixing that in the code, as it kills backwards compatibility. --- .hgignore | 1 + doc/docs/filterdevelopment.rst | 5 +++-- pygments/filter.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.hgignore b/.hgignore index 509abffa..6fd21b49 100644 --- a/.hgignore +++ b/.hgignore @@ -10,5 +10,6 @@ Pygments.egg-info/* tests/examplefiles/output .idea/ .tags +TAGS tests/.coverage tests/cover diff --git a/doc/docs/filterdevelopment.rst b/doc/docs/filterdevelopment.rst index 5f9ca8c7..fbcd0a09 100644 --- a/doc/docs/filterdevelopment.rst +++ b/doc/docs/filterdevelopment.rst @@ -58,7 +58,7 @@ You can also use the `simplefilter` decorator from the `pygments.filter` module: @simplefilter - def uncolor(lexer, stream, options): + def uncolor(self, lexer, stream, options): class_too = get_bool_opt(options, 'classtoo') for ttype, value in stream: if ttype is Name.Function or (class_too and @@ -67,4 +67,5 @@ You can also use the `simplefilter` decorator from the `pygments.filter` module: yield ttype, value The decorator automatically subclasses an internal filter class and uses the -decorated function for filtering. +decorated function as a method for filtering. (That's why there is a `self` +argument that you probably won't end up using in the method.) diff --git a/pygments/filter.py b/pygments/filter.py index 092ef331..12eb6f03 100644 --- a/pygments/filter.py +++ b/pygments/filter.py @@ -29,7 +29,7 @@ def simplefilter(f): Decorator that converts a function into a filter:: @simplefilter - def lowercase(lexer, stream, options): + def lowercase(self, lexer, stream, options): for ttype, value in stream: yield ttype, value.lower() """ -- cgit v1.2.1 From bafb45a9a47e6c40b550c77402e1dd66f93129ef Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 21 Jan 2015 07:43:26 +0100 Subject: Fix highlighting of certain IRC logs formats (closes #1076). --- CHANGES | 7 +++++++ pygments/lexers/textfmts.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 5145acb4..a0df0a9f 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,13 @@ pull request numbers to the requests at . +Version 2.0.3 +------------- +(not released yet) + +- Fix highlighting of certain IRC logs formats (#1076). + + Version 2.0.2 ------------- (released Jan 20, 2014) diff --git a/pygments/lexers/textfmts.py b/pygments/lexers/textfmts.py index 189d334a..60251940 100644 --- a/pygments/lexers/textfmts.py +++ b/pygments/lexers/textfmts.py @@ -39,7 +39,7 @@ class IrcLogsLexer(RegexLexer): (?:\d{1,4}) [T ])? # Date/time separator: T or space (?: \d?\d [:.])* # Time as :/.-separated groups of 1 or 2 digits - (?: \d?\d [:.]) + (?: \d?\d) ) (?: \]|\))?\s+ # Closing bracket or paren for the timestamp | -- cgit v1.2.1 From 3cff560fe7d84b1216fc6181c0a9cb0f2b3b9332 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 21 Jan 2015 08:29:11 +0100 Subject: closes #1077: fix year. --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index a0df0a9f..57f03a2b 100644 --- a/CHANGES +++ b/CHANGES @@ -16,7 +16,7 @@ Version 2.0.3 Version 2.0.2 ------------- -(released Jan 20, 2014) +(released Jan 20, 2015) - Fix Python tracebacks getting duplicated in the console lexer (#1068). -- cgit v1.2.1 From 13705acbd57b936990c63a12de05ce29834b6afb Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 21 Jan 2015 08:33:25 +0100 Subject: Copyright year update. --- LICENSE | 2 +- Makefile | 2 +- doc/_themes/pygments14/layout.html | 2 +- doc/_themes/pygments14/static/pygments14.css_t | 2 +- doc/conf.py | 12 ++---------- external/markdown-processor.py | 2 +- external/moin-parser.py | 2 +- external/rst-directive.py | 2 +- pygments/__init__.py | 2 +- pygments/cmdline.py | 4 ++-- pygments/console.py | 2 +- pygments/filter.py | 2 +- pygments/filters/__init__.py | 2 +- pygments/formatter.py | 2 +- pygments/formatters/__init__.py | 2 +- pygments/formatters/_mapping.py | 2 +- pygments/formatters/bbcode.py | 2 +- pygments/formatters/html.py | 2 +- pygments/formatters/img.py | 2 +- pygments/formatters/latex.py | 2 +- pygments/formatters/other.py | 2 +- pygments/formatters/rtf.py | 2 +- pygments/formatters/svg.py | 2 +- pygments/formatters/terminal.py | 2 +- pygments/formatters/terminal256.py | 2 +- pygments/lexer.py | 2 +- pygments/lexers/__init__.py | 2 +- pygments/lexers/_asy_builtins.py | 2 +- pygments/lexers/_cl_builtins.py | 2 +- pygments/lexers/_cocoa_builtins.py | 2 +- pygments/lexers/_lasso_builtins.py | 2 +- pygments/lexers/_lua_builtins.py | 2 +- pygments/lexers/_mapping.py | 2 +- pygments/lexers/_mql_builtins.py | 2 +- pygments/lexers/_openedge_builtins.py | 2 +- pygments/lexers/_php_builtins.py | 2 +- pygments/lexers/_postgres_builtins.py | 2 +- pygments/lexers/_scilab_builtins.py | 2 +- pygments/lexers/_sourcemod_builtins.py | 2 +- pygments/lexers/_stan_builtins.py | 2 +- pygments/lexers/_vim_builtins.py | 2 +- pygments/lexers/actionscript.py | 2 +- pygments/lexers/agile.py | 2 +- pygments/lexers/algebra.py | 2 +- pygments/lexers/ambient.py | 2 +- pygments/lexers/apl.py | 2 +- pygments/lexers/asm.py | 2 +- pygments/lexers/automation.py | 2 +- pygments/lexers/basic.py | 2 +- pygments/lexers/business.py | 2 +- pygments/lexers/c_cpp.py | 2 +- pygments/lexers/c_like.py | 2 +- pygments/lexers/chapel.py | 2 +- pygments/lexers/compiled.py | 2 +- pygments/lexers/configs.py | 2 +- pygments/lexers/console.py | 2 +- pygments/lexers/css.py | 2 +- pygments/lexers/d.py | 2 +- pygments/lexers/dalvik.py | 2 +- pygments/lexers/data.py | 2 +- pygments/lexers/diff.py | 2 +- pygments/lexers/dotnet.py | 2 +- pygments/lexers/dsls.py | 2 +- pygments/lexers/dylan.py | 2 +- pygments/lexers/ecl.py | 2 +- pygments/lexers/eiffel.py | 2 +- pygments/lexers/erlang.py | 2 +- pygments/lexers/esoteric.py | 2 +- pygments/lexers/factor.py | 2 +- pygments/lexers/fantom.py | 2 +- pygments/lexers/felix.py | 2 +- pygments/lexers/fortran.py | 2 +- pygments/lexers/foxpro.py | 2 +- pygments/lexers/functional.py | 2 +- pygments/lexers/go.py | 2 +- pygments/lexers/graph.py | 2 +- pygments/lexers/graphics.py | 2 +- pygments/lexers/haskell.py | 2 +- pygments/lexers/haxe.py | 2 +- pygments/lexers/hdl.py | 2 +- pygments/lexers/html.py | 2 +- pygments/lexers/idl.py | 2 +- pygments/lexers/igor.py | 2 +- pygments/lexers/inferno.py | 2 +- pygments/lexers/installers.py | 2 +- pygments/lexers/int_fiction.py | 2 +- pygments/lexers/iolang.py | 2 +- pygments/lexers/javascript.py | 2 +- pygments/lexers/julia.py | 2 +- pygments/lexers/jvm.py | 2 +- pygments/lexers/lisp.py | 2 +- pygments/lexers/make.py | 2 +- pygments/lexers/markup.py | 2 +- pygments/lexers/math.py | 2 +- pygments/lexers/matlab.py | 2 +- pygments/lexers/ml.py | 2 +- pygments/lexers/modeling.py | 2 +- pygments/lexers/nimrod.py | 2 +- pygments/lexers/nit.py | 2 +- pygments/lexers/nix.py | 2 +- pygments/lexers/objective.py | 2 +- pygments/lexers/ooc.py | 2 +- pygments/lexers/other.py | 2 +- pygments/lexers/parsers.py | 2 +- pygments/lexers/pascal.py | 2 +- pygments/lexers/pawn.py | 2 +- pygments/lexers/perl.py | 2 +- pygments/lexers/php.py | 2 +- pygments/lexers/prolog.py | 2 +- pygments/lexers/python.py | 2 +- pygments/lexers/r.py | 2 +- pygments/lexers/rdf.py | 2 +- pygments/lexers/rebol.py | 2 +- pygments/lexers/resource.py | 2 +- pygments/lexers/robotframework.py | 2 +- pygments/lexers/ruby.py | 2 +- pygments/lexers/rust.py | 2 +- pygments/lexers/scripting.py | 2 +- pygments/lexers/shell.py | 2 +- pygments/lexers/smalltalk.py | 2 +- pygments/lexers/snobol.py | 2 +- pygments/lexers/special.py | 2 +- pygments/lexers/sql.py | 2 +- pygments/lexers/tcl.py | 2 +- pygments/lexers/templates.py | 2 +- pygments/lexers/testing.py | 2 +- pygments/lexers/text.py | 2 +- pygments/lexers/textedit.py | 2 +- pygments/lexers/textfmts.py | 2 +- pygments/lexers/theorem.py | 2 +- pygments/lexers/urbi.py | 2 +- pygments/lexers/web.py | 2 +- pygments/lexers/webmisc.py | 2 +- pygments/modeline.py | 2 +- pygments/plugin.py | 2 +- pygments/regexopt.py | 2 +- pygments/scanner.py | 2 +- pygments/sphinxext.py | 2 +- pygments/style.py | 2 +- pygments/styles/__init__.py | 2 +- pygments/styles/autumn.py | 2 +- pygments/styles/borland.py | 2 +- pygments/styles/bw.py | 2 +- pygments/styles/colorful.py | 2 +- pygments/styles/default.py | 2 +- pygments/styles/emacs.py | 2 +- pygments/styles/friendly.py | 2 +- pygments/styles/fruity.py | 2 +- pygments/styles/igor.py | 2 +- pygments/styles/manni.py | 2 +- pygments/styles/monokai.py | 2 +- pygments/styles/murphy.py | 2 +- pygments/styles/native.py | 2 +- pygments/styles/paraiso_dark.py | 2 +- pygments/styles/paraiso_light.py | 2 +- pygments/styles/pastie.py | 2 +- pygments/styles/perldoc.py | 2 +- pygments/styles/rrt.py | 2 +- pygments/styles/tango.py | 2 +- pygments/styles/trac.py | 2 +- pygments/styles/vim.py | 2 +- pygments/styles/vs.py | 2 +- pygments/styles/xcode.py | 2 +- pygments/token.py | 2 +- pygments/unistring.py | 2 +- pygments/util.py | 2 +- scripts/check_sources.py | 4 ++-- scripts/debug_lexer.py | 2 +- scripts/get_vimkw.py | 2 +- setup.py | 2 +- tests/run.py | 2 +- tests/string_asserts.py | 2 +- tests/test_basic_api.py | 2 +- tests/test_cfm.py | 4 ++-- tests/test_clexer.py | 2 +- tests/test_cmdline.py | 2 +- tests/test_examplefiles.py | 2 +- tests/test_html_formatter.py | 2 +- tests/test_inherit.py | 2 +- tests/test_java.py | 2 +- tests/test_latex_formatter.py | 2 +- tests/test_lexers_other.py | 2 +- tests/test_objectiveclexer.py | 2 +- tests/test_perllexer.py | 2 +- tests/test_qbasiclexer.py | 2 +- tests/test_regexlexer.py | 2 +- tests/test_regexopt.py | 2 +- tests/test_rtf_formatter.py | 2 +- tests/test_ruby.py | 2 +- tests/test_shell.py | 2 +- tests/test_smarty.py | 2 +- tests/test_string_asserts.py | 2 +- tests/test_textfmts.py | 2 +- tests/test_token.py | 2 +- tests/test_unistring.py | 2 +- tests/test_using_api.py | 2 +- tests/test_util.py | 2 +- 197 files changed, 201 insertions(+), 209 deletions(-) diff --git a/LICENSE b/LICENSE index 641c8e8e..10b8e916 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2006-2014 by the respective authors (see AUTHORS file). +Copyright (c) 2006-2015 by the respective authors (see AUTHORS file). All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Makefile b/Makefile index 43ba5f69..2bd350c4 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # # Combines scripts for common tasks. # -# :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. +# :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. # :license: BSD, see LICENSE for details. # diff --git a/doc/_themes/pygments14/layout.html b/doc/_themes/pygments14/layout.html index 93a3119e..2cc03e03 100644 --- a/doc/_themes/pygments14/layout.html +++ b/doc/_themes/pygments14/layout.html @@ -82,7 +82,7 @@ {% block footer %}