summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Corbett <corbett.dav@northeastern.edu>2022-07-16 02:39:33 -0400
committerGitHub <noreply@github.com>2022-07-16 08:39:33 +0200
commit4c2be199e6f2beb59eb99d769fdfca3fac9ef8ee (patch)
tree6ce99d417181f2c543cc231cf8ee0a00eaa2a1ac
parenta5631c348952f6f742ecac3214a25297d0757fce (diff)
downloadpygments-git-4c2be199e6f2beb59eb99d769fdfca3fac9ef8ee.tar.gz
Update `Inform6Lexer` to Inform 6.40 (#2190)
-rw-r--r--pygments/lexers/int_fiction.py17
-rw-r--r--tests/examplefiles/inform6/inform6_example4
-rw-r--r--tests/examplefiles/inform6/inform6_example.output58
-rw-r--r--tests/examplefiles/inform7/example.ni.output3
4 files changed, 70 insertions, 12 deletions
diff --git a/pygments/lexers/int_fiction.py b/pygments/lexers/int_fiction.py
index 01ad8b7c..0e7c8180 100644
--- a/pygments/lexers/int_fiction.py
+++ b/pygments/lexers/int_fiction.py
@@ -175,6 +175,10 @@ class Inform6Lexer(RegexLexer):
# Other values
(_name, Name, '#pop')
],
+ 'value?': [
+ include('value'),
+ default('#pop')
+ ],
# Strings
'dictionary-word': [
(r'[~^]+', String.Escape),
@@ -191,8 +195,8 @@ class Inform6Lexer(RegexLexer):
(r'\\', String.Escape),
(r'@(\\\s*[%s]\s*)*@((\\\s*[%s]\s*)*[0-9])*' %
(_newline, _newline), String.Escape),
- (r'@(\\\s*[%s]\s*)*\{((\\\s*[%s]\s*)*[0-9a-fA-F])*'
- r'(\\\s*[%s]\s*)*\}' % (_newline, _newline, _newline),
+ (r'@(\\\s*[%s]\s*)*[({]((\\\s*[%s]\s*)*[0-9a-zA-Z_])*'
+ r'(\\\s*[%s]\s*)*[)}]' % (_newline, _newline, _newline),
String.Escape),
(r'@(\\\s*[%s]\s*)*.(\\\s*[%s]\s*)*.' % (_newline, _newline),
String.Escape),
@@ -210,6 +214,13 @@ class Inform6Lexer(RegexLexer):
(_name, Name.Constant, '#pop'),
include('value')
],
+ 'constant*': [
+ include('_whitespace'),
+ (r',', Punctuation),
+ (r'=', Punctuation, 'value?'),
+ (_name, Name.Constant, 'value?'),
+ default('#pop')
+ ],
'_global': [
include('_whitespace'),
(_name, Name.Variable.Global, '#pop'),
@@ -252,7 +263,7 @@ class Inform6Lexer(RegexLexer):
(r'(?i)class\b', Keyword,
('object-body', 'duplicates', 'class-name')),
(r'(?i)(constant|default)\b', Keyword,
- ('default', 'expression', '_constant')),
+ ('default', 'constant*')),
(r'(?i)(end\b)(.*)', bygroups(Keyword, Text)),
(r'(?i)(extend|verb)\b', Keyword, 'grammar'),
(r'(?i)fake_action\b', Keyword, ('default', '_constant')),
diff --git a/tests/examplefiles/inform6/inform6_example b/tests/examplefiles/inform6/inform6_example
index 330d4eb4..3eaef8c7 100644
--- a/tests/examplefiles/inform6/inform6_example
+++ b/tests/examplefiles/inform6/inform6_example
@@ -89,6 +89,7 @@ Class Bird(10) has animate class Flier with wingspan 2;
Constant Constant1;
Constant Constant2 Constant1;
Constant Constant3 = Constant2;
+Constant Constant4 = 1, Constant5, Constant6 = 2;
Ifdef VN_1633; Undef Constant1; Endif;
Ifdef VN_1633;
@@ -101,8 +102,10 @@ Fake_action NotReal;
Global global1;
Global global2 = 69105;
+Global global3 69105;
Lowstring low_string "low string";
+Constant LOW_STRING_N = 25;
Iftrue false;
Message error "Uh-oh!^~false~ shouldn't be ~true~.";
@@ -246,6 +249,7 @@ Extend only 'feel' 'touch' replace * noun -> Feel;
" by mnemonic: @!! @<< @'A @AE @et @:y^",
" by decimal value: @@64 @@126^",
" by Unicode value: @{DC}@{002b}^",
+ " by string variable via constant: @(LOW_STRING_N)^",
" by string variable: @25^";
'font', 'style':
font off; print "font off^";
diff --git a/tests/examplefiles/inform6/inform6_example.output b/tests/examplefiles/inform6/inform6_example.output
index be35bb50..404cb052 100644
--- a/tests/examplefiles/inform6/inform6_example.output
+++ b/tests/examplefiles/inform6/inform6_example.output
@@ -17,7 +17,6 @@
' ' Text
'Story' Name.Constant
' ' Text
-'' Text
'"' Literal.String.Double
'Informal Testing' Literal.String.Double
'"' Literal.String.Double
@@ -29,7 +28,6 @@
' ' Text
'Headline' Name.Constant
' ' Text
-'' Text
'"' Literal.String.Double
'^' Literal.String.Escape
'Not a game.' Literal.String.Double
@@ -94,7 +92,6 @@
' ' Text
'WORDSIZE' Name.Constant
' ' Text
-'' Text
'2' Literal.Number.Integer
'' Punctuation
';' Punctuation
@@ -448,7 +445,6 @@
' ' Text
'to' Name.Constant
' ' Text
-'' Text
'reversed' Name
'' Punctuation
';' Punctuation
@@ -671,7 +667,6 @@
' ' Text
'Constant2' Name.Constant
' ' Text
-'' Text
'Constant1' Name
'' Punctuation
';' Punctuation
@@ -681,14 +676,34 @@
' ' Text
'Constant3' Name.Constant
' ' Text
-'=' Operator
+'=' Punctuation
' ' Text
-'' Text
'Constant2' Name
'' Punctuation
';' Punctuation
'\n' Text
+'Constant' Keyword
+' ' Text
+'Constant4' Name.Constant
+' ' Text
+'=' Punctuation
+' ' Text
+'1' Literal.Number.Integer
+',' Punctuation
+' ' Text
+'Constant5' Name.Constant
+',' Punctuation
+' ' Text
+'Constant6' Name.Constant
+' ' Text
+'=' Punctuation
+' ' Text
+'2' Literal.Number.Integer
+'' Punctuation
+';' Punctuation
+'\n' Text
+
'Ifdef' Keyword
' ' Text
'' Text
@@ -778,6 +793,16 @@
'69105' Literal.Number.Integer
'' Punctuation
';' Punctuation
+'\n' Text
+
+'Global' Keyword
+' ' Text
+'global3' Name.Variable.Global
+' ' Text
+'' Text
+'69105' Literal.Number.Integer
+'' Punctuation
+';' Punctuation
'\n\n' Text
'Lowstring' Keyword
@@ -790,6 +815,17 @@
'"' Literal.String.Double
'' Punctuation
';' Punctuation
+'\n' Text
+
+'Constant' Keyword
+' ' Text
+'LOW_STRING_N' Name.Constant
+' ' Text
+'=' Punctuation
+' ' Text
+'25' Literal.Number.Integer
+'' Punctuation
+';' Punctuation
'\n\n' Text
'Iftrue' Keyword
@@ -2339,6 +2375,14 @@
'\n ' Text
'' Text
'"' Literal.String.Double
+' by string variable via constant: ' Literal.String.Double
+'@(LOW_STRING_N)' Literal.String.Escape
+'^' Literal.String.Escape
+'"' Literal.String.Double
+',' Punctuation
+'\n ' Text
+'' Text
+'"' Literal.String.Double
' by string variable: ' Literal.String.Double
'@25' Literal.String.Escape
'^' Literal.String.Escape
diff --git a/tests/examplefiles/inform7/example.ni.output b/tests/examplefiles/inform7/example.ni.output
index 406fa97a..4895bb3d 100644
--- a/tests/examplefiles/inform7/example.ni.output
+++ b/tests/examplefiles/inform7/example.ni.output
@@ -55,9 +55,8 @@
' ' Text
'MAX_TESTS' Name.Constant
' ' Text
-'=' Operator
+'=' Punctuation
' ' Text
-'' Text
'{' Punctuation
'N' Text
'}' Punctuation