Skip to content

Commit

Permalink
Fix the lexing of Inform 6 properties and doubles (#2214)
Browse files Browse the repository at this point in the history
  • Loading branch information
dscorbett committed Aug 22, 2022
1 parent 8a528f9 commit cbc7143
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
12 changes: 7 additions & 5 deletions pygments/lexers/int_fiction.py
Expand Up @@ -125,7 +125,7 @@ class Inform6Lexer(RegexLexer):
(r'[%s]' % _squote, String.Single, ('#pop', 'dictionary-word')),
(r'[%s]' % _dquote, String.Double, ('#pop', 'string')),
# Numbers
(r'\$[+%s][0-9]*\.?[0-9]*([eE][+%s]?[0-9]+)?' % (_dash, _dash),
(r'\$[<>]?[+%s][0-9]*\.?[0-9]*([eE][+%s]?[0-9]+)?' % (_dash, _dash),
Number.Float, '#pop'),
(r'\$[0-9a-fA-F]+', Number.Hex, '#pop'),
(r'\$\$[01]+', Number.Bin, '#pop'),
Expand Down Expand Up @@ -160,9 +160,10 @@ class Inform6Lexer(RegexLexer):
# Other built-in symbols
(words((
'call', 'copy', 'create', 'DEBUG', 'destroy', 'DICT_CHAR_SIZE',
'DICT_ENTRY_BYTES', 'DICT_IS_UNICODE', 'DICT_WORD_SIZE', 'false',
'FLOAT_INFINITY', 'FLOAT_NAN', 'FLOAT_NINFINITY', 'GOBJFIELD_CHAIN',
'GOBJFIELD_CHILD', 'GOBJFIELD_NAME', 'GOBJFIELD_PARENT',
'DICT_ENTRY_BYTES', 'DICT_IS_UNICODE', 'DICT_WORD_SIZE', 'DOUBLE_HI_INFINITY',
'DOUBLE_HI_NAN', 'DOUBLE_HI_NINFINITY', 'DOUBLE_LO_INFINITY', 'DOUBLE_LO_NAN',
'DOUBLE_LO_NINFINITY', 'false', 'FLOAT_INFINITY', 'FLOAT_NAN', 'FLOAT_NINFINITY',
'GOBJFIELD_CHAIN', 'GOBJFIELD_CHILD', 'GOBJFIELD_NAME', 'GOBJFIELD_PARENT',
'GOBJFIELD_PROPTAB', 'GOBJFIELD_SIBLING', 'GOBJ_EXT_START',
'GOBJ_TOTAL_LENGTH', 'Grammar__Version', 'INDIV_PROP_START', 'INFIX',
'infix__watching', 'MODULE_MODE', 'name', 'nothing', 'NUM_ATTR_BYTES', 'print',
Expand Down Expand Up @@ -411,7 +412,8 @@ class Inform6Lexer(RegexLexer):
],
'property-keyword*': [
include('_whitespace'),
(words(('additive', 'individual', 'long'), suffix=r'\b(?!(\s*|(![^%s]*))*;)' % _newline),
(words(('additive', 'individual', 'long'),
suffix=r'\b(?=(\s*|(![^%s]*[%s]))*[_a-zA-Z])' % (_newline, _newline)),
Keyword),
default('#pop')
],
Expand Down
4 changes: 3 additions & 1 deletion tests/examplefiles/inform6/inform6_example
Expand Up @@ -73,7 +73,7 @@ Property long
! to the semicolon
;
Property additive;
Property individual;
Property individual 1;
Iffalse true;
Property long individual;
Property long individual individual;
Expand Down Expand Up @@ -334,6 +334,8 @@ Extend only 'feel' 'touch' replace * noun -> Feel;
a = '''; ! character
a = $09afAF;
a = $$01;
a = $+1.0;
a = $<-1E-3;
a = ##Eat; a = #a$Eat;
a = #g$self;
a = #n$!word;
Expand Down
23 changes: 23 additions & 0 deletions tests/examplefiles/inform6/inform6_example.output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cbc7143

Please sign in to comment.