summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmr Hesham <amr96@programmer.net>2023-03-02 21:24:29 +0200
committerGitHub <noreply@github.com>2023-03-02 20:24:29 +0100
commit826dc600e8458a2a65c712492c48ec30a19fce2c (patch)
tree18bb219e8409b09a38a539b5f6216fa9e098a22c
parent3ed18e5fe815b1334742a3a15b594aa07486acfd (diff)
downloadpygments-git-826dc600e8458a2a65c712492c48ec30a19fce2c.tar.gz
Add support for impl and constraint declaration in Carbon lexer (#2368)
-rw-r--r--pygments/lexers/carbon.py2
-rw-r--r--tests/examplefiles/carbon/declarations.carbon9
-rw-r--r--tests/examplefiles/carbon/declarations.carbon.output44
3 files changed, 53 insertions, 2 deletions
diff --git a/pygments/lexers/carbon.py b/pygments/lexers/carbon.py
index bb1cb36d..07cf75dd 100644
--- a/pygments/lexers/carbon.py
+++ b/pygments/lexers/carbon.py
@@ -41,7 +41,7 @@ class CarbonLexer(RegexLexer):
# Declaration
(r'(package|import|api|namespace|library)\b', Keyword.Namespace),
(r'(abstract|alias|fn|class|interface|let|var|virtual|external|'
- r'base|addr|extends|choice)\b', Keyword.Declaration),
+ r'base|addr|extends|choice|constraint|impl)\b', Keyword.Declaration),
# Keywords
(words(('as', 'or', 'not', 'and', 'break', 'continue', 'case',
'default', 'if', 'else', 'destructor', 'for', 'forall',
diff --git a/tests/examplefiles/carbon/declarations.carbon b/tests/examplefiles/carbon/declarations.carbon
index 4f61d307..bcb9e05b 100644
--- a/tests/examplefiles/carbon/declarations.carbon
+++ b/tests/examplefiles/carbon/declarations.carbon
@@ -27,4 +27,11 @@ class Pal {
abstract class MyAbstractClass {
protected fn Create() -> partial Self { }
-} \ No newline at end of file
+}
+
+constraint DrawVectorLegoFish {
+ impl as VectorLegoFish;
+ impl as Drawable;
+}
+
+impl JustX as X {} \ No newline at end of file
diff --git a/tests/examplefiles/carbon/declarations.carbon.output b/tests/examplefiles/carbon/declarations.carbon.output
index b1db4d97..48b1362f 100644
--- a/tests/examplefiles/carbon/declarations.carbon.output
+++ b/tests/examplefiles/carbon/declarations.carbon.output
@@ -242,3 +242,47 @@
'}' Punctuation
'\n' Text.Whitespace
+
+'\n' Text.Whitespace
+
+'constraint' Keyword.Declaration
+' ' Text.Whitespace
+'DrawVectorLegoFish' Name.Other
+' ' Text.Whitespace
+'{' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'impl' Keyword.Declaration
+' ' Text.Whitespace
+'as' Keyword
+' ' Text.Whitespace
+'VectorLegoFish' Name.Other
+';' Punctuation
+'\n' Text.Whitespace
+
+' ' Text.Whitespace
+'impl' Keyword.Declaration
+' ' Text.Whitespace
+'as' Keyword
+' ' Text.Whitespace
+'Drawable' Name.Other
+';' Punctuation
+'\n' Text.Whitespace
+
+'}' Punctuation
+'\n' Text.Whitespace
+
+'\n' Text.Whitespace
+
+'impl' Keyword.Declaration
+' ' Text.Whitespace
+'JustX' Name.Other
+' ' Text.Whitespace
+'as' Keyword
+' ' Text.Whitespace
+'X' Name.Other
+' ' Text.Whitespace
+'{' Punctuation
+'}' Punctuation
+'\n' Text.Whitespace