summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Corbett <corbett.dav@northeastern.edu>2022-08-22 12:43:31 -0400
committerGitHub <noreply@github.com>2022-08-22 18:43:31 +0200
commitcbc7143f583caf05729b19c7dce4039d466a48cd (patch)
treef457b7cbb6c190bee45d918c815fad44b88fb743
parent8a528f999462dca75806e37a8543c5fcaad8aef9 (diff)
downloadpygments-git-cbc7143f583caf05729b19c7dce4039d466a48cd.tar.gz
Fix the lexing of Inform 6 properties and doubles (#2214)
-rw-r--r--pygments/lexers/int_fiction.py12
-rw-r--r--tests/examplefiles/inform6/inform6_example4
-rw-r--r--tests/examplefiles/inform6/inform6_example.output23
3 files changed, 33 insertions, 6 deletions
diff --git a/pygments/lexers/int_fiction.py b/pygments/lexers/int_fiction.py
index 0e7c8180..a31a1e31 100644
--- a/pygments/lexers/int_fiction.py
+++ b/pygments/lexers/int_fiction.py
@@ -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'),
@@ -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',
@@ -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')
],
diff --git a/tests/examplefiles/inform6/inform6_example b/tests/examplefiles/inform6/inform6_example
index 3eaef8c7..c7d5de67 100644
--- a/tests/examplefiles/inform6/inform6_example
+++ b/tests/examplefiles/inform6/inform6_example
@@ -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;
@@ -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;
diff --git a/tests/examplefiles/inform6/inform6_example.output b/tests/examplefiles/inform6/inform6_example.output
index 404cb052..ccff13be 100644
--- a/tests/examplefiles/inform6/inform6_example.output
+++ b/tests/examplefiles/inform6/inform6_example.output
@@ -525,6 +525,9 @@
'Property' Keyword
' ' Text
'individual' Name.Constant
+' ' Text
+'' Text
+'1' Literal.Number.Integer
'' Punctuation
';' Punctuation
'\n' Text
@@ -3478,6 +3481,26 @@
'=' Operator
' ' Text
'' Text
+'$+1.0' Literal.Number.Float
+'' Punctuation
+';' Punctuation
+'\n ' Text
+'' Text
+'a' Name
+' ' Text
+'=' Operator
+' ' Text
+'' Text
+'$<-1E-3' Literal.Number.Float
+'' Punctuation
+';' Punctuation
+'\n ' Text
+'' Text
+'a' Name
+' ' Text
+'=' Operator
+' ' Text
+'' Text
'##' Operator
'Eat' Name
'' Punctuation