summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Corbett <corbett.dav@husky.neu.edu>2014-03-16 15:31:46 -0400
committerDavid Corbett <corbett.dav@husky.neu.edu>2014-03-16 15:31:46 -0400
commit8f8ed8cf3e577fb07cd95c66a65b1aac1fa285d2 (patch)
tree45515a78f9503190048963c60d52f2f1c48fae00
parent37f118ebedd03947ba5b04dcd9ba21269cfa3a88 (diff)
downloadpygments-8f8ed8cf3e577fb07cd95c66a65b1aac1fa285d2.tar.gz
Update and fix the Inform 6 lexer
-rw-r--r--pygments/lexers/compiled.py34
-rw-r--r--tests/examplefiles/example.inf22
2 files changed, 34 insertions, 22 deletions
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 0a244357..9a242d61 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -4017,7 +4017,6 @@ class Inform6Lexer(RegexLexer):
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),
@@ -4036,6 +4035,10 @@ class Inform6Lexer(RegexLexer):
(r':', Punctuation, '#pop'),
include('expression')
],
+ '_keyword-expression': [
+ (r'(from|near|to)\b', Keyword, '_expression'),
+ include('expression')
+ ],
'_list-expression': [
(r',', Punctuation, '#pop'),
include('expression')
@@ -4088,13 +4091,16 @@ class Inform6Lexer(RegexLexer):
# 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')
],
@@ -4327,9 +4333,9 @@ class Inform6Lexer(RegexLexer):
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?')),
@@ -4337,13 +4343,15 @@ class Inform6Lexer(RegexLexer):
(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'),
diff --git a/tests/examplefiles/example.inf b/tests/examplefiles/example.inf
index bc163de9..73cdd087 100644
--- a/tests/examplefiles/example.inf
+++ b/tests/examplefiles/example.inf
@@ -8,8 +8,8 @@ Switches d2SDq;
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;
@@ -58,6 +58,7 @@ Array table buffer 260;
Attribute reversed;
Attribute opaque alias locked;
+Constant to reversed;
Property long additive additive long alias;
Property long long long wingspan alias alias;
@@ -271,7 +272,7 @@ Extend only 'feel' 'touch' replace * noun -> Feel;
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>;
@@ -357,13 +358,16 @@ Extend only 'feel' 'touch' replace * noun -> Feel;
[ 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, ".";
];