Skip to content

Commit

Permalink
Add support for impl and constraint declaration in Carbon lexer (#2368)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed Mar 2, 2023
1 parent 3ed18e5 commit 826dc60
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pygments/lexers/carbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 8 additions & 1 deletion tests/examplefiles/carbon/declarations.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ class Pal {

abstract class MyAbstractClass {
protected fn Create() -> partial Self { }
}
}

constraint DrawVectorLegoFish {
impl as VectorLegoFish;
impl as Drawable;
}

impl JustX as X {}
44 changes: 44 additions & 0 deletions tests/examplefiles/carbon/declarations.carbon.output

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

0 comments on commit 826dc60

Please sign in to comment.