Skip to content

Commit

Permalink
Add tl-b lexer (#2247)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlkv committed Sep 26, 2022
1 parent 72aec98 commit d67f6dd
Show file tree
Hide file tree
Showing 4 changed files with 10,221 additions and 0 deletions.
1 change: 1 addition & 0 deletions pygments/lexers/_mapping.py
Expand Up @@ -490,6 +490,7 @@
'ThingsDBLexer': ('pygments.lexers.thingsdb', 'ThingsDB', ('ti', 'thingsdb'), ('*.ti',), ()),
'ThriftLexer': ('pygments.lexers.dsls', 'Thrift', ('thrift',), ('*.thrift',), ('application/x-thrift',)),
'TiddlyWiki5Lexer': ('pygments.lexers.markup', 'tiddler', ('tid',), ('*.tid',), ('text/vnd.tiddlywiki',)),
'TlbLexer': ('pygments.lexers.tlb', 'Tl-b', ('tlb',), ('*.tlb',), ()),
'TodotxtLexer': ('pygments.lexers.textfmts', 'Todotxt', ('todotxt',), ('todo.txt', '*.todotxt'), ('text/x-todo',)),
'TransactSqlLexer': ('pygments.lexers.sql', 'Transact-SQL', ('tsql', 't-sql'), ('*.sql',), ('text/x-tsql',)),
'TreetopLexer': ('pygments.lexers.parsers', 'Treetop', ('treetop',), ('*.treetop', '*.tt'), ()),
Expand Down
57 changes: 57 additions & 0 deletions pygments/lexers/tlb.py
@@ -0,0 +1,57 @@
"""
pygments.lexers.tlb
~~~~~~~~~~~~~~~~~~~
Lexers for TL-b.
:copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""

from pygments.lexer import RegexLexer, include, words
from pygments.token import Operator, Name, \
Number, Whitespace, Punctuation, Comment

__all__ = ['TlbLexer']


class TlbLexer(RegexLexer):
"""
For TL-b source code.
"""

name = 'Tl-b'
aliases = ['tlb']
filenames = ['*.tlb']

tokens = {
'root': [
(r'\s+', Whitespace),

include('comments'),

(r'[0-9]+', Number),
(words((
'+', '-', '*', '=', '?', '~', '.',
'^', '==', '<', '>', '<=', '>=', '!='
)), Operator),
(words(('##', '#<', '#<=')), Name.Tag),
(r'#[0-9a-f]*_?', Name.Tag),
(r'\$[01]*_?', Name.Tag),

(r'[a-zA-Z_][0-9a-zA-Z_]*', Name),

(r'[;():\[\]{}]', Punctuation)
],

'comments': [
(r'//.*', Comment.Singleline),
(r'/\*', Comment.Multiline, 'comment'),
],
'comment': [
(r'[^/*]+', Comment.Multiline),
(r'/\*', Comment.Multiline, '#push'),
(r'\*/', Comment.Multiline, '#pop'),
(r'[*/]', Comment.Multiline),
],
}

0 comments on commit d67f6dd

Please sign in to comment.