1. Georg Brandl
  2. pygments-main

Commits

David Corbett  committed 4ddfcf3

Update and fix the Inform 6 lexer

  • Participants
  • Parent commits 7b08ead
  • Branches default

Comments (0)

Files changed (2)

File pygments/lexers/compiled.py

View file
  • Ignore whitespace
              Operator, '_expression'),
             (r'(has|hasnt|in|notin|ofclass|or|provides)\b', Operator.Word,
              '_expression'),
-            (r'(from|near|to)\b', Keyword, '_expression'),
             (r'sp\b', Name),
             (r'\?~?', Name.Label, 'label?'),
             (r'[@{]', Error),
             (r':', Punctuation, '#pop'),
             include('expression')
         ],
+        '_keyword-expression': [
+            (r'(from|near|to)\b', Keyword, '_expression'),
+            include('expression')
+        ],
         '_list-expression': [
             (r',', Punctuation, '#pop'),
             include('expression')
             # Other built-in symbols
             (r'(?i)(call|copy|create|DEBUG|destroy|DICT_CHAR_SIZE|'
              r'DICT_ENTRY_BYTES|DICT_IS_UNICODE|DICT_WORD_SIZE|false|'
-             r'FLOAT_INFINITY|FLOAT_NAN|FLOAT_NINFINITY|Grammar__Version|'
-             r'INDIV_PROP_START|INFIX|infix__watching|MODULE_MODE|name|'
-             r'nothing|NUM_ATTR_BYTES|print|print_to_array|recreate|remaining|'
-             r'self|sender|STRICT_MODE|sw__var|sys__glob0|sys__glob1|'
-             r'sys__glob2|sys_statusline_flag|TARGET_GLULX|TARGET_ZCODE|'
-             r'temp__global2|temp__global3|temp__global4|temp_global|true|'
-             r'USE_MODULES|WORDSIZE)\b', Name.Builtin, '#pop'),
+             r'FLOAT_INFINITY|FLOAT_NAN|FLOAT_NINFINITY|GOBJFIELD_CHAIN|'
+             r'GOBJFIELD_CHILD|GOBJFIELD_NAME|GOBJFIELD_PARENT|'
+             r'GOBJFIELD_PROPTAB|GOBJFIELD_SIBLING|GOBJ_EXT_START|'
+             r'GOBJ_TOTAL_LENGTH|Grammar__Version|INDIV_PROP_START|INFIX|'
+             r'infix__watching|MODULE_MODE|name|nothing|NUM_ATTR_BYTES|print|'
+             r'print_to_array|recreate|remaining|self|sender|STRICT_MODE|'
+             r'sw__var|sys__glob0|sys__glob1|sys__glob2|sys_statusline_flag|'
+             r'TARGET_GLULX|TARGET_ZCODE|temp__global2|temp__global3|'
+             r'temp__global4|temp_global|true|USE_MODULES|WORDSIZE)\b',
+             Name.Builtin, '#pop'),
             # Other values
             (_name, Name, '#pop')
         ],
             include('_whitespace'),
             (r'\]', Punctuation, '#pop'),
             (r'[;{}]', Punctuation),
-            (r'(box|break|continue|default|give|inversion|move|new_line|quit|'
-             r'read|remove|return|rfalse|rtrue|spaces|string|until)\b',
-             Keyword, 'default'),
+            (r'(box|break|continue|default|give|inversion|new_line|quit|read|'
+             r'remove|return|rfalse|rtrue|spaces|string|until)\b', Keyword,
+             'default'),
             (r'(do|else)\b', Keyword),
             (r'(font|style)\b', Keyword,
              ('default', 'miscellaneous-keyword?')),
             (r'(if|switch|while)', Keyword,
              ('expression', '_expression', '(?')),
             (r'(jump|save|restore)\b', Keyword, ('default', 'label?')),
-            (r'objectloop\b', Keyword, ('expression', 'variable?', '(?')),
+            (r'objectloop\b', Keyword,
+             ('_keyword-expression', 'variable?', '(?')),
             (r'print(_ret)?\b|(?=[%s])' % _dquote, Keyword, 'print-list'),
             (r'\.', Name.Label, 'label?'),
             (r'@', Keyword, 'opcode'),
             (r'#(?![agrnw]\$|#)', Punctuation, 'directive'),
             (r'<', Punctuation, 'default'),
-            (r'', Text, 'default')
+            (r'(move\b)?', Keyword,
+             ('default', '_keyword-expression', '_expression'))
         ],
         'miscellaneous-keyword?': [
             include('_whitespace'),

File tests/examplefiles/example.inf

View file
  • Ignore whitespace
 Constant Story "Informal Testing";
 Constant Headline "^Not a game.^";!% This is a comment, not ICL.
 
-Release 1;
-Serial "140128";
+Release 2;
+Serial "140308";
 Version 5;
 
 Ifndef TARGET_ZCODE;
 
 Attribute reversed;
 Attribute opaque alias locked;
+Constant to reversed;
 
 Property long additive additive long alias;
 Property long long long wingspan alias alias;
         1, 9:
             box "Testing oneself is best when done alone."
                 "                         -- Jimmy Carter";
-        2, 6, 3 to 5:
+        2, 6, to, 3 to 5, to to to:
             <Take pigeon>;
             #Ifdef VN_1633;
             <Jump, person>;
 
 [ FeelSub; print_ret (The) noun, " feels normal."; ];
 
-Global to;
-[ ReverseSub;
-    to = parent(noun);
+[ ReverseSub from;
+    from = parent(noun);
     move noun to parent(second);
-    move second to to;
-    give noun reversed;
-    give second reversed;
+    if (from == to)
+        move second to to;
+    else
+        move second to from;
+    give noun to;
+    from = to;
+    give second from;
     "You swap ", (the) noun, " and ", (the) second, ".";
 ];